remove self targeting

This commit is contained in:
ntr 2019-09-15 17:27:00 +10:00
parent 8cbaf2d597
commit 3cb15a8c1e
5 changed files with 49 additions and 72 deletions

View File

@ -92,13 +92,14 @@ function Play(args) {
<section class="top"> <section class="top">
<div class="news"> <div class="news">
<h1>v{VERSION}</h1> <h1>v{VERSION}</h1>
<p>use the buttons on the right to join an instance.</p> <p>Use the buttons on the right to join an instance.</p>
<p> <p>
select <b>PVP</b> to play against other players.<br /> Select <b>PVP</b> to play against other players.<br />
click <b>LEARN</b> to practice the game without time controls. Select <b>INVITE</b> then click <b>COPY LINK</b> to generate an instance invitation for a friend.<br />
Click <b>LEARN</b> to practice the game without time controls.
</p> </p>
<p> <p>
if you enjoy the game please support its development by <b>subscribing</b> or purchasing <b>credits</b>.<br /> If you enjoy the game please support its development by <b>subscribing</b> or purchasing <b>credits</b>.<br />
glhf glhf
</p> </p>
<p>--ntr & mashy</p> <p>--ntr & mashy</p>

View File

@ -46,7 +46,6 @@ impl Colours {
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub struct ConstructSkill { pub struct ConstructSkill {
pub skill: Skill, pub skill: Skill,
pub self_targeting: bool,
pub cd: Cooldown, pub cd: Cooldown,
// used for Uon client // used for Uon client
pub disabled: bool, pub disabled: bool,
@ -56,7 +55,6 @@ impl ConstructSkill {
pub fn new(skill: Skill) -> ConstructSkill { pub fn new(skill: Skill) -> ConstructSkill {
ConstructSkill { ConstructSkill {
skill, skill,
self_targeting: skill.self_targeting(),
cd: skill.base_cd(), cd: skill.base_cd(),
disabled: false, disabled: false,
} }

View File

@ -236,7 +236,7 @@ impl Game {
target = find_target(); 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, None => continue,
}; };
@ -258,7 +258,7 @@ impl Game {
self self
} }
fn add_skill(&mut self, player_id: Uuid, source_construct_id: Uuid, target_construct_id: Option<Uuid>, 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 // check player in game
self.player_by_id(player_id)?; self.player_by_id(player_id)?;
@ -266,17 +266,9 @@ impl Game {
return Err(err_msg("game not in skill phase")); 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 // 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, Some(c) => c,
None => return Err(err_msg("target construct not in game")), None => return Err(err_msg("target construct not in game")),
}; };
@ -318,7 +310,7 @@ impl Game {
self.stack.remove(s); 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); self.stack.push(skill);
return Ok(self); return Ok(self);
@ -887,7 +879,7 @@ fn game_json_file_write(g: &Game) -> Result<String, Error> {
Ok(dest) Ok(dest)
} }
pub fn game_skill(tx: &mut Transaction, account: &Account, game_id: Uuid, construct_id: Uuid, target_construct_id: Option<Uuid>, skill: Skill) -> Result<Game, Error> { pub fn game_skill(tx: &mut Transaction, account: &Account, game_id: Uuid, construct_id: Uuid, target_construct_id: Uuid, skill: Skill) -> Result<Game, Error> {
let mut game = game_get(tx, game_id)?; let mut game = game_get(tx, game_id)?;
game.add_skill(account.id, construct_id, target_construct_id, skill)?; 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 x_construct = x_player.constructs[0].clone();
let y_construct = y_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(x_player.id, x_construct.id, 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(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_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.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(x_player.id, x_construct.id, 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(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1105,8 +1097,8 @@ mod tests {
// remove all mitigation // remove all mitigation
game.player_by_id(x_player.id).unwrap().construct_by_id(x_construct.id).unwrap().red_life.force(0); 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(x_player.id, x_construct.id, 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(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_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(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()); 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(x_player.id, x_construct.id, 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(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1149,8 +1141,8 @@ mod tests {
// second round // second round
// now we block and it should go back on cd // 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(x_player.id, x_construct.id, 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(y_player.id, y_construct.id, x_construct.id, Skill::Attack).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
game.player_ready(y_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.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(x_player.id, x_construct.id, x_construct.id, Skill::Counter).unwrap();
game.add_skill(y_player.id, y_construct.id, Some(x_construct.id), Skill::Stun).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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
@ -1214,14 +1206,14 @@ mod tests {
} }
// apply buff // 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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Electric)); assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Electric));
// attack and receive debuff // 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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
@ -1246,7 +1238,7 @@ mod tests {
} }
// apply buff // 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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
@ -1265,7 +1257,7 @@ mod tests {
} }
// attack and receive link hit // 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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
@ -1296,14 +1288,14 @@ mod tests {
// } // }
// // apply buff // // 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(x_player.id).unwrap();
// game.player_ready(y_player.id).unwrap(); // game.player_ready(y_player.id).unwrap();
// game = game.resolve_phase_start(); // game = game.resolve_phase_start();
// assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Absorb)); // assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Absorb));
// // attack and receive debuff // // 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(x_player.id).unwrap();
// game.player_ready(y_player.id).unwrap(); // game.player_ready(y_player.id).unwrap();
// game = game.resolve_phase_start(); // game = game.resolve_phase_start();
@ -1330,10 +1322,10 @@ mod tests {
game.construct_by_id(x_construct.id).unwrap().reduce_cooldowns(); 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, i_construct.id, 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(i_player.id, j_construct.id, 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, x_construct.id, 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(x_player.id, y_construct.id, i_construct.id, Skill::Attack).unwrap();
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_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.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, i_construct.id, 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(i_player.id, j_construct.id, 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, x_construct.id, 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(x_player.id, y_construct.id, i_construct.id, Skill::Attack).unwrap();
game.player_ready(i_player.id).unwrap(); game.player_ready(i_player.id).unwrap();
game.player_ready(x_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 x_construct = x_player.constructs[0].clone();
let y_construct = x_player.constructs[1].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() game.add_skill(i_player.id, i_construct.id, x_construct.id, Skill::Attack).unwrap()
.add_skill(i_player.id, j_construct.id, Some(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, Some(i_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, Some(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(i_player.id).unwrap()
.player_ready(x_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); assert!(game.player_by_id(x_player.id).unwrap().skills_required() == 2);
// add some more skills // add some more skills
game.add_skill(i_player.id, j_construct.id, Some(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, Some(j_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, Some(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, Some(i_construct.id), Skill::Attack).is_err()); 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(i_player.id).unwrap();
game.player_ready(x_player.id).unwrap(); game.player_ready(x_player.id).unwrap();
@ -1475,7 +1467,7 @@ mod tests {
} }
// apply buff // 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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
@ -1490,7 +1482,7 @@ mod tests {
game.resolved.clear(); game.resolved.clear();
// remove // 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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); 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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();
game.resolved.clear(); 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(x_player.id).unwrap();
game.player_ready(y_player.id).unwrap(); game.player_ready(y_player.id).unwrap();
game = game.resolve_phase_start(); game = game.resolve_phase_start();

View File

@ -82,7 +82,7 @@ pub enum RpcRequest {
GameState { id: Uuid }, GameState { id: Uuid },
GameReady { id: Uuid }, GameReady { id: Uuid },
GameSkill { game_id: Uuid, construct_id: Uuid, target_construct_id: Option<Uuid>, skill: Skill }, GameSkill { game_id: Uuid, construct_id: Uuid, target_construct_id: Uuid, skill: Skill },
GameSkillClear { game_id: Uuid }, GameSkillClear { game_id: Uuid },
AccountState {}, AccountState {},

View File

@ -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 { pub fn defensive(&self) -> bool {
let mut rng = thread_rng(); let mut rng = thread_rng();