break stuff

This commit is contained in:
ntr 2019-12-03 10:21:22 +10:00
parent 5446ee19ae
commit 8cb335fcc7
10 changed files with 1906 additions and 1840 deletions

4
core/fixme.md Normal file
View File

@ -0,0 +1,4 @@
# FIXME
aoe event
cooldown checking -> go through round and find all casters

View File

@ -4,8 +4,9 @@ use rand::prelude::*;
use failure::Error; use failure::Error;
use failure::err_msg; use failure::err_msg;
use skill::{Skill, Cast, Immunity, Disable, Event}; use skill::{Skill, Cast, Immunity, Disable, EventVariant};
use effect::{Cooldown, Effect, Colour}; use game::{Colour};
use effect::{Cooldown, Effect};
use spec::{Spec}; use spec::{Spec};
use item::{Item}; use item::{Item};
@ -60,10 +61,10 @@ impl ConstructSkill {
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub enum EffectMeta { pub enum EffectMeta {
Skill(Skill), Skill(Skill),
TickAmount(u64), TickAmount(usize),
AddedDamage(u64), AddedDamage(usize),
LinkTarget(Uuid), LinkTarget(Uuid),
Multiplier(u64), Multiplier(usize),
} }
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
@ -93,7 +94,7 @@ impl ConstructEffect {
self.duration self.duration
} }
pub fn get_multiplier(&self) -> u64 { pub fn get_multiplier(&self) -> usize {
match self.meta { match self.meta {
Some(EffectMeta::Multiplier(s)) => s, Some(EffectMeta::Multiplier(s)) => s,
_ => 0 _ => 0
@ -129,14 +130,14 @@ pub enum Stat {
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)] #[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub struct ConstructStat { pub struct ConstructStat {
base: u64, base: usize,
value: u64, value: usize,
max: u64, max: usize,
pub stat: Stat, pub stat: Stat,
} }
impl ConstructStat { impl ConstructStat {
// pub fn set(&mut self, v: u64, specs: &Vec<Spec>) -> &mut ConstructStat { // pub fn set(&mut self, v: usize, specs: &Vec<Spec>) -> &mut ConstructStat {
// self.base = v; // self.base = v;
// self.recalculate(specs) // self.recalculate(specs)
// } // }
@ -157,12 +158,12 @@ impl ConstructStat {
self self
} }
pub fn reduce(&mut self, amt: u64) -> &mut ConstructStat { pub fn reduce(&mut self, amt: usize) -> &mut ConstructStat {
self.value = self.value.saturating_sub(amt); self.value = self.value.saturating_sub(amt);
self self
} }
pub fn increase(&mut self, amt: u64) -> &mut ConstructStat { pub fn increase(&mut self, amt: usize) -> &mut ConstructStat {
self.value = *[ self.value = *[
self.value.saturating_add(amt), self.value.saturating_add(amt),
self.max self.max
@ -171,7 +172,7 @@ impl ConstructStat {
self self
} }
pub fn force(&mut self, v: u64) -> &mut ConstructStat { pub fn force(&mut self, v: usize) -> &mut ConstructStat {
self.base = v; self.base = v;
self.value = v; self.value = v;
self.max = v; self.max = v;
@ -470,7 +471,7 @@ impl Construct {
} }
// Stats // Stats
pub fn red_power(&self) -> u64 { pub fn red_power(&self) -> usize {
let red_power_mods = self.effects.iter() let red_power_mods = self.effects.iter()
.filter(|e| e.effect.modifications().contains(&Stat::RedPower)) .filter(|e| e.effect.modifications().contains(&Stat::RedPower))
.map(|e| (e.effect, e.meta)) .map(|e| (e.effect, e.meta))
@ -481,7 +482,7 @@ impl Construct {
return modified_red_power; return modified_red_power;
} }
pub fn blue_power(&self) -> u64 { pub fn blue_power(&self) -> usize {
let blue_power_mods = self.effects.iter() let blue_power_mods = self.effects.iter()
.filter(|e| e.effect.modifications().contains(&Stat::BluePower)) .filter(|e| e.effect.modifications().contains(&Stat::BluePower))
.map(|e| (e.effect, e.meta)) .map(|e| (e.effect, e.meta))
@ -492,7 +493,7 @@ impl Construct {
return modified_blue_power; return modified_blue_power;
} }
pub fn green_power(&self) -> u64 { pub fn green_power(&self) -> usize {
let green_power_mods = self.effects.iter() let green_power_mods = self.effects.iter()
.filter(|e| e.effect.modifications().contains(&Stat::GreenPower)) .filter(|e| e.effect.modifications().contains(&Stat::GreenPower))
.map(|e| (e.effect, e.meta)) .map(|e| (e.effect, e.meta))
@ -503,8 +504,8 @@ impl Construct {
return modified_green_power; return modified_green_power;
} }
pub fn skill_speed(&self, s: Skill) -> u64 { pub fn skill_speed(&self, s: Skill) -> usize {
self.speed().saturating_mul(s.speed() as u64) self.speed().saturating_mul(s.speed() as usize)
} }
// todo complete with specs // todo complete with specs
@ -512,7 +513,7 @@ impl Construct {
s.aoe() s.aoe()
} }
pub fn speed(&self) -> u64 { pub fn speed(&self) -> usize {
let speed_mods = self.effects.iter() let speed_mods = self.effects.iter()
.filter(|e| e.effect.modifications().contains(&Stat::Speed)) .filter(|e| e.effect.modifications().contains(&Stat::Speed))
.map(|e| (e.effect, e.meta)) .map(|e| (e.effect, e.meta))
@ -523,32 +524,32 @@ impl Construct {
return modified_speed; return modified_speed;
} }
pub fn red_life(&self) -> u64 { pub fn red_life(&self) -> usize {
self.red_life.value self.red_life.value
} }
pub fn blue_life(&self) -> u64 { pub fn blue_life(&self) -> usize {
self.blue_life.value self.blue_life.value
} }
pub fn green_life(&self) -> u64 { pub fn green_life(&self) -> usize {
self.green_life.value self.green_life.value
} }
fn reduce_green_life(&mut self, amount: u64) { fn reduce_green_life(&mut self, amount: usize) {
self.green_life.reduce(amount); self.green_life.reduce(amount);
if self.affected(Effect::Sustain) && self.green_life() == 0 { if self.affected(Effect::Sustain) && self.green_life() == 0 {
self.green_life.value = 1; self.green_life.value = 1;
} }
} }
pub fn recharge(&mut self, skill: Skill, red_amount: u64, blue_amount: u64) -> Vec<Event> { pub fn recharge(&mut self, skill: Skill, red_amount: usize, blue_amount: usize) -> Vec<Event> {
let mut events = vec![]; let mut events = vec![];
// Should red type immunity block recharge??? // Should red type immunity block recharge???
if let Some(immunity) = self.immune(skill) { if let Some(immunity) = self.immune(skill) {
if !self.is_ko() { if !self.is_ko() {
events.push(Event::Immunity { skill, immunity }); events.push(EventVariant::Immunity { skill, immunity });
} }
return events; return events;
} }
@ -567,7 +568,7 @@ impl Construct {
let blue = new_blue_life - current_blue_life; let blue = new_blue_life - current_blue_life;
if red != 0 || blue != 0 { if red != 0 || blue != 0 {
events.push(Event::Recharge { red, blue, skill }); events.push(EventVariant::Recharge { red, blue, skill });
} }
}, },
true => { true => {
@ -593,7 +594,7 @@ impl Construct {
self.reduce_green_life(red_remainder); self.reduce_green_life(red_remainder);
let red_damage_amount = red_current_green_life - self.green_life(); let red_damage_amount = red_current_green_life - self.green_life();
events.push(Event::Damage { events.push(EventVariant::Damage {
skill, skill,
amount: red_damage_amount, amount: red_damage_amount,
mitigation: red_mitigation, mitigation: red_mitigation,
@ -622,7 +623,7 @@ impl Construct {
self.reduce_green_life(blue_remainder); self.reduce_green_life(blue_remainder);
let blue_damage_amount = blue_current_green_life - self.green_life(); let blue_damage_amount = blue_current_green_life - self.green_life();
events.push(Event::Damage { events.push(EventVariant::Damage {
skill, skill,
amount: blue_damage_amount, amount: blue_damage_amount,
mitigation: blue_mitigation, mitigation: blue_mitigation,
@ -634,11 +635,11 @@ impl Construct {
return events; return events;
} }
pub fn deal_green_damage(&mut self, skill: Skill, amount: u64) -> Vec<Event> { pub fn deal_green_damage(&mut self, skill: Skill, amount: usize) -> Vec<Event> {
let mut events = vec![]; let mut events = vec![];
if let Some(immunity) = self.immune(skill) { if let Some(immunity) = self.immune(skill) {
if !self.is_ko() { if !self.is_ko() {
events.push(Event::Immunity { skill, immunity }); events.push(EventVariant::Immunity { skill, immunity });
} }
return events; return events;
} }
@ -660,21 +661,21 @@ impl Construct {
let healing = new_green_life - current_green_life; let healing = new_green_life - current_green_life;
let overhealing = modified_power - healing; let overhealing = modified_power - healing;
events.push(Event::Healing { events.push(EventVariant::Healing {
skill, skill,
amount: healing, amount: healing,
overhealing, overhealing,
}); });
}, },
true => { true => {
// events.push(Event::Inversion { skill }); // events.push(EventVariant::Inversion { skill });
// there is no green shield (yet) // there is no green shield (yet)
let current_green_life = self.green_life(); let current_green_life = self.green_life();
self.reduce_green_life(modified_power); self.reduce_green_life(modified_power);
let delta = current_green_life - self.green_life(); let delta = current_green_life - self.green_life();
events.push(Event::Damage { events.push(EventVariant::Damage {
skill, skill,
amount: delta, amount: delta,
mitigation: 0, mitigation: 0,
@ -686,12 +687,12 @@ impl Construct {
return events; return events;
} }
pub fn deal_red_damage(&mut self, skill: Skill, amount: u64) -> Vec<Event> { pub fn deal_red_damage(&mut self, skill: Skill, amount: usize) -> Vec<Resolution> {
let mut events = vec![]; let mut events = vec![];
if let Some(immunity) = self.immune(skill) { if let Some(immunity) = self.immune(skill) {
if !self.is_ko() { if !self.is_ko() {
events.push(Event::Immunity { skill, immunity }); events.push(EventVariant::Immunity { skill, immunity });
} }
return events; return events;
} }
@ -721,7 +722,7 @@ impl Construct {
self.reduce_green_life(remainder); self.reduce_green_life(remainder);
let delta = current_green_life - self.green_life(); let delta = current_green_life - self.green_life();
events.push(Event::Damage { events.push(EventVariant::Damage {
skill, skill,
amount: delta, amount: delta,
mitigation, mitigation,
@ -729,7 +730,7 @@ impl Construct {
}); });
}, },
true => { true => {
// events.push(Event::Inversion { skill }); // events.push(EventVariant::Inversion { skill });
let current_green_life = self.green_life(); let current_green_life = self.green_life();
self.green_life.increase(modified_power); self.green_life.increase(modified_power);
@ -742,7 +743,7 @@ impl Construct {
let recharge = self.red_life.value - current_life; let recharge = self.red_life.value - current_life;
if healing > 0 { if healing > 0 {
events.push(Event::Healing { events.push(EventVariant::Healing {
skill, skill,
amount: healing, amount: healing,
overhealing: overhealing - recharge, overhealing: overhealing - recharge,
@ -750,7 +751,7 @@ impl Construct {
} }
if recharge > 0 { if recharge > 0 {
events.push(Event::Recharge { red: recharge, blue: 0, skill }); events.push(EventVariant::Recharge { red: recharge, blue: 0, skill });
} }
} }
}; };
@ -758,12 +759,12 @@ impl Construct {
return events; return events;
} }
pub fn deal_blue_damage(&mut self, skill: Skill, amount: u64) -> Vec<Event> { pub fn deal_blue_damage(&mut self, skill: Skill, amount: usize) -> Vec<Event> {
let mut events = vec![]; let mut events = vec![];
if let Some(immunity) = self.immune(skill) { if let Some(immunity) = self.immune(skill) {
if !self.is_ko() { if !self.is_ko() {
events.push(Event::Immunity { skill, immunity }); events.push(EventVariant::Immunity { skill, immunity });
} }
return events; return events;
} }
@ -789,7 +790,7 @@ impl Construct {
self.reduce_green_life(remainder); self.reduce_green_life(remainder);
let delta = current_green_life - self.green_life(); let delta = current_green_life - self.green_life();
events.push(Event::Damage { events.push(EventVariant::Damage {
skill, skill,
amount: delta, amount: delta,
mitigation, mitigation,
@ -797,7 +798,7 @@ impl Construct {
}); });
}, },
true => { true => {
// events.push(Event::Inversion { skill }); // events.push(EventVariant::Inversion { skill });
let current_green_life = self.green_life(); let current_green_life = self.green_life();
self.green_life.increase(modified_power); self.green_life.increase(modified_power);
@ -810,7 +811,7 @@ impl Construct {
let recharge = self.blue_life.value - current_life; let recharge = self.blue_life.value - current_life;
if healing > 0 { if healing > 0 {
events.push(Event::Healing { events.push(EventVariant::Healing {
skill, skill,
amount: healing, amount: healing,
overhealing, overhealing,
@ -818,7 +819,7 @@ impl Construct {
} }
if recharge > 0 { if recharge > 0 {
events.push(Event::Recharge { red: 0, blue: recharge, skill }); events.push(EventVariant::Recharge { red: 0, blue: recharge, skill });
} }
} }
}; };
@ -828,7 +829,7 @@ impl Construct {
pub fn add_effect(&mut self, skill: Skill, effect: ConstructEffect) -> Event { pub fn add_effect(&mut self, skill: Skill, effect: ConstructEffect) -> Event {
if let Some(immunity) = self.immune(skill) { if let Some(immunity) = self.immune(skill) {
return Event::Immunity { return EventVariant::Immunity {
skill, skill,
immunity, immunity,
}; };
@ -846,7 +847,7 @@ impl Construct {
} }
// todo modified durations cause of buffs // todo modified durations cause of buffs
let result = Event::Effect { let result = EventVariant::Effect {
effect: effect.effect, effect: effect.effect,
duration: effect.duration, duration: effect.duration,
construct_effects: self.effects.clone(), construct_effects: self.effects.clone(),
@ -867,7 +868,7 @@ impl Construct {
// info!("{:} < {:?}", roll, evasion_rating); // info!("{:} < {:?}", roll, evasion_rating);
// match roll < evasion_rating { // match roll < evasion_rating {
// true => Some(Event::Evasion { // true => Some(EventVariant::Evasion {
// skill, // skill,
// evasion_rating: evasion_rating, // evasion_rating: evasion_rating,
// }), // }),

View File

@ -1,4 +1,5 @@
use construct::{Stat, EffectMeta}; use construct::{Stat, EffectMeta};
use game::{Colour};
use skill::{Skill}; use skill::{Skill};
use util::{IntPct}; use util::{IntPct};
@ -123,7 +124,7 @@ impl Effect {
} }
} }
pub fn apply(&self, value: u64, meta: Option<EffectMeta>) -> u64 { pub fn apply(&self, value: usize, meta: Option<EffectMeta>) -> usize {
match self { match self {
Effect::Amplify | Effect::Amplify |
Effect::Vulnerable | Effect::Vulnerable |
@ -200,10 +201,3 @@ impl Effect {
} }
} }
} }
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
pub enum Colour {
Red,
Blue,
Green,
}

File diff suppressed because it is too large Load Diff

View File

@ -493,10 +493,10 @@ impl Instance {
Ok(self) Ok(self)
} }
pub fn vbox_unequip(mut self, account: Uuid, target: Item, construct_id: Uuid, target_construct_id: Option<Uuid>) -> Result<Instance, Error> { pub fn vbox_unequip(mut self, account: Uuid, target: Item, construct_id: Uuid, target_construct: Option<Uuid>) -> Result<Instance, Error> {
self.vbox_action_allowed(account)?; self.vbox_action_allowed(account)?;
self.account_player(account)? self.account_player(account)?
.vbox_unequip(target, construct_id, target_construct_id)?; .vbox_unequip(target, construct_id, target_construct)?;
Ok(self) Ok(self)
} }
} }

View File

@ -1,7 +1,8 @@
use skill::{Skill}; use skill::{Skill};
use spec::{Spec, SpecValues}; use spec::{Spec, SpecValues};
use construct::{Colours}; use construct::{Colours};
use effect::{Colour, Cooldown}; use effect::{Cooldown};
use game::{Colour};
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)] #[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
pub enum Item { pub enum Item {
@ -337,7 +338,7 @@ impl Item {
} }
} }
pub fn base_speed(&self) -> u64 { pub fn base_speed(&self) -> usize {
match self { match self {
Item::Attack => 1, Item::Attack => 1,
Item::Stun => 2, Item::Stun => 2,
@ -351,7 +352,7 @@ impl Item {
} }
} }
pub fn speed(&self) -> u64 { pub fn speed(&self) -> usize {
match self { match self {
Item::Attack | Item::Attack |
Item::Stun | Item::Stun |
@ -1490,7 +1491,7 @@ pub struct ItemInfo {
pub spec: bool, pub spec: bool,
pub values: Option<SpecValues>, pub values: Option<SpecValues>,
pub skill: bool, pub skill: bool,
pub speed: Option<u64>, pub speed: Option<usize>,
pub cooldown: Cooldown, pub cooldown: Cooldown,
pub description: String, pub description: String,
} }

View File

@ -330,8 +330,8 @@ impl Player {
Ok(self) Ok(self)
} }
pub fn vbox_unequip(&mut self, target: Item, construct_id: Uuid, target_construct_id: Option<Uuid>) -> Result<&mut Player, Error> { pub fn vbox_unequip(&mut self, target: Item, construct_id: Uuid, construct: Option<Uuid>) -> Result<&mut Player, Error> {
if self.vbox.stash.len() >= 9 && !target_construct_id.is_some() { if self.vbox.stash.len() >= 9 && !construct.is_some() {
return Err(err_msg("too many items stash")); return Err(err_msg("too many items stash"));
} }
@ -363,7 +363,7 @@ impl Player {
construct.apply_modifiers(&player_colours); construct.apply_modifiers(&player_colours);
} }
match target_construct_id { match construct {
Some(cid) => { self.vbox_apply(target, cid)?; }, Some(cid) => { self.vbox_apply(target, cid)?; },
None => { self.vbox.stash_add(target, None)?; }, None => { self.vbox.stash_add(target, None)?; },
}; };

File diff suppressed because it is too large Load Diff

View File

@ -4,11 +4,11 @@ use util::{IntPct};
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct SpecBonus { pub struct SpecBonus {
pub req: Colours, pub req: Colours,
pub bonus: u64, pub bonus: usize,
} }
impl SpecBonus { impl SpecBonus {
pub fn get_bonus(&self, c: &Colours) -> u64 { pub fn get_bonus(&self, c: &Colours) -> usize {
if c.red >= self.req.red && c.blue >= self.req.blue && c.green >= self.req.green { if c.red >= self.req.red && c.blue >= self.req.blue && c.green >= self.req.green {
return self.bonus; return self.bonus;
} }
@ -18,16 +18,16 @@ impl SpecBonus {
#[derive(Debug,Clone,Serialize,Deserialize)] #[derive(Debug,Clone,Serialize,Deserialize)]
pub struct SpecValues { pub struct SpecValues {
pub base: u64, pub base: usize,
pub bonuses: Vec<SpecBonus>, pub bonuses: Vec<SpecBonus>,
} }
impl SpecValues { impl SpecValues {
pub fn max_value (&self, c: &Colours) -> u64 { pub fn max_value (&self, c: &Colours) -> usize {
self.bonuses.iter().fold(self.base, |acc, s| acc + s.get_bonus(c)) self.bonuses.iter().fold(self.base, |acc, s| acc + s.get_bonus(c))
} }
pub fn base (self) -> u64 { pub fn base (self) -> usize {
self.base self.base
} }
} }
@ -666,7 +666,7 @@ impl Spec {
} }
} }
pub fn apply(&self, modified: u64, base: u64, player_colours: &Colours) -> u64 { pub fn apply(&self, modified: usize, base: usize, player_colours: &Colours) -> usize {
match *self { match *self {
// Percentage multipliers based on base value // Percentage multipliers based on base value
Spec::Power | Spec::Power |

View File

@ -17,11 +17,11 @@
// } // }
pub trait IntPct { pub trait IntPct {
fn pct(self, pct: u64) -> u64; fn pct(self, pct: usize) -> usize;
} }
impl IntPct for u64 { impl IntPct for usize {
fn pct(self, pct: u64) -> u64 { fn pct(self, pct: usize) -> usize {
self * pct / 100 self * pct / 100
} }
} }