| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- """
- 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 <https://www.gnu.org/licenses/>.
- """
- class Unit():
- """
- A unit.
- Parameters
- ----------
- id : str
- Unit identifier.
- name : str
- Unit name. For Homunculus, the given name.
- stars : int
- Unit grade,from 1 to 6.
- level : int
- Unit level, from 1 to 40.
- in_storage : bool
- Indicates if the unit is in storage
- base_stats : StatSet
- Unit base stats, without runes, artifacts or bonus towers.
- stats : StatSet
- Unit base stats, with runes but without artifacts or bonus towers.
- has_runes : bool
- Indicates if the unit has any runes equiped.
- team_ids : str[]
- List of IDs of the team the unit is on.
- in_teams : bool
- Indicates if the unit is in any team.
- priority : int
- Unit priority.
- Methods
- -------
- populateUnitList(event)
- Populates the unit list.
- goToOptimizer(event)
- Prepares the optimizer panel with the selected unit and redirects.
- unitSelected(event)
- Loads a unit info.
- processResults(jsonData)
- Processes data obtained from RuneOptimizer.
- """
-
- _id = None
- _name = ""
- _stars = 1
- _level = 1
- _in_storage = False
- _base_stats = StatSet()
- _stats = StatSet()
- _runes = [None, None, None, None, None, None]
- _has_runes = False
- _teams = []
- _in_teams = False
- _priority = 0
- def __init__(self, id=None):
- if id != None:
- self._load(id)
-
- def _load(self, id):
- cursor = conn.execute("""
- SELECT
- id, -- 0
- name,
- stars,
- level,
- storage,
- base_hp, -- 5
- base_atk,
- base_def,
- base_spd,
- base_crr,
- base_crd, -- 10
- base_res,
- base_acc,
- current_hp,
- current_atk,
- current_def, --15
- current_spd,
- current_crr,
- current_crd,
- current_res,
- current_acc --20
- FROM units
- WHERE
- id = ?;
- """, (id,))
- row = cursor.fetchone()
- if row != None:
- self._base_stats = StatSet()
- self._stats = StatSet()
- self._id = str(row[0])
- self._name = str(row[1])
- self._stars = int(row[2])
- self._level = int(row[3])
- if int(row[4]) == 1:
- self._storage = True
- else:
- self._storage = False
- self._base_stats.hp = int(row[5])
- #print("BASE HP FOR " + self._name + ": " + str(self._base_stats.hp))
- self._base_stats.atk = int(row[6])
- self._base_stats.dfc = int(row[7])
- self._base_stats.spd = int(row[8])
- self._base_stats.crr = int(row[9])
- self._base_stats.crd = int(row[10])
- self._base_stats.res = int(row[11])
- self._base_stats.acc = int(row[12])
- self._stats.hp = int(row[13])
- self._stats.atk = int(row[14])
- self._stats.dfc = int(row[15])
- self._stats.spd = int(row[16])
- self._stats.crr = int(row[17])
- self._stats.crd = int(row[18])
- self._stats.res = int(row[19])
- self._stats.acc = int(row[20])
-
- # Get runes
- self._runes = [None, None, None, None, None, None]
- cursor = conn.execute(
- "SELECT id, slot FROM runes WHERE unit = ?", (self._id,)
- )
- rows = cursor.fetchall()
- for row in rows:
- self._runes[int(row[1]) - 1] = Rune(str(row[0]))
- self._has_runes = True
-
- # Get teams
- self._teams = []
- cursor = conn.execute(
- "SELECT DISTINCT team FROM units_teams WHERE unit = ?",
- (self._id,)
- )
- rows = cursor.fetchall()
- for row in rows:
- team = UnitTeam(str(row[0]))
- self._priority += team.priority
- self._teams.append(team)
- self._in_teams = True
- @property
- def id(self):
- return self._id
-
- @property
- def name(self):
- return self._name
-
- @property
- def stars(self):
- return self._stars
-
- @property
- def level(self):
- return self._level
-
- @property
- def in_storage(self):
- return self._in_storage
-
- @property
- def base_stats(self):
- return self._base_stats
- @property
- def stats(self):
- return self._stats
-
- @property
- def runes(self):
- return self._runes
-
- @property
- def has_runes(self):
- return self._has_runes
-
- @property
- def teams(self):
- return self._teams
-
- @property
- def in_teams(self):
- return self._in_teams
-
- @property
- def priority(self):
- return self._priority
|