bash is back
This commit is contained in:
parent
9b5261c95a
commit
7c486812f4
@ -54,7 +54,7 @@ pub struct Game {
|
||||
pub players: Vec<Player>,
|
||||
pub phase: Phase,
|
||||
pub stack: Vec<Cast>,
|
||||
pub resolutions: Vec<Vec<Event>>,
|
||||
pub events: Vec<Vec<Event>>,
|
||||
pub instance: Option<Uuid>,
|
||||
time_control: TimeControl,
|
||||
phase_start: DateTime<Utc>,
|
||||
@ -70,7 +70,7 @@ impl Game {
|
||||
players: vec![],
|
||||
phase: Phase::Start,
|
||||
stack: vec![],
|
||||
resolutions: vec![],
|
||||
events: vec![],
|
||||
instance: None,
|
||||
time_control: TimeControl::Standard,
|
||||
phase_end: None,
|
||||
@ -189,6 +189,8 @@ impl Game {
|
||||
}
|
||||
|
||||
fn skill_phase_start(mut self, resolution_animation_ms: i64) -> Game {
|
||||
self.events.push(vec![]);
|
||||
|
||||
self.phase_start = Utc::now()
|
||||
.checked_add_signed(Duration::milliseconds(resolution_animation_ms))
|
||||
.expect("could not set phase start");
|
||||
@ -415,7 +417,6 @@ impl Game {
|
||||
panic!("game not in skill phase");
|
||||
}
|
||||
self.phase = Phase::Resolve;
|
||||
self.resolutions.push(vec![]);
|
||||
// self.log.push("<Resolve Phase>".to_string());
|
||||
|
||||
self.resolve_stack()
|
||||
@ -467,10 +468,10 @@ impl Game {
|
||||
// info!("{:} casts ", cast);
|
||||
|
||||
resolve(&mut self, cast);
|
||||
// r_animation_ms = resolutions.iter().fold(r_animation_ms, |acc, r| acc + r.clone().get_delay());
|
||||
// r_animation_ms = events.iter().fold(r_animation_ms, |acc, r| acc + r.clone().get_delay());
|
||||
|
||||
// if theres no resolution resolutions, the skill didn't trigger (disable etc)
|
||||
// if resolutions.len() > 0 && cast.used_cooldown() {
|
||||
// if theres no resolution events, the skill didn't trigger (disable etc)
|
||||
// if events.len() > 0 && cast.used_cooldown() {
|
||||
// casters.push(cast);
|
||||
// }
|
||||
|
||||
@ -490,8 +491,8 @@ impl Game {
|
||||
self.skill_phase_start(r_animation_ms)
|
||||
}
|
||||
|
||||
fn resolution_add(&mut self, mut resolutions: Vec<Event>) -> &mut Game {
|
||||
self.resolutions.last_mut().unwrap().append(&mut resolutions);
|
||||
fn resolution_add(&mut self, mut events: Vec<Event>) -> &mut Game {
|
||||
self.events.last_mut().unwrap().append(&mut events);
|
||||
self
|
||||
}
|
||||
|
||||
@ -508,27 +509,27 @@ impl Game {
|
||||
}
|
||||
|
||||
fn damage(&mut self, construct: Uuid, values: Vec<Value>, colour: Colour) -> &mut Game {
|
||||
let resolutions = match colour {
|
||||
let events = match colour {
|
||||
_ => self.construct_by_id(construct).unwrap().deal_red_damage(128) // fixme unwrap
|
||||
};
|
||||
|
||||
self.resolution_add(resolutions);
|
||||
self.resolution_add(events);
|
||||
self
|
||||
}
|
||||
|
||||
fn effect(&mut self, construct: Uuid, effect: ConstructEffect) -> &mut Game {
|
||||
let resolutions = self.construct_by_id(construct).unwrap().add_effect(effect);
|
||||
self.resolution_add(resolutions);
|
||||
let events = self.construct_by_id(construct).unwrap().add_effect(effect);
|
||||
self.resolution_add(events);
|
||||
self
|
||||
}
|
||||
|
||||
fn increase_cooldowns(&mut self, construct: Uuid, turns: usize) -> &mut Game {
|
||||
let resolutions = self.construct_by_id(construct).unwrap().increase_cooldowns(turns);
|
||||
self.resolution_add(resolutions);
|
||||
let events = self.construct_by_id(construct).unwrap().increase_cooldowns(turns);
|
||||
self.resolution_add(events);
|
||||
self
|
||||
}
|
||||
|
||||
fn progress_durations(&mut self, resolutions: &Vec<Cast>) -> &mut Game {
|
||||
fn progress_durations(&mut self, events: &Vec<Cast>) -> &mut Game {
|
||||
for mut construct in self.all_constructs() {
|
||||
// info!("progressing durations for {:}", construct.name);
|
||||
|
||||
@ -536,7 +537,7 @@ impl Game {
|
||||
continue;
|
||||
}
|
||||
|
||||
match resolutions.iter().find(|s| s.source == construct.id) {
|
||||
match events.iter().find(|s| s.source == construct.id) {
|
||||
Some(skill) => { construct.skill_set_cd(skill.skill); },
|
||||
None => { construct.reduce_cooldowns(); },
|
||||
};
|
||||
@ -662,7 +663,7 @@ impl Game {
|
||||
// player.forfeit();
|
||||
// info!("upkeep: {:} forfeited", player.name);
|
||||
// //todo
|
||||
// // self.resolutions.push(forfeit)
|
||||
// // self.events.push(forfeit)
|
||||
// // self.log.push(format!("{:} forfeited.", player.name));
|
||||
// }
|
||||
}
|
||||
@ -1047,13 +1048,13 @@ mod tests {
|
||||
// // game = game.resolve_phase_start();
|
||||
// // assert!(game.construct_by_id(x_construct.id).unwrap().affected(Effect::Link));
|
||||
|
||||
// // let Event { source: _, target: _, event, stages: _ } = game.resolutions.last.unwrap().pop().unwrap();
|
||||
// // let Event { source: _, target: _, event, stages: _ } = game.events.last.unwrap().pop().unwrap();
|
||||
// // match event {
|
||||
// // Event::Effect { effect, skill: _, duration: _, construct_effects: _ } => assert_eq!(effect, Effect::Link),
|
||||
// // _ => panic!("not siphon"),
|
||||
// // };
|
||||
|
||||
// // let Event { source: _, target: _, event, stages: _ } = game.resolutions.last.unwrap().pop().unwrap();
|
||||
// // let Event { source: _, target: _, event, stages: _ } = game.events.last.unwrap().pop().unwrap();
|
||||
// // match event {
|
||||
// // Event::Recharge { red: _, blue: _, skill: _ } => (),
|
||||
// // _ => panic!("link result was not recharge"),
|
||||
@ -1065,7 +1066,7 @@ mod tests {
|
||||
// // game.player_ready(y_player.id).unwrap();
|
||||
// // game = game.resolve_phase_start();
|
||||
|
||||
// // let Event { source: _, target, event, stages: _ } = game.resolutions.last.unwrap().pop().unwrap();
|
||||
// // let Event { source: _, target, event, stages: _ } = game.events.last.unwrap().pop().unwrap();
|
||||
// // assert_eq!(target.id, y_construct.id);
|
||||
// // match event {
|
||||
// // Event::Damage { amount, skill: _, mitigation: _, colour: _} =>
|
||||
@ -1135,7 +1136,7 @@ mod tests {
|
||||
|
||||
// assert!(game.skill_phase_finished());
|
||||
// game = game.resolve_phase_start();
|
||||
// let ruins = game.resolutions
|
||||
// let ruins = game.events
|
||||
// .last().unwrap()
|
||||
// .into_iter()
|
||||
// .filter(|r| {
|
||||
@ -1187,8 +1188,8 @@ mod tests {
|
||||
|
||||
// game = game.resolve_phase_start();
|
||||
|
||||
// assert!(game.resolutions.len() == 4);
|
||||
// while let Some(r) = game.resolutions.last().unwrap().pop() {
|
||||
// assert!(game.events.len() == 4);
|
||||
// while let Some(r) = game.events.last().unwrap().pop() {
|
||||
// let Event { source , target, event: _, stages: _ } = r;
|
||||
// if [i_construct.id, j_construct.id].contains(&source.id) {
|
||||
// assert!(target.id == x_construct.id);
|
||||
@ -1278,13 +1279,13 @@ mod tests {
|
||||
// game = game.resolve_phase_start();
|
||||
// assert!(game.construct_by_id(y_construct.id).unwrap().affected(Effect::Decay));
|
||||
|
||||
// let Event { source: _, target: _, event, stages: _ } = game.resolutions.last().unwrap().pop().unwrap();
|
||||
// let Event { source: _, target: _, event, stages: _ } = game.events.last().unwrap().pop().unwrap();
|
||||
// match event {
|
||||
// Event::Damage { amount: _, skill, mitigation: _, colour: _ } => assert_eq!(skill, Skill::DecayTick),
|
||||
// _ => panic!("not decay"),
|
||||
// };
|
||||
|
||||
// game.resolutions.clear();
|
||||
// game.events.clear();
|
||||
|
||||
// // remove
|
||||
// game.add_skill(y_player.id, y_construct.id, y_construct.id, Skill::Purify).unwrap();
|
||||
@ -1292,7 +1293,7 @@ mod tests {
|
||||
// game.player_ready(y_player.id).unwrap();
|
||||
// game = game.resolve_phase_start();
|
||||
|
||||
// while let Some(Event { source: _, target: _, event, stages: _ }) = game.resolutions.last().unwrap().pop() {
|
||||
// while let Some(Event { source: _, target: _, event, stages: _ }) = game.events.last().unwrap().pop() {
|
||||
// match event {
|
||||
// Event::Damage { amount: _, skill: _, mitigation: _, colour: _ } =>
|
||||
// panic!("{:?} damage event", event),
|
||||
@ -1305,17 +1306,17 @@ mod tests {
|
||||
// game.player_ready(y_player.id).unwrap();
|
||||
// game = game.resolve_phase_start();
|
||||
|
||||
// game.resolutions.clear();
|
||||
// game.events.clear();
|
||||
|
||||
// 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();
|
||||
|
||||
// while let Some(Event { source: _, target: _, event, stages: _ }) = game.resolutions.last().unwrap().pop() {
|
||||
// while let Some(Event { source: _, target: _, event, stages: _ }) = game.events.last().unwrap().pop() {
|
||||
// match event {
|
||||
// Event::Damage { amount: _, skill: _, mitigation: _, colour: _ } =>
|
||||
// panic!("{:#?} {:#?} damage event", game.resolutions, event),
|
||||
// panic!("{:#?} {:#?} damage event", game.events, event),
|
||||
// _ => (),
|
||||
// }
|
||||
// };
|
||||
@ -1352,6 +1353,6 @@ mod tests {
|
||||
|
||||
game.actions(Cast::new(source, player_id, target, Skill::Bash).actions());
|
||||
|
||||
println!("{:?}", game);
|
||||
println!("{:?}", game.events);
|
||||
}
|
||||
}
|
||||
|
||||
@ -156,7 +156,9 @@ impl Cast {
|
||||
}
|
||||
],
|
||||
|
||||
Skill::Bash => vec![
|
||||
Skill::Bash |
|
||||
Skill::BashPlus |
|
||||
Skill::BashPlusPlus => vec![
|
||||
Action::Damage {
|
||||
construct: self.target,
|
||||
colour: Colour::Red,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user