uhh
This commit is contained in:
parent
01a5d781bb
commit
2100ad678e
@ -26,8 +26,10 @@ pub enum Phase {
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Value {
|
||||
Stat { construct: Uuid, stat: Stat, mult: usize },
|
||||
Fixed { amount: usize },
|
||||
Fixed { value: usize },
|
||||
Cooldowns { construct: Uuid, mult: usize },
|
||||
ColourSkills { construct: Uuid, colour: Colour, mult: usize },
|
||||
DamageTaken { construct: Uuid, colour: Colour, mult: usize },
|
||||
// Skills { construct: Uuid, colour: Colour },
|
||||
}
|
||||
|
||||
@ -40,12 +42,12 @@ pub enum Colour {
|
||||
|
||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Action {
|
||||
Cast { construct: Uuid, skill: Skill },
|
||||
Hit { construct: Uuid, skill: Skill },
|
||||
HitCast { construct: Uuid, skill: Skill, source: Uuid },
|
||||
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||
Healing { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||
Effect { construct: Uuid, effect: ConstructEffect },
|
||||
IncreaseCooldowns { construct: Uuid, turns: usize },
|
||||
// Recharge { skill: Skill, red: usize, blue: usize },
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
@ -191,7 +193,9 @@ impl Game {
|
||||
}
|
||||
|
||||
fn skill_phase_start(mut self, resolution_animation_ms: i64) -> Game {
|
||||
self.phase_start = Utc::now()
|
||||
self.events.push(vec![]);
|
||||
|
||||
self.phase_start = Utc::now()
|
||||
.checked_add_signed(Duration::milliseconds(resolution_animation_ms))
|
||||
.expect("could not set phase start");
|
||||
|
||||
@ -413,8 +417,6 @@ impl Game {
|
||||
}
|
||||
|
||||
pub fn resolve_phase_start(mut self) -> Game {
|
||||
self.events.push(vec![]);
|
||||
|
||||
if self.phase != Phase::Skill {
|
||||
panic!("game not in skill phase");
|
||||
}
|
||||
@ -493,54 +495,49 @@ impl Game {
|
||||
self.skill_phase_start(r_animation_ms)
|
||||
}
|
||||
|
||||
fn event_add(&mut self, mut events: Vec<Event>) -> &mut Game {
|
||||
self.events.last_mut().unwrap().append(&mut events);
|
||||
self
|
||||
}
|
||||
|
||||
pub fn actions(&mut self, actions: Vec<Action>) -> &mut Game {
|
||||
let mut events_group = vec![];
|
||||
|
||||
// calculate values first?
|
||||
// for result damage value need to pass &events and .find()
|
||||
|
||||
for action in actions {
|
||||
match action {
|
||||
let mut events = match action {
|
||||
Action::Cast { construct, skill } => self.cast(construct, skill),
|
||||
Action::Hit { construct, skill } => self.hit(construct, skill),
|
||||
Action::HitCast { construct, skill, source } => self.hit_cast(construct, skill, source),
|
||||
Action::Damage { construct, values, colour } => self.damage(construct, values, colour),
|
||||
Action::Healing { construct, values, colour } => unimplemented!(),
|
||||
Action::Effect { construct, effect } => self.effect(construct, effect),
|
||||
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
||||
};
|
||||
|
||||
events_group.append(&mut events);
|
||||
}
|
||||
|
||||
self.events.last_mut().unwrap().append(&mut events_group);
|
||||
self
|
||||
}
|
||||
|
||||
fn hit_cast(&mut self, construct: Uuid, skill: Skill, source: Uuid) -> &mut Game {
|
||||
self.event_add(vec![Event::new(EventVariant::HitCast { skill: skill, source: source }, construct)]);
|
||||
self
|
||||
fn cast(&mut self, construct: Uuid, skill: Skill) -> Vec<Event> {
|
||||
vec![Event::new(EventVariant::Cast { skill: skill }, construct)]
|
||||
}
|
||||
|
||||
fn hit(&mut self, construct: Uuid, skill: Skill) -> &mut Game {
|
||||
self.event_add(vec![Event::new(EventVariant::Hit { skill: skill }, construct)]);
|
||||
self
|
||||
fn hit(&mut self, construct: Uuid, skill: Skill) -> Vec<Event> {
|
||||
vec![Event::new(EventVariant::Hit { skill: skill }, construct)]
|
||||
}
|
||||
|
||||
fn damage(&mut self, construct: Uuid, values: Vec<Value>, colour: Colour) -> &mut Game {
|
||||
let events = match colour {
|
||||
fn damage(&mut self, construct: Uuid, values: Vec<Value>, colour: Colour) -> Vec<Event> {
|
||||
match colour {
|
||||
_ => self.construct_by_id(construct).unwrap().deal_red_damage(128) // fixme unwrap
|
||||
};
|
||||
|
||||
self.event_add(events);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
fn effect(&mut self, construct: Uuid, effect: ConstructEffect) -> &mut Game {
|
||||
let events = self.construct_by_id(construct).unwrap().add_effect(effect);
|
||||
self.event_add(events);
|
||||
self
|
||||
fn effect(&mut self, construct: Uuid, effect: ConstructEffect) -> Vec<Event> {
|
||||
self.construct_by_id(construct).unwrap().add_effect(effect)
|
||||
}
|
||||
|
||||
fn increase_cooldowns(&mut self, construct: Uuid, turns: usize) -> &mut Game {
|
||||
let events = self.construct_by_id(construct).unwrap().increase_cooldowns(turns);
|
||||
self.event_add(events);
|
||||
self
|
||||
fn increase_cooldowns(&mut self, construct: Uuid, turns: usize) -> Vec<Event> {
|
||||
self.construct_by_id(construct).unwrap().increase_cooldowns(turns)
|
||||
}
|
||||
|
||||
fn progress_durations(&mut self, events: &Vec<Cast>) -> &mut Game {
|
||||
|
||||
1541
core/src/skill.rs
1541
core/src/skill.rs
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user