move into own mod
This commit is contained in:
parent
02f6dffb4a
commit
1fa645cbfd
@ -9,7 +9,8 @@ use failure::err_msg;
|
|||||||
|
|
||||||
use account::{Account};
|
use account::{Account};
|
||||||
use rpc::{ConstructSpawnParams};
|
use rpc::{ConstructSpawnParams};
|
||||||
use skill::{Skill, Cooldown, Effect, Cast, Colour, Immunity, Disable, Event};
|
use skill::{Skill, Cast, Immunity, Disable, Event};
|
||||||
|
use effect::{Cooldown, Effect, Colour};
|
||||||
use spec::{Spec};
|
use spec::{Spec};
|
||||||
use item::{Item};
|
use item::{Item};
|
||||||
|
|
||||||
@ -975,6 +976,30 @@ mod tests {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn construct_colour_calc_test() {
|
||||||
|
let mut construct = Construct::new()
|
||||||
|
.named(&"player player".to_string());
|
||||||
|
|
||||||
|
construct.spec_add(Spec::PowerRRI).unwrap();
|
||||||
|
construct.spec_add(Spec::PowerGGI).unwrap();
|
||||||
|
construct.spec_add(Spec::PowerBBI).unwrap();
|
||||||
|
|
||||||
|
let colours = Colours::from_construct(&construct);
|
||||||
|
assert!(colours.red == 2);
|
||||||
|
assert!(colours.blue == 2);
|
||||||
|
assert!(colours.green == 2);
|
||||||
|
|
||||||
|
let construct = construct
|
||||||
|
.learn(Skill::StrikeI)
|
||||||
|
.learn(Skill::BlastIII);
|
||||||
|
|
||||||
|
let colours = Colours::from_construct(&construct);
|
||||||
|
assert!(colours.red == 4);
|
||||||
|
assert!(colours.blue == 20);
|
||||||
|
assert!(colours.green == 2);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn construct_player_modifiers_spec_bonus_test() {
|
fn construct_player_modifiers_spec_bonus_test() {
|
||||||
let mut construct = Construct::new()
|
let mut construct = Construct::new()
|
||||||
|
|||||||
@ -14,7 +14,8 @@ use failure::err_msg;
|
|||||||
use account::Account;
|
use account::Account;
|
||||||
use rpc::{GameStateParams, GameSkillParams};
|
use rpc::{GameStateParams, GameSkillParams};
|
||||||
use construct::{Construct};
|
use construct::{Construct};
|
||||||
use skill::{Skill, Effect, Cast, Resolution, Event, resolution_steps};
|
use skill::{Skill, Cast, Resolution, Event, resolution_steps};
|
||||||
|
use effect::{Effect};
|
||||||
use player::{Player};
|
use player::{Player};
|
||||||
use instance::{TimeControl, instance_game_finished};
|
use instance::{TimeControl, instance_game_finished};
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
use skill::{Skill, Colour};
|
use skill::{Skill};
|
||||||
use spec::{Spec, SpecValues};
|
use spec::{Spec, SpecValues};
|
||||||
use construct::{Colours};
|
use construct::{Colours};
|
||||||
|
use effect::{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 {
|
||||||
|
|||||||
@ -28,6 +28,7 @@ mod net;
|
|||||||
mod player;
|
mod player;
|
||||||
mod rpc;
|
mod rpc;
|
||||||
mod skill;
|
mod skill;
|
||||||
|
mod effect;
|
||||||
mod spec;
|
mod spec;
|
||||||
mod util;
|
mod util;
|
||||||
mod vbox;
|
mod vbox;
|
||||||
|
|||||||
@ -10,7 +10,7 @@ use account::Account;
|
|||||||
use construct::{Construct, Colours};
|
use construct::{Construct, Colours};
|
||||||
use vbox::{Vbox};
|
use vbox::{Vbox};
|
||||||
use item::{Item, ItemEffect};
|
use item::{Item, ItemEffect};
|
||||||
use skill::{Effect};
|
use effect::{Effect};
|
||||||
|
|
||||||
const DISCARD_COST: u16 = 5;
|
const DISCARD_COST: u16 = 5;
|
||||||
|
|
||||||
|
|||||||
@ -2,10 +2,11 @@ use rand::{thread_rng, Rng};
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use util::{IntPct};
|
use util::{IntPct};
|
||||||
use construct::{Construct, ConstructEffect, EffectMeta, Stat};
|
use construct::{Construct, ConstructEffect, EffectMeta};
|
||||||
use item::{Item};
|
use item::{Item};
|
||||||
|
|
||||||
use game::{Game};
|
use game::{Game};
|
||||||
|
use effect::{Effect, Colour, Cooldown};
|
||||||
|
|
||||||
pub fn resolution_steps(cast: &Cast, game: &mut Game) -> Resolutions {
|
pub fn resolution_steps(cast: &Cast, game: &mut Game) -> Resolutions {
|
||||||
let mut resolutions = vec![];
|
let mut resolutions = vec![];
|
||||||
@ -464,218 +465,6 @@ pub enum Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Resolutions = Vec<Resolution>;
|
type Resolutions = Vec<Resolution>;
|
||||||
pub type Cooldown = Option<u8>;
|
|
||||||
|
|
||||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
|
||||||
pub enum Effect {
|
|
||||||
Amplify,
|
|
||||||
Banish,
|
|
||||||
Block,
|
|
||||||
Buff,
|
|
||||||
Clutch,
|
|
||||||
Curse,
|
|
||||||
Haste,
|
|
||||||
Hex,
|
|
||||||
Impurity,
|
|
||||||
Invert,
|
|
||||||
Parry,
|
|
||||||
Purge,
|
|
||||||
Reflect,
|
|
||||||
Slow,
|
|
||||||
Snare,
|
|
||||||
Stun,
|
|
||||||
Taunt,
|
|
||||||
Vulnerable,
|
|
||||||
Silence,
|
|
||||||
Wither, // Reduce green dmg (healing) taken
|
|
||||||
|
|
||||||
// corrupt is the buff that applies
|
|
||||||
// corruption the dmg debuff
|
|
||||||
Corrupt,
|
|
||||||
Corruption,
|
|
||||||
|
|
||||||
// hostility is the buff
|
|
||||||
// hatred is the increased damage
|
|
||||||
Hostility,
|
|
||||||
Hatred,
|
|
||||||
|
|
||||||
// magic immunity
|
|
||||||
Scatter,
|
|
||||||
|
|
||||||
// effects over time
|
|
||||||
Triage,
|
|
||||||
Decay,
|
|
||||||
Regen,
|
|
||||||
Siphon,
|
|
||||||
|
|
||||||
// Airborne,
|
|
||||||
// Boost
|
|
||||||
// Bleed,
|
|
||||||
// Blind,
|
|
||||||
// Deadly,
|
|
||||||
// Enslave,
|
|
||||||
// Fury,
|
|
||||||
// Injured,
|
|
||||||
// Leech,
|
|
||||||
// Mesmerise,
|
|
||||||
// Untouchable,
|
|
||||||
// SpeedSiphon,
|
|
||||||
// SpeedIncrease,
|
|
||||||
|
|
||||||
Ko,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Effect {
|
|
||||||
pub fn immune(&self, skill: Skill) -> bool {
|
|
||||||
match self {
|
|
||||||
Effect::Parry => match skill {
|
|
||||||
Skill::Attack => true,
|
|
||||||
Skill::Stun => true,
|
|
||||||
_ => skill.colours().contains(&Colour::Red)
|
|
||||||
},
|
|
||||||
Effect::Banish => true,
|
|
||||||
Effect::Clutch => [
|
|
||||||
Skill::Stun,
|
|
||||||
Skill::HexI,
|
|
||||||
Skill::HexII,
|
|
||||||
Skill::HexIII,
|
|
||||||
Skill::SilenceI,
|
|
||||||
Skill::SilenceII,
|
|
||||||
Skill::SilenceIII,
|
|
||||||
Skill::RuinI,
|
|
||||||
Skill::RuinII,
|
|
||||||
Skill::RuinIII,
|
|
||||||
Skill::SnareI,
|
|
||||||
Skill::SnareII,
|
|
||||||
Skill::SnareIII
|
|
||||||
].contains(&skill),
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn disables_skill(&self, skill: Skill) -> bool {
|
|
||||||
if skill.is_tick() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
match self {
|
|
||||||
Effect::Stun => true,
|
|
||||||
Effect::Hex => true,
|
|
||||||
Effect::Banish => true,
|
|
||||||
Effect::Silence => skill.colours().contains(&Colour::Blue),
|
|
||||||
Effect::Snare => skill.colours().contains(&Colour::Red),
|
|
||||||
Effect::Purge => skill.colours().contains(&Colour::Green),
|
|
||||||
Effect::Ko => skill.ko_castable(),
|
|
||||||
_ => false,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn modifications(&self) -> Vec<Stat> {
|
|
||||||
match self {
|
|
||||||
Effect::Vulnerable => vec![Stat::RedDamageTaken],
|
|
||||||
Effect::Block => vec![Stat::RedDamageTaken],
|
|
||||||
Effect::Buff => vec![Stat::RedPower, Stat::Speed],
|
|
||||||
|
|
||||||
Effect::Hatred => vec![Stat::RedPower, Stat::BluePower],
|
|
||||||
|
|
||||||
Effect::Amplify => vec![Stat::RedPower, Stat::BluePower],
|
|
||||||
Effect::Curse => vec![Stat::BlueDamageTaken],
|
|
||||||
|
|
||||||
Effect::Impurity => vec![Stat::GreenPower],
|
|
||||||
Effect::Wither => vec![Stat::GreenDamageTaken],
|
|
||||||
|
|
||||||
Effect::Haste => vec![Stat::Speed],
|
|
||||||
Effect::Slow => vec![Stat::Speed],
|
|
||||||
|
|
||||||
Effect::Scatter => vec![Stat::BlueDamageTaken, Stat::GreenDamageTaken, Stat::RedDamageTaken],
|
|
||||||
|
|
||||||
_ => vec![],
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn apply(&self, value: u64, meta: Option<EffectMeta>) -> u64 {
|
|
||||||
match self {
|
|
||||||
Effect::Amplify |
|
|
||||||
Effect::Vulnerable |
|
|
||||||
Effect::Block |
|
|
||||||
Effect::Buff |
|
|
||||||
Effect::Curse |
|
|
||||||
Effect::Haste |
|
|
||||||
Effect::Slow |
|
|
||||||
Effect::Impurity |
|
|
||||||
Effect::Wither => value.pct(match meta {
|
|
||||||
Some(EffectMeta::Multiplier(d)) => d,
|
|
||||||
_ => 100,
|
|
||||||
}),
|
|
||||||
|
|
||||||
Effect::Scatter => value >> 1,
|
|
||||||
|
|
||||||
Effect::Hatred => value + match meta {
|
|
||||||
Some(EffectMeta::AddedDamage(d)) => d,
|
|
||||||
_ => panic!("hatred meta not damage"),
|
|
||||||
},
|
|
||||||
|
|
||||||
_ => {
|
|
||||||
info!("{:?} does not have a mod effect", self);
|
|
||||||
return value;
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn colour(&self) -> Option<Colour> {
|
|
||||||
match self {
|
|
||||||
// physical
|
|
||||||
Effect::Stun => Some(Colour::Red),
|
|
||||||
Effect::Block => Some(Colour::Green),
|
|
||||||
Effect::Buff => Some(Colour::Green),
|
|
||||||
Effect::Parry => Some(Colour::Green),
|
|
||||||
Effect::Vulnerable => Some(Colour::Red),
|
|
||||||
Effect::Snare => Some(Colour::Red),
|
|
||||||
Effect::Clutch => Some(Colour::Green),
|
|
||||||
Effect::Taunt => Some(Colour::Green),
|
|
||||||
|
|
||||||
// magic
|
|
||||||
Effect::Hex => Some(Colour::Blue),
|
|
||||||
Effect::Curse => Some(Colour::Blue),
|
|
||||||
Effect::Banish => None,
|
|
||||||
// Effect::Banish => rng.gen_bool(0.5),
|
|
||||||
|
|
||||||
Effect::Slow => Some(Colour::Blue),
|
|
||||||
Effect::Haste => Some(Colour::Green),
|
|
||||||
Effect::Hatred => Some(Colour::Green),
|
|
||||||
Effect::Reflect => Some(Colour::Green),
|
|
||||||
Effect::Amplify => Some(Colour::Green),
|
|
||||||
Effect::Silence => Some(Colour::Blue),
|
|
||||||
Effect::Wither => Some(Colour::Blue),
|
|
||||||
Effect::Purge => Some(Colour::Blue),
|
|
||||||
|
|
||||||
Effect::Corrupt => Some(Colour::Green),
|
|
||||||
Effect::Corruption => Some(Colour::Blue),
|
|
||||||
|
|
||||||
Effect::Hostility => Some(Colour::Green),
|
|
||||||
|
|
||||||
// magic
|
|
||||||
Effect::Impurity => Some(Colour::Green),
|
|
||||||
Effect::Scatter => Some(Colour::Green),
|
|
||||||
Effect::Invert => Some(Colour::Green),
|
|
||||||
|
|
||||||
// effects over time
|
|
||||||
Effect::Triage => Some(Colour::Green),
|
|
||||||
Effect::Decay => Some(Colour::Blue),
|
|
||||||
Effect::Regen => Some(Colour::Green),
|
|
||||||
Effect::Siphon => Some(Colour::Blue),
|
|
||||||
|
|
||||||
Effect::Ko => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
|
||||||
pub enum Colour {
|
|
||||||
Red,
|
|
||||||
Blue,
|
|
||||||
Green,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
#[derive(Debug,Clone,Copy,PartialEq,Serialize,Deserialize)]
|
||||||
pub enum Skill {
|
pub enum Skill {
|
||||||
@ -1395,7 +1184,7 @@ impl Skill {
|
|||||||
return components;
|
return components;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn colours(&self) -> Vec<Colour> {
|
pub fn colours(&self) -> Vec<Colour> {
|
||||||
let mut components = self.components();
|
let mut components = self.components();
|
||||||
let colour_items = [Item::Red, Item::Green, Item::Blue];
|
let colour_items = [Item::Red, Item::Green, Item::Blue];
|
||||||
components.dedup();
|
components.dedup();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user