|
@ -1029,10 +1029,30 @@ impl Mag { |
|
|
MAG_STATS.get(&self.mag).map(|stats| {
|
|
|
MAG_STATS.get(&self.mag).map(|stats| {
|
|
|
MAG_FEEDING_TABLES.get(stats.feed_table).map(|feeding_table| {
|
|
|
MAG_FEEDING_TABLES.get(stats.feed_table).map(|feeding_table| {
|
|
|
feeding_table.get(&tool).map(|feed_stats| {
|
|
|
feeding_table.get(&tool).map(|feed_stats| {
|
|
|
self.def = std::cmp::max(std::cmp::max((self.def as i16) + feed_stats.def, 0) as u16, self.def()*100);
|
|
|
|
|
|
self.pow = std::cmp::max(std::cmp::max((self.pow as i16) + feed_stats.pow, 0) as u16, self.pow()*100);
|
|
|
|
|
|
self.dex = std::cmp::max(std::cmp::max((self.dex as i16) + feed_stats.dex, 0) as u16, self.dex()*100);
|
|
|
|
|
|
self.mnd = std::cmp::max(std::cmp::max((self.mnd as i16) + feed_stats.mnd, 0) as u16, self.mind()*100);
|
|
|
|
|
|
|
|
|
self.def = {
|
|
|
|
|
|
if (self.def as i16 + feed_stats.def) < ((self.def()*100) as i16) {
|
|
|
|
|
|
self.def
|
|
|
|
|
|
} else {
|
|
|
|
|
|
std::cmp::max(std::cmp::max((self.def as i16) + feed_stats.def, 0) as u16, self.def()*100)
|
|
|
|
|
|
}};
|
|
|
|
|
|
self.pow = {
|
|
|
|
|
|
if (self.pow as i16 + feed_stats.pow) < ((self.pow()*100) as i16) {
|
|
|
|
|
|
self.pow
|
|
|
|
|
|
} else {
|
|
|
|
|
|
std::cmp::max(std::cmp::max((self.pow as i16) + feed_stats.pow, 0) as u16, self.pow()*100)
|
|
|
|
|
|
}};
|
|
|
|
|
|
self.dex = {
|
|
|
|
|
|
if (self.dex as i16 + feed_stats.dex) < ((self.dex()*100) as i16) {
|
|
|
|
|
|
self.dex
|
|
|
|
|
|
} else {
|
|
|
|
|
|
std::cmp::max(std::cmp::max((self.dex as i16) + feed_stats.dex, 0) as u16, self.dex()*100)
|
|
|
|
|
|
}};
|
|
|
|
|
|
self.mnd = {
|
|
|
|
|
|
if (self.mnd as i16 + feed_stats.mnd) < ((self.mind()*100) as i16) {
|
|
|
|
|
|
self.mnd
|
|
|
|
|
|
} else {
|
|
|
|
|
|
std::cmp::max(std::cmp::max((self.mnd as i16) + feed_stats.mnd, 0) as u16, self.mind()*100)
|
|
|
|
|
|
}};
|
|
|
self.iq = std::cmp::min(((self.iq as i16) + feed_stats.iq as i16) as u8, 200);
|
|
|
self.iq = std::cmp::min(((self.iq as i16) + feed_stats.iq as i16) as u8, 200);
|
|
|
self.synchro = std::cmp::min(((self.synchro as i8) + feed_stats.syn) as u8, 120);
|
|
|
self.synchro = std::cmp::min(((self.synchro as i8) + feed_stats.syn) as u8, 120);
|
|
|
})
|
|
|
})
|
|
@ -1188,7 +1208,7 @@ mod test { |
|
|
f.read_to_string(&mut s).unwrap();
|
|
|
f.read_to_string(&mut s).unwrap();
|
|
|
|
|
|
|
|
|
let mut feed: HashMap<String, Vec<HashMap<String, MagFeedTable>>> = toml::from_str(&s).unwrap();
|
|
|
let mut feed: HashMap<String, Vec<HashMap<String, MagFeedTable>>> = toml::from_str(&s).unwrap();
|
|
|
let feed = feed.remove("feedtable".into()).unwrap();
|
|
|
|
|
|
|
|
|
let feed = feed.remove("feedtable").unwrap();
|
|
|
let _feed = feed.into_iter()
|
|
|
let _feed = feed.into_iter()
|
|
|
.map(|table| {
|
|
|
.map(|table| {
|
|
|
table.into_iter()
|
|
|
table.into_iter()
|
|
@ -1219,7 +1239,7 @@ mod test { |
|
|
}
|
|
|
}
|
|
|
assert!(mag == Mag {
|
|
|
assert!(mag == Mag {
|
|
|
mag: MagType::Sato,
|
|
|
mag: MagType::Sato,
|
|
|
def: 507,
|
|
|
|
|
|
|
|
|
def: 509,
|
|
|
pow: 5019,
|
|
|
pow: 5019,
|
|
|
dex: 4505,
|
|
|
dex: 4505,
|
|
|
mnd: 0,
|
|
|
mnd: 0,
|
|
|