remove unused fns
This commit is contained in:
parent
b2dd063382
commit
433b20fdb5
@ -37,13 +37,6 @@ impl Team {
|
||||
self
|
||||
}
|
||||
|
||||
fn update_cryp(&mut self, updated: Cryp) -> &mut Team {
|
||||
let index = self.cryps.iter().position(|c| c.id == updated.id).unwrap();
|
||||
self.cryps.remove(index);
|
||||
self.cryps.push(updated);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn cryp_by_id(&mut self, id: Uuid) -> Option<&mut Cryp> {
|
||||
self.cryps.iter_mut().find(|c| c.id == id)
|
||||
}
|
||||
@ -119,25 +112,13 @@ impl Game {
|
||||
}
|
||||
}
|
||||
|
||||
fn cryp_by_id(&mut self, id: Uuid) -> &mut Cryp {
|
||||
for team in self.teams.iter_mut() {
|
||||
let in_team = team.cryp_by_id(id);
|
||||
if in_team.is_some() {
|
||||
return in_team.unwrap();
|
||||
}
|
||||
}
|
||||
panic!("cryp not in game");
|
||||
}
|
||||
|
||||
fn update_team(&mut self, updated: &mut Team) -> &mut Game {
|
||||
match self.teams.iter().position(|t| t.id == updated.id) {
|
||||
Some(index) => {
|
||||
self.teams.remove(index);
|
||||
self.teams.push(updated.clone());
|
||||
self
|
||||
}
|
||||
None => panic!("team not in game"),
|
||||
}
|
||||
fn cryp_by_id(&mut self, id: Uuid) -> Option<&mut Cryp> {
|
||||
match self.teams.iter_mut().find(|t| t.cryps.iter().any(|c| c.id == id)) {
|
||||
Some(team) => {
|
||||
return team.cryps.iter_mut().find(|c| c.id == id);
|
||||
},
|
||||
None => panic!("cryp not in game"),
|
||||
};
|
||||
}
|
||||
|
||||
fn update_cryp(&mut self, cryp: &mut Cryp) -> &mut Game {
|
||||
@ -202,8 +183,7 @@ impl Game {
|
||||
}
|
||||
|
||||
{
|
||||
let team = self.team_by_id(team_id);
|
||||
let cryp = match team.cryp_by_id(source_cryp_id) {
|
||||
let cryp = match self.cryp_by_id(source_cryp_id) {
|
||||
Some(c) => c,
|
||||
None => return Err(err_msg("cryp not in team")),
|
||||
};
|
||||
@ -331,8 +311,8 @@ impl Game {
|
||||
}
|
||||
|
||||
for skill in self.skills.clone().iter_mut() {
|
||||
let mut source = self.cryp_by_id(skill.source_cryp_id).clone();
|
||||
let mut target = self.cryp_by_id(skill.target_cryp_id.unwrap()).clone();
|
||||
let mut source = self.cryp_by_id(skill.source_cryp_id).unwrap().clone();
|
||||
let mut target = self.cryp_by_id(skill.target_cryp_id.unwrap()).unwrap().clone();
|
||||
let resolution = skill.resolve(&mut source, &mut target);
|
||||
|
||||
self.update_cryp(&mut source);
|
||||
@ -349,7 +329,7 @@ impl Game {
|
||||
fn progress_cooldowns(&mut self) -> &mut Game {
|
||||
for skill in self.skills.clone().iter() {
|
||||
// copy the creep cause we will replace it
|
||||
let mut cryp = self.cryp_by_id(skill.source_cryp_id).clone();
|
||||
let mut cryp = self.cryp_by_id(skill.source_cryp_id).unwrap().clone();
|
||||
|
||||
if skill.used_cooldown() {
|
||||
cryp.skill_set_cd(skill.skill);
|
||||
@ -430,7 +410,7 @@ pub fn game_target(params: GameTargetParams, tx: &mut Transaction, account: &Acc
|
||||
let game_bytes: Vec<u8> = returned.get("data");
|
||||
let mut game = from_slice::<Game>(&game_bytes)?;
|
||||
|
||||
game.add_target(account.id, params.cryp_id, params.cast_id)?;
|
||||
game.add_target(account.id, params.cryp_id, params.skill_id)?;
|
||||
|
||||
if game.target_phase_finished() {
|
||||
game.damage_phase_start();
|
||||
|
||||
@ -355,7 +355,7 @@ struct GameTargetMsg {
|
||||
pub struct GameTargetParams {
|
||||
pub game_id: Uuid,
|
||||
pub cryp_id: Uuid,
|
||||
pub cast_id: Uuid,
|
||||
pub skill_id: Uuid,
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user