diff --git a/client/src/components/game.jsx b/client/src/components/game.jsx index 56e15b36..052c7e65 100644 --- a/client/src/components/game.jsx +++ b/client/src/components/game.jsx @@ -33,7 +33,6 @@ function GamePanel(props) { }); function PlayerCrypCard(cryp) { - if (activeIncoming) console.log('should be a pointer'); return (
dmg <-> heal +immune to status effects + physical, magic, pure dmg? elemental? diff --git a/server/src/game.rs b/server/src/game.rs index fe8a28dd..2cff784f 100755 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -62,6 +62,7 @@ impl GameSkill { // roll = c.skills.iter().fold(roll, |roll, s| s.apply(roll)); // finally combine with stat + println!("{:?}'s stats", c.name); println!("{:064b} <- finalised", roll.result); roll.result = roll.result & stat.value; @@ -385,8 +386,9 @@ impl Game { for team in self.teams.clone().iter_mut() { for incoming in team.incoming.clone().iter_mut() { // they better fuckin be there - let mut cryp = self.cryp_by_id(incoming.target_cryp_id.unwrap()).clone(); + let mut cryp = self.cryp_by_id(incoming.cryp_id).clone(); let mut target_cryp = self.cryp_by_id(incoming.target_cryp_id.unwrap()).clone(); + println!("{:?} is attacking {:?}", cryp.name, target_cryp.name); incoming.resolve(&mut cryp, &mut target_cryp); self.update_cryp(target_cryp); } diff --git a/server/src/rpc.rs b/server/src/rpc.rs index b31abc00..64a14bc5 100755 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -184,19 +184,25 @@ impl Rpc { } - fn cryp_spawn(data: Vec, tx: &mut Transaction, account: Option, _client: &mut WebSocket) -> Result { - match from_slice::(&data) { - Ok(v) => { - match account { - Some(a) => Ok(RpcResponse { - method: v.method, - params: RpcResult::SpawnCryp(cryp_spawn(v.params, tx, &a)?) - }), - None => Err(err_msg("auth required")), - } - } - Err(_e) => Err(err_msg("invalid params")), - } + fn cryp_spawn(data: Vec, tx: &mut Transaction, account: Option, client: &mut WebSocket) -> Result { + let a = match account { + Some(a) => a, + None => return Err(err_msg("auth required")), + }; + + let msg = from_slice::(&data).or(Err(err_msg("invalid params")))?; + + Rpc::send_msg(client, RpcResponse { + method: "cryp_spawn".to_string(), + params: RpcResult::CrypSpawn(cryp_spawn(msg.params, tx, &a)?) + })?; + + let cryp_list = RpcResponse { + method: "account_cryps".to_string(), + params: RpcResult::CrypList(account_cryps(tx, &a)?) + }; + + Ok(cryp_list) } fn account_create(data: Vec, tx: &mut Transaction, _account: Option, _client: &mut WebSocket) -> Result { @@ -268,7 +274,7 @@ pub struct RpcResponse { #[derive(Debug,Clone,Serialize,Deserialize)] pub enum RpcResult { - SpawnCryp(Cryp), + CrypSpawn(Cryp), Account(Account), CrypList(Vec), GameState(Game),