self targeting client

This commit is contained in:
ntr
2018-10-30 20:20:08 +11:00
parent b5191e5306
commit 09b6f455d3
5 changed files with 25 additions and 12 deletions
+1
View File
@@ -288,6 +288,7 @@ pub fn cryp_spawn(params: CrypSpawnParams, tx: &mut Transaction, account: &Accou
.named(&params.name)
.level(10)
.learn(Skill::Stun)
.learn(Skill::Block)
.set_account(account.id)
.create();
+8
View File
@@ -273,6 +273,10 @@ impl Game {
// targets can only be added by the owner of the team
fn add_target(&mut self, team_id: Uuid, cryp_id: Uuid, skill_id: Uuid) -> Result<&mut Cast, Error> {
if self.phase != Phase::Target {
return Err(err_msg("game not in target phase"));
}
{
// whose team is this?
let team = self.team_by_id(team_id);
@@ -414,6 +418,10 @@ pub fn game_skill(params: GameSkillParams, tx: &mut Transaction, account: &Accou
let game_bytes: Vec<u8> = returned.get("data");
let mut game = from_slice::<Game>(&game_bytes)?;
if game.phase != Phase::Skill {
return Err(err_msg("game not in skill phase"))
}
game.add_skill(account.id, params.cryp_id, params.target_team_id, params.skill)?;
if game.skill_phase_finished() {