We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
One Dispatch example
dispatch({type: KILL_ACTION, payload:{triggerBy: houyi, triggerTo: npc1}); const npcInfo = (state = initState, action) => produce(state, draft => { const { type: actionType, triggerBy, triggerTo } = action; draft.npcs.forEach( (npc,index) => if( npc[actionType] ){ const { onlyDirect, isAny, types, triggers, blockers } = npc[actionType]; if((onlyDirect && triggerTo.id !== npc.id) || blockers.includes(triggerBy.id)) || (!isAny && !types.includes(triggerBy.type) && !triggers.includes(triggerBy.id))){ return; } /* reaction -> e.g: [ {type:ADD, props:'hp', value: 100 }, {type:MAYBE_ADD, props:'mp', rate: 0.9 , value: 0 }, ] */ const reactions = npc[actionType].reactions; // processReaction is a function in common util const updatedNpc = processReaction(reactions, npc); draft.npcs[index] = updatedNpc; }) } const processReaction = (reactions, target) => { for (const reaction of reactions){ switch(reaction.type){ case ADD: target[reaction.props] += reaction.value; break; case MAYBE_ADD: if(randomCheck(seed)){ target[reaction.props] += reaction.value; } break; //... } } return target; }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
One Dispatch example
The text was updated successfully, but these errors were encountered: