uhh
This commit is contained in:
parent
01a5d781bb
commit
2100ad678e
@ -26,8 +26,10 @@ pub enum Phase {
|
|||||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum Value {
|
pub enum Value {
|
||||||
Stat { construct: Uuid, stat: Stat, mult: usize },
|
Stat { construct: Uuid, stat: Stat, mult: usize },
|
||||||
Fixed { amount: usize },
|
Fixed { value: usize },
|
||||||
Cooldowns { construct: Uuid, mult: 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 },
|
// Skills { construct: Uuid, colour: Colour },
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,12 +42,12 @@ pub enum Colour {
|
|||||||
|
|
||||||
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum Action {
|
pub enum Action {
|
||||||
|
Cast { construct: Uuid, skill: Skill },
|
||||||
Hit { construct: Uuid, skill: Skill },
|
Hit { construct: Uuid, skill: Skill },
|
||||||
HitCast { construct: Uuid, skill: Skill, source: Uuid },
|
|
||||||
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
Damage { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||||
|
Healing { construct: Uuid, values: Vec<Value>, colour: Colour },
|
||||||
Effect { construct: Uuid, effect: ConstructEffect },
|
Effect { construct: Uuid, effect: ConstructEffect },
|
||||||
IncreaseCooldowns { construct: Uuid, turns: usize },
|
IncreaseCooldowns { construct: Uuid, turns: usize },
|
||||||
// Recharge { skill: Skill, red: usize, blue: usize },
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||||
@ -191,6 +193,8 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn skill_phase_start(mut self, resolution_animation_ms: i64) -> Game {
|
fn skill_phase_start(mut self, resolution_animation_ms: i64) -> Game {
|
||||||
|
self.events.push(vec![]);
|
||||||
|
|
||||||
self.phase_start = Utc::now()
|
self.phase_start = Utc::now()
|
||||||
.checked_add_signed(Duration::milliseconds(resolution_animation_ms))
|
.checked_add_signed(Duration::milliseconds(resolution_animation_ms))
|
||||||
.expect("could not set phase start");
|
.expect("could not set phase start");
|
||||||
@ -413,8 +417,6 @@ impl Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn resolve_phase_start(mut self) -> Game {
|
pub fn resolve_phase_start(mut self) -> Game {
|
||||||
self.events.push(vec![]);
|
|
||||||
|
|
||||||
if self.phase != Phase::Skill {
|
if self.phase != Phase::Skill {
|
||||||
panic!("game not in skill phase");
|
panic!("game not in skill phase");
|
||||||
}
|
}
|
||||||
@ -493,54 +495,49 @@ impl Game {
|
|||||||
self.skill_phase_start(r_animation_ms)
|
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 {
|
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 {
|
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::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::Damage { construct, values, colour } => self.damage(construct, values, colour),
|
||||||
|
Action::Healing { construct, values, colour } => unimplemented!(),
|
||||||
Action::Effect { construct, effect } => self.effect(construct, effect),
|
Action::Effect { construct, effect } => self.effect(construct, effect),
|
||||||
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
Action::IncreaseCooldowns { construct, turns } => self.increase_cooldowns(construct, turns),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
events_group.append(&mut events);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self.events.last_mut().unwrap().append(&mut events_group);
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hit_cast(&mut self, construct: Uuid, skill: Skill, source: Uuid) -> &mut Game {
|
fn cast(&mut self, construct: Uuid, skill: Skill) -> Vec<Event> {
|
||||||
self.event_add(vec![Event::new(EventVariant::HitCast { skill: skill, source: source }, construct)]);
|
vec![Event::new(EventVariant::Cast { skill: skill }, construct)]
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn hit(&mut self, construct: Uuid, skill: Skill) -> &mut Game {
|
fn hit(&mut self, construct: Uuid, skill: Skill) -> Vec<Event> {
|
||||||
self.event_add(vec![Event::new(EventVariant::Hit { skill: skill }, construct)]);
|
vec![Event::new(EventVariant::Hit { skill: skill }, construct)]
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn damage(&mut self, construct: Uuid, values: Vec<Value>, colour: Colour) -> &mut Game {
|
fn damage(&mut self, construct: Uuid, values: Vec<Value>, colour: Colour) -> Vec<Event> {
|
||||||
let events = match colour {
|
match colour {
|
||||||
_ => self.construct_by_id(construct).unwrap().deal_red_damage(128) // fixme unwrap
|
_ => 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 {
|
fn effect(&mut self, construct: Uuid, effect: ConstructEffect) -> Vec<Event> {
|
||||||
let events = self.construct_by_id(construct).unwrap().add_effect(effect);
|
self.construct_by_id(construct).unwrap().add_effect(effect)
|
||||||
self.event_add(events);
|
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn increase_cooldowns(&mut self, construct: Uuid, turns: usize) -> &mut Game {
|
fn increase_cooldowns(&mut self, construct: Uuid, turns: usize) -> Vec<Event> {
|
||||||
let events = self.construct_by_id(construct).unwrap().increase_cooldowns(turns);
|
self.construct_by_id(construct).unwrap().increase_cooldowns(turns)
|
||||||
self.event_add(events);
|
|
||||||
self
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn progress_durations(&mut self, events: &Vec<Cast>) -> &mut Game {
|
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