From 3cb15a8c1e6628097558eb3d485a41b5b323ddc8 Mon Sep 17 00:00:00 2001 From: ntr Date: Sun, 15 Sep 2019 17:27:00 +1000 Subject: [PATCH] remove self targeting --- client/src/components/play.jsx | 9 ++-- server/src/construct.rs | 2 - server/src/game.rs | 94 ++++++++++++++++------------------ server/src/rpc.rs | 2 +- server/src/skill.rs | 14 ----- 5 files changed, 49 insertions(+), 72 deletions(-) diff --git a/client/src/components/play.jsx b/client/src/components/play.jsx index b76feb0c..362ed057 100644 --- a/client/src/components/play.jsx +++ b/client/src/components/play.jsx @@ -92,13 +92,14 @@ function Play(args) {

v{VERSION}

-

use the buttons on the right to join an instance.

+

Use the buttons on the right to join an instance.

- select PVP to play against other players.
- click LEARN to practice the game without time controls. + Select PVP to play against other players.
+ Select INVITE then click COPY LINK to generate an instance invitation for a friend.
+ Click LEARN to practice the game without time controls.

- if you enjoy the game please support its development by subscribing or purchasing credits.
+ If you enjoy the game please support its development by subscribing or purchasing credits.
glhf

--ntr & mashy

diff --git a/server/src/construct.rs b/server/src/construct.rs index 2d0e4fe8..80b4d7bb 100644 --- a/server/src/construct.rs +++ b/server/src/construct.rs @@ -46,7 +46,6 @@ impl Colours { #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] pub struct ConstructSkill { pub skill: Skill, - pub self_targeting: bool, pub cd: Cooldown, // used for Uon client pub disabled: bool, @@ -56,7 +55,6 @@ impl ConstructSkill { pub fn new(skill: Skill) -> ConstructSkill { ConstructSkill { skill, - self_targeting: skill.self_targeting(), cd: skill.base_cd(), disabled: false, } diff --git a/server/src/game.rs b/server/src/game.rs index caeb1e61..97354d86 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -236,7 +236,7 @@ impl Game { target = find_target(); } - pve_skills.push((mobs.id, mob.id, Some(target.id), s)); + pve_skills.push((mobs.id, mob.id, target.id, s)); }, None => continue, }; @@ -258,7 +258,7 @@ impl Game { self } - fn add_skill(&mut self, player_id: Uuid, source_construct_id: Uuid, target_construct_id: Option, skill: Skill) -> Result<&mut Game, Error> { + fn add_skill(&mut self, player_id: Uuid, source_construct_id: Uuid, target_construct_id: Uuid, skill: Skill) -> Result<&mut Game, Error> { // check player in game self.player_by_id(player_id)?; @@ -266,17 +266,9 @@ impl Game { return Err(err_msg("game not in skill phase")); } - let final_target_id = match skill.self_targeting() { - true => source_construct_id, - false => match target_construct_id { - Some(t) => t, - None => return Err(err_msg("skill requires a target")), - } - }; - // target checks { - let target = match self.construct_by_id(final_target_id) { + let target = match self.construct_by_id(target_construct_id) { Some(c) => c, None => return Err(err_msg("target construct not in game")), }; @@ -318,7 +310,7 @@ impl Game { self.stack.remove(s); } - let skill = Cast::new(source_construct_id, player_id, final_target_id, skill); + let skill = Cast::new(source_construct_id, player_id, target_construct_id, skill); self.stack.push(skill); return Ok(self); @@ -887,7 +879,7 @@ fn game_json_file_write(g: &Game) -> Result { Ok(dest) } -pub fn game_skill(tx: &mut Transaction, account: &Account, game_id: Uuid, construct_id: Uuid, target_construct_id: Option, skill: Skill) -> Result { +pub fn game_skill(tx: &mut Transaction, account: &Account, game_id: Uuid, construct_id: Uuid, target_construct_id: Uuid, skill: Skill) -> Result { let mut game = game_get(tx, game_id)?; game.add_skill(account.id, construct_id, target_construct_id, skill)?; @@ -1039,8 +1031,8 @@ mod tests { let x_construct = x_player.constructs[0].clone(); let y_construct = y_player.constructs[0].clone(); - game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Attack).unwrap(); - game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Attack).unwrap(); + game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1068,8 +1060,8 @@ mod tests { game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap(); - game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Stun).unwrap(); + game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1105,8 +1097,8 @@ mod tests { // remove all mitigation game.player_by_id(x_player.id).unwrap().construct_by_id(x_construct.id).unwrap().red_life.force(0); - game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap(); - game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Stun).unwrap(); + game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1135,8 +1127,8 @@ mod tests { assert!(game.player_by_id(y_player.id).unwrap().constructs[0].skill_on_cd(Skill::Stun).is_some()); assert!(game.player_by_id(x_player.id).unwrap().constructs[0].skill_on_cd(Skill::Block).is_none()); - game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Attack).unwrap(); - game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Attack).unwrap(); + game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1149,8 +1141,8 @@ mod tests { // second round // now we block and it should go back on cd - // game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Stun).unwrap(); - game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); + // game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Stun).unwrap(); + game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1179,8 +1171,8 @@ mod tests { game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.add_skill(x_player.id, x_construct.id, None, Skill::Counter).unwrap(); - game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Stun).unwrap(); + game.add_skill(x_player.id, x_construct.id, x_construct.id, Skill::Counter).unwrap(); + game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::Stun).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); @@ -1214,14 +1206,14 @@ mod tests { } // apply buff - game.add_skill(x_player.id, x_construct.id, Some(x_construct.id), Skill::Electrify).unwrap(); + game.add_skill(x_player.id, x_construct.id, x_construct.id, Skill::Electrify).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Electric)); // attack and receive debuff - game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); + game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); @@ -1246,7 +1238,7 @@ mod tests { } // apply buff - game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Link).unwrap(); + game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Link).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); @@ -1265,7 +1257,7 @@ mod tests { } // attack and receive link hit - game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); + game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); @@ -1296,14 +1288,14 @@ mod tests { // } // // apply buff - // game.add_skill(x_player.id, x_construct.id, Some(x_construct.id), Skill::Absorb).unwrap(); + // game.add_skill(x_player.id, x_construct.id, x_construct.id, Skill::Absorb).unwrap(); // game.player_ready(x_player.id).unwrap(); // game.player_ready(y_player.id).unwrap(); // game = game.resolve_phase_start(); // assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Absorb)); // // attack and receive debuff - // game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::TestAttack).unwrap(); + // game.add_skill(y_player.id, y_construct.id, x_construct.id, Skill::TestAttack).unwrap(); // game.player_ready(x_player.id).unwrap(); // game.player_ready(y_player.id).unwrap(); // game = game.resolve_phase_start(); @@ -1330,10 +1322,10 @@ mod tests { game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); - game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); - game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Ruin).unwrap(); - game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::Attack).unwrap(); + game.add_skill(i_player.id, i_construct.id, x_construct.id, Skill::Attack).unwrap(); + game.add_skill(i_player.id, j_construct.id, x_construct.id, Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, i_construct.id, Skill::Ruin).unwrap(); + game.add_skill(x_player.id, y_construct.id, i_construct.id, Skill::Attack).unwrap(); game.player_ready(i_player.id).unwrap(); game.player_ready(x_player.id).unwrap(); @@ -1380,10 +1372,10 @@ mod tests { game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); } - game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); - game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); - game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Intercept).unwrap(); - game.add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::Attack).unwrap(); + game.add_skill(i_player.id, i_construct.id, x_construct.id, Skill::Attack).unwrap(); + game.add_skill(i_player.id, j_construct.id, x_construct.id, Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, i_construct.id, Skill::Intercept).unwrap(); + game.add_skill(x_player.id, y_construct.id, i_construct.id, Skill::Attack).unwrap(); game.player_ready(i_player.id).unwrap(); game.player_ready(x_player.id).unwrap(); @@ -1411,10 +1403,10 @@ mod tests { let x_construct = x_player.constructs[0].clone(); let y_construct = x_player.constructs[1].clone(); - game.add_skill(i_player.id, i_construct.id, Some(x_construct.id), Skill::Attack).unwrap() - .add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::Attack).unwrap() - .add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Attack).unwrap() - .add_skill(x_player.id, y_construct.id, Some(i_construct.id), Skill::Attack).unwrap() + game.add_skill(i_player.id, i_construct.id, x_construct.id, Skill::Attack).unwrap() + .add_skill(i_player.id, j_construct.id, x_construct.id, Skill::Attack).unwrap() + .add_skill(x_player.id, x_construct.id, i_construct.id, Skill::Attack).unwrap() + .add_skill(x_player.id, y_construct.id, i_construct.id, Skill::Attack).unwrap() .player_ready(i_player.id).unwrap() .player_ready(x_player.id).unwrap(); @@ -1430,10 +1422,10 @@ mod tests { assert!(game.player_by_id(x_player.id).unwrap().skills_required() == 2); // add some more skills - game.add_skill(i_player.id, j_construct.id, Some(x_construct.id), Skill::Attack).unwrap(); - game.add_skill(x_player.id, x_construct.id, Some(j_construct.id), Skill::Attack).unwrap(); - game.add_skill(x_player.id, y_construct.id, Some(j_construct.id), Skill::Attack).unwrap(); - assert!(game.add_skill(x_player.id, x_construct.id, Some(i_construct.id), Skill::Attack).is_err()); + game.add_skill(i_player.id, j_construct.id, x_construct.id, Skill::Attack).unwrap(); + game.add_skill(x_player.id, x_construct.id, j_construct.id, Skill::Attack).unwrap(); + game.add_skill(x_player.id, y_construct.id, j_construct.id, Skill::Attack).unwrap(); + assert!(game.add_skill(x_player.id, x_construct.id, i_construct.id, Skill::Attack).is_err()); game.player_ready(i_player.id).unwrap(); game.player_ready(x_player.id).unwrap(); @@ -1475,7 +1467,7 @@ mod tests { } // apply buff - game.add_skill(x_player.id, x_construct.id, Some(y_construct.id), Skill::Decay).unwrap(); + game.add_skill(x_player.id, x_construct.id, y_construct.id, Skill::Decay).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); @@ -1490,7 +1482,7 @@ mod tests { game.resolved.clear(); // remove - game.add_skill(y_player.id, y_construct.id, Some(y_construct.id), Skill::Purify).unwrap(); + game.add_skill(y_player.id, y_construct.id, y_construct.id, Skill::Purify).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); @@ -1503,14 +1495,14 @@ mod tests { } }; - game.add_skill(y_player.id, x_construct.id, Some(y_construct.id), Skill::Siphon).unwrap(); + game.add_skill(y_player.id, x_construct.id, y_construct.id, Skill::Siphon).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); game.resolved.clear(); - game.add_skill(y_player.id, y_construct.id, Some(y_construct.id), Skill::Purify).unwrap(); + game.add_skill(y_player.id, y_construct.id, y_construct.id, Skill::Purify).unwrap(); game.player_ready(x_player.id).unwrap(); game.player_ready(y_player.id).unwrap(); game = game.resolve_phase_start(); diff --git a/server/src/rpc.rs b/server/src/rpc.rs index 3439a6c4..be3071e8 100644 --- a/server/src/rpc.rs +++ b/server/src/rpc.rs @@ -82,7 +82,7 @@ pub enum RpcRequest { GameState { id: Uuid }, GameReady { id: Uuid }, - GameSkill { game_id: Uuid, construct_id: Uuid, target_construct_id: Option, skill: Skill }, + GameSkill { game_id: Uuid, construct_id: Uuid, target_construct_id: Uuid, skill: Skill }, GameSkillClear { game_id: Uuid }, AccountState {}, diff --git a/server/src/skill.rs b/server/src/skill.rs index d71ac47e..52ef3092 100644 --- a/server/src/skill.rs +++ b/server/src/skill.rs @@ -1213,20 +1213,6 @@ impl Skill { } } - pub fn self_targeting(&self) -> bool { - match self { - Skill::Block | - Skill::Sustain| - Skill::SustainPlus | - Skill::SustainPlusPlus | - Skill::Counter| - Skill::CounterPlus | - Skill::CounterPlusPlus => true, - - _ => false, - } - } - pub fn defensive(&self) -> bool { let mut rng = thread_rng();