remove logs
This commit is contained in:
parent
a321805f54
commit
7b0fa9ca6c
@ -589,7 +589,7 @@ impl Construct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if self.is_ko() {
|
if self.is_ko() {
|
||||||
events.push(Event::Ko { skill });
|
events.push(Event::Ko ());
|
||||||
self.effects.clear();
|
self.effects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -667,7 +667,7 @@ impl Construct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if self.is_ko() {
|
if self.is_ko() {
|
||||||
events.push(Event::Ko { skill });
|
events.push(Event::Ko ());
|
||||||
self.effects.clear();
|
self.effects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -742,7 +742,7 @@ impl Construct {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if self.is_ko() {
|
if self.is_ko() {
|
||||||
events.push(Event::Ko { skill });
|
events.push(Event::Ko ());
|
||||||
self.effects.clear();
|
self.effects.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,6 @@ pub struct Game {
|
|||||||
pub phase: Phase,
|
pub phase: Phase,
|
||||||
pub stack: Vec<Cast>,
|
pub stack: Vec<Cast>,
|
||||||
pub resolved: Vec<Resolution>,
|
pub resolved: Vec<Resolution>,
|
||||||
pub log: Vec<String>,
|
|
||||||
pub instance: Option<Uuid>,
|
pub instance: Option<Uuid>,
|
||||||
phase_end: DateTime<Utc>,
|
phase_end: DateTime<Utc>,
|
||||||
phase_start: DateTime<Utc>,
|
phase_start: DateTime<Utc>,
|
||||||
@ -51,7 +50,6 @@ impl Game {
|
|||||||
phase: Phase::Start,
|
phase: Phase::Start,
|
||||||
stack: vec![],
|
stack: vec![],
|
||||||
resolved: vec![],
|
resolved: vec![],
|
||||||
log: vec![],
|
|
||||||
instance: None,
|
instance: None,
|
||||||
phase_end: Utc::now(),
|
phase_end: Utc::now(),
|
||||||
phase_start: Utc::now(),
|
phase_start: Utc::now(),
|
||||||
@ -84,11 +82,12 @@ impl Game {
|
|||||||
|
|
||||||
if player.constructs.iter().all(|c| c.skills.len() == 0) {
|
if player.constructs.iter().all(|c| c.skills.len() == 0) {
|
||||||
info!("WARNING: {:?} has no skills and has forfeited {:?}", player.name, self.id);
|
info!("WARNING: {:?} has no skills and has forfeited {:?}", player.name, self.id);
|
||||||
|
// self.log.push(format!("{:} has forfeited the game", player.name));
|
||||||
player.forfeit();
|
player.forfeit();
|
||||||
}
|
}
|
||||||
|
|
||||||
let player_description = player.constructs.iter().map(|c| c.name.clone()).collect::<Vec<String>>().join(", ");
|
let player_description = player.constructs.iter().map(|c| c.name.clone()).collect::<Vec<String>>().join(", ");
|
||||||
self.log.push(format!("{:} has joined the game. [{:}]", player.name, player_description));
|
// self.log.push(format!("{:} has joined the game. [{:}]", player.name, player_description));
|
||||||
|
|
||||||
player.constructs.sort_unstable_by_key(|c| c.id);
|
player.constructs.sort_unstable_by_key(|c| c.id);
|
||||||
self.players.push(player);
|
self.players.push(player);
|
||||||
@ -140,7 +139,7 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn start(mut self) -> Game {
|
pub fn start(mut self) -> Game {
|
||||||
self.log.push("Game starting...".to_string());
|
// self.log.push("Game starting...".to_string());
|
||||||
|
|
||||||
// forfeit
|
// forfeit
|
||||||
if self.finished() {
|
if self.finished() {
|
||||||
@ -179,7 +178,7 @@ impl Game {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.log.push("<Skill Phase>".to_string());
|
// self.log.push("<Skill Phase>".to_string());
|
||||||
|
|
||||||
if ![Phase::Start, Phase::Resolve].contains(&self.phase) {
|
if ![Phase::Start, Phase::Resolve].contains(&self.phase) {
|
||||||
panic!("game not in Resolve or start phase");
|
panic!("game not in Resolve or start phase");
|
||||||
@ -346,7 +345,7 @@ impl Game {
|
|||||||
assert!(self.skill_phase_finished());
|
assert!(self.skill_phase_finished());
|
||||||
|
|
||||||
self.phase = Phase::Resolve;
|
self.phase = Phase::Resolve;
|
||||||
self.log.push("<Resolve Phase>".to_string());
|
// self.log.push("<Resolve Phase>".to_string());
|
||||||
|
|
||||||
self.resolve_skills()
|
self.resolve_skills()
|
||||||
}
|
}
|
||||||
@ -421,13 +420,14 @@ impl Game {
|
|||||||
// info!("{:} casts ", cast);
|
// info!("{:} casts ", cast);
|
||||||
|
|
||||||
let mut resolutions = resolution_steps(&cast, &mut self);
|
let mut resolutions = resolution_steps(&cast, &mut self);
|
||||||
resolutions.reverse();
|
|
||||||
turn_events += resolutions.len();
|
turn_events += resolutions.len();
|
||||||
while let Some(resolution) = resolutions.pop() {
|
self.resolved.append(&mut resolutions);
|
||||||
self.log_resolution(cast.speed, &resolution);
|
|
||||||
// the results go into the resolutions
|
// while let Some(resolution) = resolutions.pop() {
|
||||||
self.resolved.push(resolution);
|
// self.log_resolution(cast.speed, &resolution);
|
||||||
}
|
// // the results go into the resolutions
|
||||||
|
// self.resolved.push(resolution);
|
||||||
|
// }
|
||||||
|
|
||||||
// the cast itself goes into this temp vec
|
// the cast itself goes into this temp vec
|
||||||
// to handle cooldowns
|
// to handle cooldowns
|
||||||
@ -479,65 +479,65 @@ impl Game {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn log_resolution(&mut self, speed: u64, resolution: &Resolution) -> &mut Game {
|
// fn log_resolution(&mut self, speed: u64, resolution: &Resolution) -> &mut Game {
|
||||||
let Resolution { source, target, event, stages: _ } = resolution;
|
// let Resolution { source, target, event, stages: _ } = resolution;
|
||||||
match event {
|
// match event {
|
||||||
Event::Ko { skill: _ }=>
|
// Event::Ko { skill: _ }=>
|
||||||
self.log.push(format!("{:} KO!", target.name)),
|
// self.log.push(format!("{:} KO!", target.name)),
|
||||||
|
|
||||||
Event::Disable { skill, disable } =>
|
// Event::Disable { skill, disable } =>
|
||||||
self.log.push(format!("{:} {:?} {:} disabled {:?}",
|
// self.log.push(format!("{:} {:?} {:} disabled {:?}",
|
||||||
source.name, skill, target.name, disable)),
|
// source.name, skill, target.name, disable)),
|
||||||
|
|
||||||
Event::Immunity { skill, immunity } =>
|
// Event::Immunity { skill, immunity } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
|
// self.log.push(format!("[{:}] {:} {:?} {:} immune {:?}",
|
||||||
speed, source.name, skill, target.name, immunity)),
|
// speed, source.name, skill, target.name, immunity)),
|
||||||
|
|
||||||
Event::TargetKo { skill } =>
|
// Event::TargetKo { skill } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} - target is KO",
|
// self.log.push(format!("[{:}] {:} {:?} {:} - target is KO",
|
||||||
speed, source.name, skill, target.name)),
|
// speed, source.name, skill, target.name)),
|
||||||
|
|
||||||
Event::Damage { skill, amount, mitigation, colour: _ } =>
|
// Event::Damage { skill, amount, mitigation, colour: _ } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:} mitigated)",
|
// self.log.push(format!("[{:}] {:} {:?} {:} {:} ({:} mitigated)",
|
||||||
speed, source.name, skill, target.name, amount, mitigation)),
|
// speed, source.name, skill, target.name, amount, mitigation)),
|
||||||
|
|
||||||
Event::Healing { skill, amount, overhealing } =>
|
// Event::Healing { skill, amount, overhealing } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:} healing ({:}OH)",
|
// self.log.push(format!("[{:}] {:} {:?} {:} {:} healing ({:}OH)",
|
||||||
speed, source.name, skill, target.name, amount, overhealing)),
|
// speed, source.name, skill, target.name, amount, overhealing)),
|
||||||
|
|
||||||
Event::Inversion { skill } =>
|
// Event::Inversion { skill } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} INVERTED",
|
// self.log.push(format!("[{:}] {:} {:?} {:} INVERTED",
|
||||||
speed, source.name, skill, target.name)),
|
// speed, source.name, skill, target.name)),
|
||||||
|
|
||||||
Event::Reflection { skill } =>
|
// Event::Reflection { skill } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} REFLECTED",
|
// self.log.push(format!("[{:}] {:} {:?} {:} REFLECTED",
|
||||||
speed, source.name, skill, target.name)),
|
// speed, source.name, skill, target.name)),
|
||||||
|
|
||||||
Event::Effect { skill, effect, duration, construct_effects: _ } =>
|
// Event::Effect { skill, effect, duration, construct_effects: _ } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
|
// self.log.push(format!("[{:}] {:} {:?} {:} {:?} {:}T",
|
||||||
speed, source.name, skill, target.name, effect, duration)),
|
// speed, source.name, skill, target.name, effect, duration)),
|
||||||
|
|
||||||
Event::Skill { skill } =>
|
// Event::Skill { skill } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:}",
|
// self.log.push(format!("[{:}] {:} {:?} {:}",
|
||||||
speed, source.name, skill, target.name)),
|
// speed, source.name, skill, target.name)),
|
||||||
|
|
||||||
Event::Removal { effect, construct_effects: _ } =>
|
// Event::Removal { effect, construct_effects: _ } =>
|
||||||
self.log.push(format!("[{:}] {:?} removed {:} {:?}",
|
// self.log.push(format!("[{:}] {:?} removed {:} {:?}",
|
||||||
speed, source.name, target.name, effect)),
|
// speed, source.name, target.name, effect)),
|
||||||
|
|
||||||
Event::Recharge { skill, red, blue } =>
|
// Event::Recharge { skill, red, blue } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} {:}R {:}B",
|
// self.log.push(format!("[{:}] {:} {:?} {:} {:}R {:}B",
|
||||||
speed, source.name, skill, target.name, red, blue)),
|
// speed, source.name, skill, target.name, red, blue)),
|
||||||
|
|
||||||
Event::Evasion { skill, evasion_rating } =>
|
// Event::Evasion { skill, evasion_rating } =>
|
||||||
self.log.push(format!("[{:}] {:} {:?} {:} evaded ({:}%)",
|
// self.log.push(format!("[{:}] {:} {:?} {:} evaded ({:}%)",
|
||||||
speed, source.name, skill, target.name, evasion_rating)),
|
// speed, source.name, skill, target.name, evasion_rating)),
|
||||||
|
|
||||||
Event::Incomplete => panic!("incomplete resolution {:?}", resolution),
|
// Event::Incomplete => panic!("incomplete resolution {:?}", resolution),
|
||||||
}
|
// }
|
||||||
|
|
||||||
self
|
// self
|
||||||
}
|
// }
|
||||||
|
|
||||||
pub fn finished(&self) -> bool {
|
pub fn finished(&self) -> bool {
|
||||||
self.players.iter().any(|t| t.constructs.iter().all(|c| c.is_ko()))
|
self.players.iter().any(|t| t.constructs.iter().all(|c| c.is_ko()))
|
||||||
@ -549,15 +549,15 @@ impl Game {
|
|||||||
|
|
||||||
fn finish(mut self) -> Game {
|
fn finish(mut self) -> Game {
|
||||||
self.phase = Phase::Finish;
|
self.phase = Phase::Finish;
|
||||||
self.log.push(format!("Game finished."));
|
// self.log.push(format!("Game finished."));
|
||||||
|
|
||||||
{
|
// {
|
||||||
let winner = self.players.iter().find(|t| t.constructs.iter().any(|c| !c.is_ko()));
|
// let winner = self.players.iter().find(|t| t.constructs.iter().any(|c| !c.is_ko()));
|
||||||
match winner {
|
// match winner {
|
||||||
Some(w) => self.log.push(format!("Winner: {:}", w.name)),
|
// Some(w) => self.log.push(format!("Winner: {:}", w.name)),
|
||||||
None => self.log.push(format!("Game was drawn.")),
|
// None => self.log.push(format!("Game was drawn.")),
|
||||||
};
|
// };
|
||||||
}
|
// }
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
@ -585,7 +585,7 @@ impl Game {
|
|||||||
if player.warnings >= 3 {
|
if player.warnings >= 3 {
|
||||||
player.forfeit();
|
player.forfeit();
|
||||||
info!("upkeep: {:} forfeited", player.name);
|
info!("upkeep: {:} forfeited", player.name);
|
||||||
self.log.push(format!("{:} forfeited.", player.name));
|
// self.log.push(format!("{:} forfeited.", player.name));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -461,7 +461,8 @@ pub enum Event {
|
|||||||
Removal { effect: Effect, construct_effects: Vec<ConstructEffect> },
|
Removal { effect: Effect, construct_effects: Vec<ConstructEffect> },
|
||||||
TargetKo { skill: Skill },
|
TargetKo { skill: Skill },
|
||||||
// skill not necessary but makes it neater as all events are arrays in js
|
// skill not necessary but makes it neater as all events are arrays in js
|
||||||
Ko { skill: Skill },
|
Ko (),
|
||||||
|
Forfeit (),
|
||||||
Incomplete,
|
Incomplete,
|
||||||
// not used
|
// not used
|
||||||
Evasion { skill: Skill, evasion_rating: u64 },
|
Evasion { skill: Skill, evasion_rating: u64 },
|
||||||
@ -1552,7 +1553,7 @@ fn strangle_tick(source: &mut Construct, target: &mut Construct, mut results: Re
|
|||||||
.for_each(|e| results.push(Resolution::new(source, target).event(e).stages(LogStages::EndPost)));
|
.for_each(|e| results.push(Resolution::new(source, target).event(e).stages(LogStages::EndPost)));
|
||||||
|
|
||||||
// remove immunity if target ko
|
// remove immunity if target ko
|
||||||
if target.is_ko() {
|
if target.is_ko() && !source.is_ko() {
|
||||||
let i = source.effects
|
let i = source.effects
|
||||||
.iter()
|
.iter()
|
||||||
.position(|e| e.effect == Effect::Strangling)
|
.position(|e| e.effect == Effect::Strangling)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user