""" This file is part of RuneOptimizer. RuneOptimizer is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. RuneOptimizer is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with RuneOptimizer. If not, see . """ import math class StatSet(): """ A set of stats. It can be used as a set of stats a unit has in any given moment. Compound stats EHP and DMG can't be set manually and are calculated as the stats they depend on are set. Values are validated on setting and capped automatically. Note that the value caps don't take into acount material monsters, which have uniquely low stats. But if you are optimizing your Angelmon runes, I can't help you. Parameters ---------- hp : int Health points (HP) stat. Always equal or greater than 15. atk : int Attack stat. Always equal or greater than 1. dfc : int Defense stat. Always equal or greater than 1. spd : int Speed stat. Always equal or greater than 1. crr : int Critical rate stat. Between 15 and 100, both included. crd : int Critical damage stat. Always equal or greater than 50. res : int Resistance stat. Always equal or greater than 15. acc : int Accuracy stat. Between 0 and 85, both included. ehp : int Effective HP stat. Depends on HP and DEF. Always equal or greater than 1. dmg : int Damage stat. Depends on ATK, CRR and CRD. Always equal or greater than 1. """ _hp = 0 _atk = 0 _dfc = 0 _spd = 0 _crr = 0 _crd = 0 _res = 0 _acc = 0 _ehp = 0 _dmg = 0 def __init__(self): pass @property def hp(self): return self._hp @hp.setter def hp(self, value): value = int(value) if value < 1: value = 1; self._hp = value self._calculate_ehp() @property def atk(self): return self._atk @atk.setter def atk(self, value): value = int(value) if value < 1: value = 1; self._atk = value self._calculate_dmg() @property def dfc(self): return self._dfc @dfc.setter def dfc(self, value): value = int(value) if value < 1: value = 1; self._dfc = value self._calculate_ehp() @property def spd(self): return self._spd @spd.setter def spd(self, value): value = int(value) if value < 1: value = 1; self._spd = value @property def crr(self): return self._crr @crr.setter def crr(self, value): value = int(value) if value < 15: value = 15; if value > 100: value = 100 self._crr = value self._calculate_dmg() @property def crd(self): return self._crd @crd.setter def crd(self, value): value = int(value) if value < 50: value = 50; self._crd = value self._calculate_dmg() @property def res(self): return self._res @res.setter def res(self, value): value = int(value) if value < 15: value = 15; if value > 100: value = 100 self._res = value @property def acc(self): return self._acc @acc.setter def acc(self, value): value = int(value) if value < 15: value = 15; if value > 85: value = 85 self._acc = value @property def ehp(self): return self._ehp @property def dmg(self): return self._dmg def _calculate_ehp(self): """ Recalculates _ehp. Uses _dfc and _hp, and it is called from automatically from their setters. """ self._ehp = math.ceil((((self._dfc * 3.5) + 1140) * self._hp) / 1000) def _calculate_dmg(self): """ Recalculates _dmg. Uses _atk, _crr and _crd, and it is called from automatically from their setters. """ self._dmg = math.ceil( #Non-crit + crit (self._atk * (100 - self._crr) / 100) + (self._atk * ( self._crr / 100) * (self._crd + 100) / 100) ) def values(self): """ Gets all stats as an array. The order is: HP, ATK, DFC, SPD, CRR, CRD, RES, ACC, EHP, DMG """ return [ self._hp, self._atk, self._dfc, self._spd, self._crr, self._crd, self._res, self._acc, self._ehp, self._dmg ]