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