You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
89 lines
2.5 KiB
89 lines
2.5 KiB
use serde::{Serialize, Deserialize};
|
|
use crate::item::ItemEntityId;
|
|
use libpso::item::weapon::*;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum TekSpecialModifier {
|
|
Plus,
|
|
Neutral,
|
|
Minus,
|
|
}
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum TekPercentModifier {
|
|
PlusPlus,
|
|
Plus,
|
|
Neutral,
|
|
Minus,
|
|
MinusMinus,
|
|
}
|
|
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub enum WeaponModifier {
|
|
AddPercents {
|
|
attr: WeaponAttribute,
|
|
pds: Vec<ItemEntityId>,
|
|
},
|
|
AddGrind {
|
|
amount: u32,
|
|
grinder: ItemEntityId,
|
|
},
|
|
Tekked {
|
|
special: TekSpecialModifier,
|
|
percent: TekPercentModifier,
|
|
grind: i32,
|
|
},
|
|
}
|
|
|
|
pub fn apply_modifier(weapon: &mut Weapon, modifier: &WeaponModifier) {
|
|
match modifier {
|
|
WeaponModifier::Tekked{special, percent, grind} => {
|
|
match special {
|
|
TekSpecialModifier::Plus => {
|
|
weapon.special = weapon.special.map(|special| {
|
|
special.rank_up()
|
|
});
|
|
},
|
|
TekSpecialModifier::Minus => {
|
|
weapon.special = weapon.special.map(|special| {
|
|
special.rank_down()
|
|
});
|
|
},
|
|
TekSpecialModifier::Neutral => {
|
|
},
|
|
}
|
|
for i in 0..3 {
|
|
weapon.attrs[i] = weapon.attrs[i].map(|mut attr| {
|
|
match percent {
|
|
TekPercentModifier::PlusPlus => {
|
|
attr.value += 10;
|
|
},
|
|
TekPercentModifier::Plus => {
|
|
attr.value += 5;
|
|
},
|
|
TekPercentModifier::MinusMinus => {
|
|
attr.value -= 10;
|
|
},
|
|
TekPercentModifier::Minus => {
|
|
attr.value -= 5;
|
|
},
|
|
TekPercentModifier::Neutral => {
|
|
}
|
|
}
|
|
attr
|
|
});
|
|
}
|
|
weapon.grind = std::cmp::max(weapon.grind as i32 + grind, 0) as u8;
|
|
weapon.tekked = true;
|
|
},
|
|
WeaponModifier::AddGrind {amount, ..} => {
|
|
weapon.grind += *amount as u8;
|
|
},
|
|
WeaponModifier::AddPercents {..} => {
|
|
// TODO
|
|
}
|
|
}
|
|
}
|