break stuff
This commit is contained in:
parent
5446ee19ae
commit
8cb335fcc7
4
core/fixme.md
Normal file
4
core/fixme.md
Normal file
@ -0,0 +1,4 @@
|
||||
# FIXME
|
||||
|
||||
aoe event
|
||||
cooldown checking -> go through round and find all casters
|
||||
@ -4,8 +4,9 @@ use rand::prelude::*;
|
||||
use failure::Error;
|
||||
use failure::err_msg;
|
||||
|
||||
use skill::{Skill, Cast, Immunity, Disable, Event};
|
||||
use effect::{Cooldown, Effect, Colour};
|
||||
use skill::{Skill, Cast, Immunity, Disable, EventVariant};
|
||||
use game::{Colour};
|
||||
use effect::{Cooldown, Effect};
|
||||
use spec::{Spec};
|
||||
use item::{Item};
|
||||
|
||||
@ -60,10 +61,10 @@ impl ConstructSkill {
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum EffectMeta {
|
||||
Skill(Skill),
|
||||
TickAmount(u64),
|
||||
AddedDamage(u64),
|
||||
TickAmount(usize),
|
||||
AddedDamage(usize),
|
||||
LinkTarget(Uuid),
|
||||
Multiplier(u64),
|
||||
Multiplier(usize),
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
@ -93,7 +94,7 @@ impl ConstructEffect {
|
||||
self.duration
|
||||
}
|
||||
|
||||
pub fn get_multiplier(&self) -> u64 {
|
||||
pub fn get_multiplier(&self) -> usize {
|
||||
match self.meta {
|
||||
Some(EffectMeta::Multiplier(s)) => s,
|
||||
_ => 0
|
||||
@ -129,14 +130,14 @@ pub enum Stat {
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub struct ConstructStat {
|
||||
base: u64,
|
||||
value: u64,
|
||||
max: u64,
|
||||
base: usize,
|
||||
value: usize,
|
||||
max: usize,
|
||||
pub stat: Stat,
|
||||
}
|
||||
|
||||
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.recalculate(specs)
|
||||
// }
|
||||
@ -157,12 +158,12 @@ impl ConstructStat {
|
||||
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
|
||||
}
|
||||
|
||||
pub fn increase(&mut self, amt: u64) -> &mut ConstructStat {
|
||||
pub fn increase(&mut self, amt: usize) -> &mut ConstructStat {
|
||||
self.value = *[
|
||||
self.value.saturating_add(amt),
|
||||
self.max
|
||||
@ -171,7 +172,7 @@ impl ConstructStat {
|
||||
self
|
||||
}
|
||||
|
||||
pub fn force(&mut self, v: u64) -> &mut ConstructStat {
|
||||
pub fn force(&mut self, v: usize) -> &mut ConstructStat {
|
||||
self.base = v;
|
||||
self.value = v;
|
||||
self.max = v;
|
||||
@ -470,7 +471,7 @@ impl Construct {
|
||||
}
|
||||
|
||||
// Stats
|
||||
pub fn red_power(&self) -> u64 {
|
||||
pub fn red_power(&self) -> usize {
|
||||
let red_power_mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::RedPower))
|
||||
.map(|e| (e.effect, e.meta))
|
||||
@ -481,7 +482,7 @@ impl Construct {
|
||||
return modified_red_power;
|
||||
}
|
||||
|
||||
pub fn blue_power(&self) -> u64 {
|
||||
pub fn blue_power(&self) -> usize {
|
||||
let blue_power_mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::BluePower))
|
||||
.map(|e| (e.effect, e.meta))
|
||||
@ -492,7 +493,7 @@ impl Construct {
|
||||
return modified_blue_power;
|
||||
}
|
||||
|
||||
pub fn green_power(&self) -> u64 {
|
||||
pub fn green_power(&self) -> usize {
|
||||
let green_power_mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::GreenPower))
|
||||
.map(|e| (e.effect, e.meta))
|
||||
@ -503,8 +504,8 @@ impl Construct {
|
||||
return modified_green_power;
|
||||
}
|
||||
|
||||
pub fn skill_speed(&self, s: Skill) -> u64 {
|
||||
self.speed().saturating_mul(s.speed() as u64)
|
||||
pub fn skill_speed(&self, s: Skill) -> usize {
|
||||
self.speed().saturating_mul(s.speed() as usize)
|
||||
}
|
||||
|
||||
// todo complete with specs
|
||||
@ -512,7 +513,7 @@ impl Construct {
|
||||
s.aoe()
|
||||
}
|
||||
|
||||
pub fn speed(&self) -> u64 {
|
||||
pub fn speed(&self) -> usize {
|
||||
let speed_mods = self.effects.iter()
|
||||
.filter(|e| e.effect.modifications().contains(&Stat::Speed))
|
||||
.map(|e| (e.effect, e.meta))
|
||||
@ -523,32 +524,32 @@ impl Construct {
|
||||
return modified_speed;
|
||||
}
|
||||
|
||||
pub fn red_life(&self) -> u64 {
|
||||
pub fn red_life(&self) -> usize {
|
||||
self.red_life.value
|
||||
}
|
||||
|
||||
pub fn blue_life(&self) -> u64 {
|
||||
pub fn blue_life(&self) -> usize {
|
||||
self.blue_life.value
|
||||
}
|
||||
|
||||
pub fn green_life(&self) -> u64 {
|
||||
pub fn green_life(&self) -> usize {
|
||||
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);
|
||||
if self.affected(Effect::Sustain) && self.green_life() == 0 {
|
||||
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![];
|
||||
|
||||
// Should red type immunity block recharge???
|
||||
if let Some(immunity) = self.immune(skill) {
|
||||
if !self.is_ko() {
|
||||
events.push(Event::Immunity { skill, immunity });
|
||||
events.push(EventVariant::Immunity { skill, immunity });
|
||||
}
|
||||
return events;
|
||||
}
|
||||
@ -567,7 +568,7 @@ impl Construct {
|
||||
let blue = new_blue_life - current_blue_life;
|
||||
|
||||
if red != 0 || blue != 0 {
|
||||
events.push(Event::Recharge { red, blue, skill });
|
||||
events.push(EventVariant::Recharge { red, blue, skill });
|
||||
}
|
||||
},
|
||||
true => {
|
||||
@ -593,7 +594,7 @@ impl Construct {
|
||||
self.reduce_green_life(red_remainder);
|
||||
let red_damage_amount = red_current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
skill,
|
||||
amount: red_damage_amount,
|
||||
mitigation: red_mitigation,
|
||||
@ -622,7 +623,7 @@ impl Construct {
|
||||
self.reduce_green_life(blue_remainder);
|
||||
let blue_damage_amount = blue_current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
skill,
|
||||
amount: blue_damage_amount,
|
||||
mitigation: blue_mitigation,
|
||||
@ -634,11 +635,11 @@ impl Construct {
|
||||
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![];
|
||||
if let Some(immunity) = self.immune(skill) {
|
||||
if !self.is_ko() {
|
||||
events.push(Event::Immunity { skill, immunity });
|
||||
events.push(EventVariant::Immunity { skill, immunity });
|
||||
}
|
||||
return events;
|
||||
}
|
||||
@ -660,21 +661,21 @@ impl Construct {
|
||||
let healing = new_green_life - current_green_life;
|
||||
let overhealing = modified_power - healing;
|
||||
|
||||
events.push(Event::Healing {
|
||||
events.push(EventVariant::Healing {
|
||||
skill,
|
||||
amount: healing,
|
||||
overhealing,
|
||||
});
|
||||
},
|
||||
true => {
|
||||
// events.push(Event::Inversion { skill });
|
||||
// events.push(EventVariant::Inversion { skill });
|
||||
|
||||
// there is no green shield (yet)
|
||||
let current_green_life = self.green_life();
|
||||
self.reduce_green_life(modified_power);
|
||||
let delta = current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
skill,
|
||||
amount: delta,
|
||||
mitigation: 0,
|
||||
@ -686,12 +687,12 @@ impl Construct {
|
||||
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![];
|
||||
|
||||
if let Some(immunity) = self.immune(skill) {
|
||||
if !self.is_ko() {
|
||||
events.push(Event::Immunity { skill, immunity });
|
||||
events.push(EventVariant::Immunity { skill, immunity });
|
||||
}
|
||||
return events;
|
||||
}
|
||||
@ -721,7 +722,7 @@ impl Construct {
|
||||
self.reduce_green_life(remainder);
|
||||
let delta = current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
skill,
|
||||
amount: delta,
|
||||
mitigation,
|
||||
@ -729,7 +730,7 @@ impl Construct {
|
||||
});
|
||||
},
|
||||
true => {
|
||||
// events.push(Event::Inversion { skill });
|
||||
// events.push(EventVariant::Inversion { skill });
|
||||
|
||||
let current_green_life = self.green_life();
|
||||
self.green_life.increase(modified_power);
|
||||
@ -742,7 +743,7 @@ impl Construct {
|
||||
let recharge = self.red_life.value - current_life;
|
||||
|
||||
if healing > 0 {
|
||||
events.push(Event::Healing {
|
||||
events.push(EventVariant::Healing {
|
||||
skill,
|
||||
amount: healing,
|
||||
overhealing: overhealing - recharge,
|
||||
@ -750,7 +751,7 @@ impl Construct {
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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![];
|
||||
|
||||
if let Some(immunity) = self.immune(skill) {
|
||||
if !self.is_ko() {
|
||||
events.push(Event::Immunity { skill, immunity });
|
||||
events.push(EventVariant::Immunity { skill, immunity });
|
||||
}
|
||||
return events;
|
||||
}
|
||||
@ -789,7 +790,7 @@ impl Construct {
|
||||
self.reduce_green_life(remainder);
|
||||
let delta = current_green_life - self.green_life();
|
||||
|
||||
events.push(Event::Damage {
|
||||
events.push(EventVariant::Damage {
|
||||
skill,
|
||||
amount: delta,
|
||||
mitigation,
|
||||
@ -797,7 +798,7 @@ impl Construct {
|
||||
});
|
||||
},
|
||||
true => {
|
||||
// events.push(Event::Inversion { skill });
|
||||
// events.push(EventVariant::Inversion { skill });
|
||||
|
||||
let current_green_life = self.green_life();
|
||||
self.green_life.increase(modified_power);
|
||||
@ -810,7 +811,7 @@ impl Construct {
|
||||
let recharge = self.blue_life.value - current_life;
|
||||
|
||||
if healing > 0 {
|
||||
events.push(Event::Healing {
|
||||
events.push(EventVariant::Healing {
|
||||
skill,
|
||||
amount: healing,
|
||||
overhealing,
|
||||
@ -818,7 +819,7 @@ impl Construct {
|
||||
}
|
||||
|
||||
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 {
|
||||
if let Some(immunity) = self.immune(skill) {
|
||||
return Event::Immunity {
|
||||
return EventVariant::Immunity {
|
||||
skill,
|
||||
immunity,
|
||||
};
|
||||
@ -846,7 +847,7 @@ impl Construct {
|
||||
}
|
||||
|
||||
// todo modified durations cause of buffs
|
||||
let result = Event::Effect {
|
||||
let result = EventVariant::Effect {
|
||||
effect: effect.effect,
|
||||
duration: effect.duration,
|
||||
construct_effects: self.effects.clone(),
|
||||
@ -867,7 +868,7 @@ impl Construct {
|
||||
// info!("{:} < {:?}", roll, evasion_rating);
|
||||
|
||||
// match roll < evasion_rating {
|
||||
// true => Some(Event::Evasion {
|
||||
// true => Some(EventVariant::Evasion {
|
||||
// skill,
|
||||
// evasion_rating: evasion_rating,
|
||||
// }),
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
use construct::{Stat, EffectMeta};
|
||||
use game::{Colour};
|
||||
use skill::{Skill};
|
||||
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 {
|
||||
Effect::Amplify |
|
||||
Effect::Vulnerable |
|
||||
@ -200,10 +201,3 @@ impl Effect {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||
pub enum Colour {
|
||||
Red,
|
||||
Blue,
|
||||
Green,
|
||||
}
|
||||
|
||||
1136
core/src/game.rs
1136
core/src/game.rs
File diff suppressed because it is too large
Load Diff
@ -493,10 +493,10 @@ impl Instance {
|
||||
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.account_player(account)?
|
||||
.vbox_unequip(target, construct_id, target_construct_id)?;
|
||||
.vbox_unequip(target, construct_id, target_construct)?;
|
||||
Ok(self)
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
use skill::{Skill};
|
||||
use spec::{Spec, SpecValues};
|
||||
use construct::{Colours};
|
||||
use effect::{Colour, Cooldown};
|
||||
use effect::{Cooldown};
|
||||
use game::{Colour};
|
||||
|
||||
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq,PartialOrd,Ord,Eq)]
|
||||
pub enum Item {
|
||||
@ -337,7 +338,7 @@ impl Item {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn base_speed(&self) -> u64 {
|
||||
pub fn base_speed(&self) -> usize {
|
||||
match self {
|
||||
Item::Attack => 1,
|
||||
Item::Stun => 2,
|
||||
@ -351,7 +352,7 @@ impl Item {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn speed(&self) -> u64 {
|
||||
pub fn speed(&self) -> usize {
|
||||
match self {
|
||||
Item::Attack |
|
||||
Item::Stun |
|
||||
@ -1490,7 +1491,7 @@ pub struct ItemInfo {
|
||||
pub spec: bool,
|
||||
pub values: Option<SpecValues>,
|
||||
pub skill: bool,
|
||||
pub speed: Option<u64>,
|
||||
pub speed: Option<usize>,
|
||||
pub cooldown: Cooldown,
|
||||
pub description: String,
|
||||
}
|
||||
|
||||
@ -330,8 +330,8 @@ impl Player {
|
||||
Ok(self)
|
||||
}
|
||||
|
||||
pub fn vbox_unequip(&mut self, target: Item, construct_id: Uuid, target_construct_id: Option<Uuid>) -> Result<&mut Player, Error> {
|
||||
if self.vbox.stash.len() >= 9 && !target_construct_id.is_some() {
|
||||
pub fn vbox_unequip(&mut self, target: Item, construct_id: Uuid, construct: Option<Uuid>) -> Result<&mut Player, Error> {
|
||||
if self.vbox.stash.len() >= 9 && !construct.is_some() {
|
||||
return Err(err_msg("too many items stash"));
|
||||
}
|
||||
|
||||
@ -363,7 +363,7 @@ impl Player {
|
||||
construct.apply_modifiers(&player_colours);
|
||||
}
|
||||
|
||||
match target_construct_id {
|
||||
match construct {
|
||||
Some(cid) => { self.vbox_apply(target, cid)?; },
|
||||
None => { self.vbox.stash_add(target, None)?; },
|
||||
};
|
||||
|
||||
2462
core/src/skill.rs
2462
core/src/skill.rs
File diff suppressed because it is too large
Load Diff
@ -4,11 +4,11 @@ use util::{IntPct};
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct SpecBonus {
|
||||
pub req: Colours,
|
||||
pub bonus: u64,
|
||||
pub bonus: usize,
|
||||
}
|
||||
|
||||
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 {
|
||||
return self.bonus;
|
||||
}
|
||||
@ -18,16 +18,16 @@ impl SpecBonus {
|
||||
|
||||
#[derive(Debug,Clone,Serialize,Deserialize)]
|
||||
pub struct SpecValues {
|
||||
pub base: u64,
|
||||
pub base: usize,
|
||||
pub bonuses: Vec<SpecBonus>,
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
|
||||
pub fn base (self) -> u64 {
|
||||
pub fn base (self) -> usize {
|
||||
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 {
|
||||
// Percentage multipliers based on base value
|
||||
Spec::Power |
|
||||
|
||||
@ -17,11 +17,11 @@
|
||||
// }
|
||||
|
||||
pub trait IntPct {
|
||||
fn pct(self, pct: u64) -> u64;
|
||||
fn pct(self, pct: usize) -> usize;
|
||||
}
|
||||
|
||||
impl IntPct for u64 {
|
||||
fn pct(self, pct: u64) -> u64 {
|
||||
impl IntPct for usize {
|
||||
fn pct(self, pct: usize) -> usize {
|
||||
self * pct / 100
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user