use crate::enums::*;
use crate::models::car::*;
#[derive(Debug)]
pub struct Sprite{
pub number: u8,
pub name: String,
pub property: String,
pub race_value_sum: u16,
pub race: Six
}
#[derive(Debug)]
pub struct Six {
pub hp: f32,
pub atk: f32,
pub dfe: f32,
pub m_atk: f32,
pub m_dfe: f32,
pub spd: f32,
}
#[derive(Debug)]
pub struct Tri{
pub car: Car, pub rac: Six, pub ind: Vec<(Panel, f32)>,
}
impl Tri {
pub fn new(car: Car, rac: Six, ind: Vec<(Panel, f32)>) -> Self {
Self {
car,
rac,
ind,
}
}
pub fn cor(&mut self) {
self.rac_cor();
self.ind_cor();
self.car_cor();
self.con_cor();
}
fn rac_cor(&mut self) {
macro_rules! apply_to_all {
( $($field:ident),* ) => {
$(
self.rac.$field = 1.1 * self.rac.$field + 10.0;
)*
};
}
self.rac.hp = 1.7 * self.rac.hp + 70.0;
apply_to_all!(atk, dfe, m_atk, m_dfe, spd);
}
fn ind_cor(&mut self) {
for (ind_type, value) in &self.ind {
match ind_type {
Panel::Hp => self.rac.hp += value * 6.0 * 0.85,
Panel::Atk => self.rac.atk += value * 6.0 * 0.55,
Panel::MAtk => self.rac.m_atk += value * 6.0 * 0.55,
Panel::Dfe => self.rac.dfe += value * 6.0 * 0.55,
Panel::MDfe => self.rac.m_dfe += value * 6.0 * 0.55,
Panel::Spd => self.rac.spd += value * 6.0 * 0.55,
}
}
}
fn car_cor(&mut self) {
let keys = get_key(&self.car);
{
let plus = get_field_mut(&mut self.rac, keys[0]);
if let Some(p) = plus {
*p *= 1.2;
}
}
let sub = get_field_mut(&mut self.rac, keys[1]);
if let Some(s) = sub {
*s *= 0.9;
}
}
fn con_cor(&mut self) {
macro_rules! apply_to_all {
( $($field:ident),* ) => {
$(
self.rac.$field += 50.0;
)*
};
}
self.rac.hp += 100.0;
apply_to_all!(atk, dfe, m_atk, m_dfe, spd);
}
}
#[derive(Debug)]
pub struct Sfor {
pub atk: f32,
pub dfe: f32,
pub pow: f32,
}
impl Sfor {
pub fn simple_dmg(&self) -> f32 {
let dmg = (37.0 * self.atk * self.pow / 41.0).round() / self.dfe;
return dmg;
}
}
#[derive(Debug)]
pub struct Cfor {
pub atk: f32, pub dfe: f32, pub pow: f32, pub deal: f32, pub pow_appd: f32, pub atk_buff: f32, pub dfe_buff: f32, pub pow_buff: f32, pub prop: f32, pub count: f32, pub reduce: f32, }
impl Cfor {
pub fn new(atk: f32, dfe:f32, pow:f32) -> Self {
Self {
atk,
dfe,
pow,
deal: 1.0,
pow_appd: 0.0,
atk_buff: 1.0,
dfe_buff: 1.0,
pow_buff: 1.0,
prop: 1.0,
count: 1.0,
reduce: 0.0,
}
}
pub fn cal(&self) -> f32 {
(37.0 * (self.atk * self.atk_buff) * (self.pow * self.deal + self.pow_appd) * self.pow_buff * self.prop * self.count * (1.0 - self.reduce)).round() / 41.0 / (self.dfe * self.dfe_buff)
}
}