diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index e8340934..7c4f2e70 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -72,7 +72,7 @@ function InstanceComponent(args) { if (!instance) return
...
; - const cryps = instance.cryps.map(c => Cryp(c, sendVboxApply, setInfo)); + const cryps = instance.cryps.map((c, i) => Cryp(c, sendVboxApply, setInfo)); return (
diff --git a/client/src/events.jsx b/client/src/events.jsx index cbc3a632..6d178ad7 100644 --- a/client/src/events.jsx +++ b/client/src/events.jsx @@ -54,6 +54,8 @@ function registerEvents(store) { } function setPlayer(v) { + const { instance } = store.getState(); + console.log(instance === v); return store.dispatch(actions.setInstance(v)); } diff --git a/client/src/reducers.jsx b/client/src/reducers.jsx index d48b18ad..ce1f20da 100644 --- a/client/src/reducers.jsx +++ b/client/src/reducers.jsx @@ -44,7 +44,7 @@ const defaultInstance = null; function instanceReducer(state = defaultInstance, action) { switch (action.type) { case actions.SET_INSTANCE: - return action.value; + return Object.assign({}, action.value); default: return state; } diff --git a/server/src/vbox.rs b/server/src/vbox.rs index 26b8e18b..21a9de06 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -638,6 +638,20 @@ pub fn vbox_unequip(params: VboxUnequipParams, tx: &mut Transaction, account: &A None => return Err(err_msg("var has no effect on cryps")), } + // now the var has been applied + // recalculate the stats of the whole team + let team_colours = player.cryps.iter().fold(Colours::new(), |tc, c| { + Colours { + red: tc.red + c.colours.red, + green: tc.green + c.colours.green, + blue: tc.blue + c.colours.blue + } + }); + + for cryp in player.cryps.iter_mut() { + cryp.apply_modifiers(&team_colours); + } + player.vbox.bound.push(params.target); return player_update(tx, player, false); }