""" 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 . """ class Team(): """ A team of units. Very similar to the Teams class, but this one loads units, so it's not safe to have as property of Unit. Parameters ---------- id : str Team identifier. name : str Team name. priority : int Team priority, from 1 to 50. units : Unit[] """ _id = None _name = "" _priority = 1 _units = [] def __init__(self, id=None): if id != None: self._load(id) def _load(self, id): global conn cursor = conn.execute( "SELECT id, name, priority FROM teams WHERE id = ?", (id,) ) row = cursor.fetchone() if row != None: self._id = str(row[0]) self._name = str(row[1]) self._priority = int(row[2]) # Load units self._units = [] cursor = conn.execute( "SELECT unit FROM units_teams WHERE team = ?", (self._id,) ) rows = cursor.fetchall() for row in rows: self.units.append(Unit(str(row[0]))) @property def id(self): return self._id @property def name(self): return self._name @property def priority(self): return self._priority @property def units(self): return self._units