stam -> hp
This commit is contained in:
+15
-26
@@ -44,7 +44,6 @@ pub enum Stat {
|
||||
Int,
|
||||
Hp,
|
||||
Speed,
|
||||
Stamina,
|
||||
RedDamage,
|
||||
RedDamageTaken,
|
||||
BlueDamage,
|
||||
@@ -60,6 +59,7 @@ pub enum Stat {
|
||||
pub struct CrypStat {
|
||||
base: u64,
|
||||
value: u64,
|
||||
max: u64,
|
||||
pub stat: Stat,
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ impl CrypStat {
|
||||
// but still needs access to the base amount
|
||||
let value = specs.iter().fold(self.base, |acc, s| s.apply(acc, self.base));
|
||||
self.value = value;
|
||||
self.max = value;
|
||||
|
||||
self
|
||||
}
|
||||
@@ -120,7 +121,6 @@ pub struct Cryp {
|
||||
pub blue_shield: CrypStat,
|
||||
pub blue_damage: CrypStat,
|
||||
pub speed: CrypStat,
|
||||
pub stamina: CrypStat,
|
||||
pub hp: CrypStat,
|
||||
pub evasion: CrypStat,
|
||||
pub xp: u64,
|
||||
@@ -143,14 +143,13 @@ impl Cryp {
|
||||
return Cryp {
|
||||
id,
|
||||
account: id,
|
||||
red_damage: CrypStat { base: 0, value: 0, stat: Stat::RedDamage },
|
||||
red_shield: CrypStat { base: 0, value: 0, stat: Stat::RedShield },
|
||||
blue_damage: CrypStat { base: 0, value: 0, stat: Stat::BlueDamage },
|
||||
blue_shield: CrypStat { base: 0, value: 0, stat: Stat::BlueShield },
|
||||
speed: CrypStat { base: 0, value: 0, stat: Stat::Speed },
|
||||
stamina: CrypStat { base: 0, value: 0, stat: Stat::Stamina },
|
||||
hp: CrypStat { base: 0, value: 0, stat: Stat::Hp },
|
||||
evasion: CrypStat { base: 0, value: 0, stat: Stat::Evasion },
|
||||
red_damage: CrypStat { base: 0, value: 0, max: 0, stat: Stat::RedDamage },
|
||||
red_shield: CrypStat { base: 0, value: 0, max: 0, stat: Stat::RedShield },
|
||||
blue_damage: CrypStat { base: 0, value: 0, max: 0, stat: Stat::BlueDamage },
|
||||
blue_shield: CrypStat { base: 0, value: 0, max: 0, stat: Stat::BlueShield },
|
||||
speed: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Speed },
|
||||
hp: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Hp },
|
||||
evasion: CrypStat { base: 0, value: 0, max: 0, stat: Stat::Evasion },
|
||||
lvl: 0,
|
||||
xp: 0,
|
||||
skills: vec![],
|
||||
@@ -225,10 +224,7 @@ impl Cryp {
|
||||
Stat::RedDamage => self.red_damage.set(rng.gen_range(stat_min, stat_max), &self.specs),
|
||||
Stat::BlueDamage => self.blue_damage.set(rng.gen_range(stat_min, stat_max), &self.specs),
|
||||
Stat::Speed => self.speed.set(rng.gen_range(stat_min, stat_max), &self.specs),
|
||||
Stat::Stamina => {
|
||||
self.stamina.set(rng.gen_range(stam_min, stam_max), &self.specs);
|
||||
self.hp.set(self.stamina.base, &self.specs)
|
||||
},
|
||||
Stat::Hp => self.hp.set(rng.gen_range(stam_min, stam_max), &self.specs),
|
||||
Stat::BlueShield => self.blue_shield.set(rng.gen_range(stat_min, stat_max), &self.specs),
|
||||
Stat::RedShield => self.red_shield.set(rng.gen_range(stat_min, stat_max), &self.specs),
|
||||
Stat::Evasion => self.evasion.set(rng.gen_range(evasion_min, evasion_max), &self.specs),
|
||||
@@ -249,7 +245,7 @@ impl Cryp {
|
||||
self.roll_stat(Stat::RedDamage);
|
||||
self.roll_stat(Stat::BlueDamage);
|
||||
self.roll_stat(Stat::Speed);
|
||||
self.roll_stat(Stat::Stamina);
|
||||
self.roll_stat(Stat::Hp);
|
||||
|
||||
self
|
||||
}
|
||||
@@ -276,10 +272,7 @@ impl Cryp {
|
||||
self.blue_shield.recalculate(&self.specs);
|
||||
self.evasion.recalculate(&self.specs);
|
||||
self.speed.recalculate(&self.specs);
|
||||
|
||||
// special case where hp is tied to stam
|
||||
self.stamina.recalculate(&self.specs);
|
||||
self.hp.set(self.stamina.value, &self.specs);
|
||||
self.hp.recalculate(&self.specs);
|
||||
|
||||
self
|
||||
}
|
||||
@@ -406,7 +399,7 @@ impl Cryp {
|
||||
}
|
||||
|
||||
// pub fn rez(&mut self) -> &mut Cryp {
|
||||
// self.hp.set(self.stamina.base);
|
||||
// self.hp.set(self.hp.base);
|
||||
// self
|
||||
// }
|
||||
|
||||
@@ -449,10 +442,6 @@ impl Cryp {
|
||||
self.hp.value
|
||||
}
|
||||
|
||||
pub fn stamina(&self) -> u64 {
|
||||
self.stamina.value
|
||||
}
|
||||
|
||||
pub fn heal(&mut self, skill: Skill, amount: u64) -> ResolutionResult {
|
||||
let immunity = self.immune(skill);
|
||||
let immune = immunity.immune;
|
||||
@@ -478,7 +467,7 @@ impl Cryp {
|
||||
let current_hp = self.hp();
|
||||
let new_hp = *[
|
||||
self.hp().saturating_add(modified_healing),
|
||||
self.stamina()
|
||||
self.hp.max
|
||||
].iter().min().unwrap();
|
||||
|
||||
let healing = new_hp - current_hp;
|
||||
@@ -597,7 +586,7 @@ impl Cryp {
|
||||
}
|
||||
|
||||
let mut rng = thread_rng();
|
||||
let hp_pct = (self.hp.value * 100) / self.stamina.value;
|
||||
let hp_pct = (self.hp.value * 100) / self.hp.value;
|
||||
let evasion_rating = (self.evasion.value * hp_pct) / 100;
|
||||
let roll = rng.gen_range(0, 100);
|
||||
println!("{:} < {:?}", roll, evasion_rating);
|
||||
|
||||
+4
-4
@@ -20,7 +20,7 @@ pub enum ItemAction {
|
||||
RerollRedDamage,
|
||||
RerollBlueDamage,
|
||||
RerollSpeed,
|
||||
RerollStamina,
|
||||
RerollHp,
|
||||
RerollRedShield,
|
||||
RerollBlueShield,
|
||||
RerollEvasion,
|
||||
@@ -52,7 +52,7 @@ impl Item {
|
||||
|
||||
fn apply(&mut self, tx: &mut Transaction, target: Uuid) -> Result<(), Error> {
|
||||
match self.action {
|
||||
ItemAction::RerollStamina => reroll(self, tx, target, Stat::Stamina),
|
||||
ItemAction::RerollHp => reroll(self, tx, target, Stat::Hp),
|
||||
ItemAction::RerollRedDamage => reroll(self, tx, target, Stat::RedDamage),
|
||||
ItemAction::RerollBlueDamage => reroll(self, tx, target, Stat::BlueDamage),
|
||||
ItemAction::RerollSpeed => reroll(self, tx, target, Stat::Speed),
|
||||
@@ -85,7 +85,7 @@ fn reroll(item: &mut Item, tx: &mut Transaction, target: Uuid, stat: Stat) -> Re
|
||||
fn mode_drops(mode: GameMode) -> Vec<(ItemAction, usize)> {
|
||||
match mode {
|
||||
GameMode::Normal => vec![
|
||||
(ItemAction::RerollStamina, 1),
|
||||
(ItemAction::RerollHp, 1),
|
||||
(ItemAction::RerollRedDamage, 1),
|
||||
(ItemAction::RerollBlueDamage, 1),
|
||||
],
|
||||
@@ -103,7 +103,7 @@ fn mode_drops(mode: GameMode) -> Vec<(ItemAction, usize)> {
|
||||
(ItemAction::RerollSpeed, 1),
|
||||
],
|
||||
// _ => vec![
|
||||
// (ItemAction::RerollStamina, 1),
|
||||
// (ItemAction::RerollHp, 1),
|
||||
// (ItemAction::RerollRedDamage, 1),
|
||||
// (ItemAction::RerollBlueDamage, 1),
|
||||
// (ItemAction::RerollSpeed, 1),
|
||||
|
||||
+1
-1
@@ -1045,7 +1045,7 @@ mod tests {
|
||||
|
||||
y.reduce_effect_durations(&mut log);
|
||||
let _decay = y.effects.iter().find(|e| e.effect == Effect::Decay);
|
||||
// assert!(y.hp() == y.stamina().saturating_sub(decay.unwrap().tick.unwrap().amount));
|
||||
// assert!(y.hp() == y.hp().saturating_sub(decay.unwrap().tick.unwrap().amount));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
+3
-3
@@ -3,7 +3,7 @@ use cryp::{Stat};
|
||||
#[derive(Debug,Copy,Clone,Serialize,Deserialize,PartialEq)]
|
||||
pub enum Spec {
|
||||
SpeedI,
|
||||
StaminaI,
|
||||
HpI,
|
||||
RedDamageI,
|
||||
GreenDamageI,
|
||||
BlueDamageI,
|
||||
@@ -20,7 +20,7 @@ impl Spec {
|
||||
Spec::RedShieldI => Stat::RedShield,
|
||||
Spec::BlueShieldI => Stat::BlueShield,
|
||||
Spec::SpeedI => Stat::Speed,
|
||||
Spec::StaminaI => Stat::Stamina,
|
||||
Spec::HpI => Stat::Hp,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ impl Spec {
|
||||
Spec::GreenDamageI => modified + (base * 5 / 100),
|
||||
Spec::BlueDamageI => modified + (base * 5 / 100),
|
||||
Spec::SpeedI => modified + (base * 5 / 100),
|
||||
Spec::StaminaI => modified + (base * 5 / 100),
|
||||
Spec::HpI => modified + (base * 5 / 100),
|
||||
Spec::RedShieldI => modified + 50,
|
||||
Spec::BlueShieldI => modified + 50,
|
||||
}
|
||||
|
||||
+13
-14
@@ -33,17 +33,15 @@ pub enum Var {
|
||||
|
||||
// specs
|
||||
Damage,
|
||||
Protection,
|
||||
Hp,
|
||||
Speed,
|
||||
Stamina,
|
||||
|
||||
StaminaI,
|
||||
HpI,
|
||||
RedDamageI,
|
||||
BlueDamageI,
|
||||
GreenDamageI,
|
||||
RedShieldI,
|
||||
BlueShieldI,
|
||||
SpeedI,
|
||||
|
||||
Amplify,
|
||||
Banish,
|
||||
@@ -87,7 +85,7 @@ impl Var {
|
||||
Var::Debuff |
|
||||
Var::Buff => true,
|
||||
|
||||
Var::Protection |
|
||||
Var::Hp |
|
||||
Var::Damage => true,
|
||||
|
||||
_ => false,
|
||||
@@ -137,13 +135,16 @@ impl Var {
|
||||
|
||||
fn spec(&self) -> Option<Spec> {
|
||||
match *self {
|
||||
Var::StaminaI => Some(Spec::StaminaI),
|
||||
Var::SpeedI => Some(Spec::SpeedI),
|
||||
Var::Speed => Some(Spec::SpeedI),
|
||||
|
||||
Var::RedDamageI => Some(Spec::RedDamageI),
|
||||
Var::BlueDamageI => Some(Spec::BlueDamageI),
|
||||
Var::GreenDamageI => Some(Spec::GreenDamageI),
|
||||
|
||||
Var::HpI => Some(Spec::HpI),
|
||||
Var::RedShieldI => Some(Spec::RedShieldI),
|
||||
Var::BlueShieldI => Some(Spec::BlueShieldI),
|
||||
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -175,8 +176,8 @@ impl Vbox {
|
||||
Var::Attack,
|
||||
Var::Attack,
|
||||
Var::Attack,
|
||||
Var::StaminaI,
|
||||
Var::SpeedI,
|
||||
Var::Hp,
|
||||
Var::Speed,
|
||||
Var::Damage,
|
||||
Var::Red,
|
||||
Var::Green,
|
||||
@@ -214,9 +215,8 @@ impl Vbox {
|
||||
|
||||
let specs = vec![
|
||||
(Var::Damage, 1),
|
||||
(Var::Protection, 1),
|
||||
(Var::Hp, 1),
|
||||
(Var::Speed, 1),
|
||||
(Var::Stamina, 1),
|
||||
];
|
||||
|
||||
let mut rng = thread_rng();
|
||||
@@ -358,16 +358,15 @@ impl Vbox {
|
||||
ColourCode::GB => return Err(err_msg("unhandled skill combo")),
|
||||
ColourCode::BR => return Err(err_msg("unhandled skill combo")),
|
||||
},
|
||||
Var::Protection => match colour_code {
|
||||
Var::Hp => match colour_code {
|
||||
ColourCode::RR => Var::RedShieldI,
|
||||
ColourCode::GG => Var::StaminaI,
|
||||
ColourCode::GG => Var::HpI,
|
||||
ColourCode::BB => Var::BlueShieldI,
|
||||
ColourCode::RG => return Err(err_msg("unhandled skill combo")),
|
||||
ColourCode::GB => return Err(err_msg("unhandled skill combo")),
|
||||
ColourCode::BR => return Err(err_msg("unhandled skill combo")),
|
||||
},
|
||||
|
||||
|
||||
_ => panic!("wrong base {:?}", base),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user