class EnemySkill(db.Model): __tablename__ = "enemy_skill" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) effect = db.Column(db.String(256)) def __init__(self, id, name, effect): self.id = id self.name = name self.effect = effect def __str__(self): return str(self.dictify(thinify=False)) def dictify(self, thinify=True): dictified = OrderedDict() dictified["name"] = self.name dictified["effect"] = self.effect if not thinify: dictified["part_of_moves"] = [ move.id for move in self.part_of_moves ] return dictified
class LeaderSkill(db.Model): __tablename__ = "leader_skill" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) effect = db.Column(db.String(512), nullable=False) original_effect = db.Column(db.String(256), nullable=False) def __init__(self, id, name, effect, original_effect): self.id = id self.name = name self.effect = effect self.original_effect = original_effect def __str__(self): return "\nID: " + str(self.id) + \ "\nName: " + self.name + \ "\nEffect: " + self.effect + \ "\nOriginal Effect: " + self.original_effect def dictify(self, thinify=True): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name dictified["effect"] = self.effect dictified["original_effect"] = self.original_effect if not thinify: dictified["owned_by_monsters"] = [monster.id for monster in self.owned_by_monsters] return dictified
class AwokenSkill(db.Model): __tablename__ = "awoken_skill" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) description = db.Column(db.String(256), nullable=False) img = db.Column(db.String(128), nullable=False) def __init__(self, id, name, description, img): self.id = id self.name = name self.description = description self.img = img def __str__(self): return "\nID: " + str(self.id) + \ "\nName: " + self.name + \ "\nEffect: " + self.description + \ "\nImg: " + self.img + \ "\nMonsters: " + str(self.owned_by_monsters) def dictify(self, thinify=True): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name dictified["description"] = self.description dictified["img"] = self.img if not thinify: dictified["owned_by_monsters"] = [ monster.id for monster in self.owned_by_monsters ] return dictified
class Element(db.Model): __tablename__ = "element" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), unique=True, nullable=False) def __init__(self, id, name): self.id = id self.name = name def __str__(self): return "\nID: " + str(self.id) + \ "\nName: " + str(self.name) def dictify(self, thinify=True): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name if not thinify: dictified["primary_element_owned_by"] = [ monster.id for monster in self.primary_element_owned_by_monsters ] dictified["secondary_element_owned_by"] = [ monster.id for monster in self.secondary_element_owned_by_monsters ] return dictified
class Dungeon(db.Model): __tablename__ = "dungeon" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) def __init__(self, id, name): self.id = id self.name = name def __str__(self): return str(self.dictify()) def dictify(self): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name dictified["random_encounters"] = [ random_encounter.dictify() for random_encounter in self.random_encounters ] dictified["major_floors"] = [floor.dictify() for floor in self.floors] return dictified
class EnemyMonster(db.Model): __tablename__ = "enemy_monster" id = db.Column(db.Integer, primary_key=True) hp = db.Column(db.Integer) atk = db.Column(db.Integer) defn = db.Column(db.Integer, nullable=False) turn = db.Column(db.Integer) quantity = db.Column(db.Integer) memo = db.Column(db.String(512)) common_monster_id = db.Column(db.Integer, db.ForeignKey("common_monster.id"), nullable=False) common_monster = db.relationship( "CommonMonster", backref="enemy_monsters", foreign_keys="EnemyMonster.common_monster_id") random_encounter_in_dungeon_id = db.Column(db.Integer, db.ForeignKey("dungeon.id")) random_encounter_in_dungeon = db.relationship( "Dungeon", backref="random_encounters", foreign_keys="EnemyMonster.random_encounter_in_dungeon_id") major_encounter_on_floor_id = db.Column(db.Integer, db.ForeignKey("floor.id")) major_encounter_on_floor = db.relationship( "Floor", backref="encounters", foreign_keys="EnemyMonster.major_encounter_on_floor_id") def __init__(self, hp, atk, defn, turn, quantity=None): self.hp = hp self.atk = atk self.defn = defn self.quantity = quantity self.turn = turn def __str__(self): return str(self.dictify()) def encounter_in_dungeon(self): return self.random_encounter_in_dungeon if self.random_encounter_in_dungeon_id != None else self.major_encounter_on_floor.dungeon def dictify(self): dictified = OrderedDict() dictified["common_id"] = self.common_monster_id dictified["name"] = self.common_monster.name dictified["hit_points"] = self.hp dictified["attack"] = self.atk dictified["defense"] = self.defn dictified["turn"] = self.turn dictified["quantity"] = self.quantity dictified["drop"] = [drop.monster_id for drop in self.drops] dictified["moves"] = [move.dictify() for move in self.moves] return dictified
class MonsterSeries(db.Model): __tablename__ = "monster_series" id = db.Column(db.Integer, primary_key=True, autoincrement=False) name = db.Column(db.String(80), nullable=False, unique=True) def __init__(self, id, name): self.id = id self.name = name def __str__(self): return "\nID: " + str(self.id) + \ "\nName: " + self.name def dictify(self, thinify=True): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name if not thinify: dictified["monsters_in_series"] = [ monster.id for monster in self.monsters_in_series ] return dictified
class EnemyMoveType(db.Model): __tablename___ = "enemy_move_type" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) img = db.Column(db.String(128)) def __init__(self, id, name, img=None, description=None): self.id = id self.name = name self.img = img def dictify(self, thinify=True): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name dictified["img"] = self.img
class EnemyMove(db.Model): __tablename__ = "enemy_move" id = db.Column(db.Integer, primary_key=True) atk = db.Column(db.Integer) atk_condition = db.Column(db.String(128)) # enemy_monster_id = db.Column(db.Integer, db.ForeignKey("enemy_monster.id"), nullable=False) enemy_monster_id = db.Column(db.Integer, db.ForeignKey("enemy_monster.id")) enemy_monster = db.relationship("EnemyMonster", backref="moves", foreign_keys="EnemyMove.enemy_monster_id") enemy_skill_id = db.Column(db.Integer, db.ForeignKey("enemy_skill.id"), nullable=False) enemy_skill = db.relationship("EnemySkill", backref="part_of_moves", foreign_keys="EnemyMove.enemy_skill_id") enemy_move_types = db.relationship("EnemyMoveType", secondary=enemy_move_move_type_n, backref="part_of_moves") def __init__(self, atk_condition, atk=None): self.atk = atk self.atk_condition = atk_condition def __str__(self): return "\nMove Information:" + \ "\nM_ID: " + str(self.id) + \ "\nATK: " + str(self.atk) + \ "\nATK Condition: " + str(self.atk_condition) + \ "\nFK.S_ID: " + str(self.enemy_skill_id) + \ "\nEnemy Skill: " + str(self.enemy_skill) def dictify(self): dictified = OrderedDict() dictified["name"] = self.enemy_skill.name dictified["attack"] = self.atk dictified["attack_condition"] = self.atk_condition dictified["effect"] = self.enemy_skill.effect dictified["move_types"] = [ move_type.id for move_type in self.enemy_move_types ] return dictified
class FloorMemo(db.Model): __tablename__ = "floor_memo" id = db.Column(db.Integer, primary_key=True) memo = db.Column(db.String(512)) floor_id = db.Column(db.Integer, db.ForeignKey("floor.id")) floor = db.relationship("Floor", backref="floor_memos", foreign_keys="FloorMemo.floor_id") def __init__(self, memo): self.memo = memo def dictify(self): return {"memo": self.memo}
class ActiveSkill(db.Model): __tablename__ = "active_skill" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) effect = db.Column(db.String(256), nullable=False) original_effect = db.Column(db.String(256), nullable=False) max_cd = db.Column(db.String(80)) min_cd = db.Column(db.String(80)) max_lvl = db.Column(db.String(80)) def __init__(self, id, name, effect, original_effect, max_cd, min_cd, max_lvl): self.id = id self.name = name self.effect = effect self.original_effect = original_effect self.max_cd = max_cd self.min_cd = min_cd self.max_lvl = max_lvl def __str__(self): return str(self.dictify(thinify=False)) def dictify(self, thinify=True): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name dictified["effect"] = self.original_effect dictified["max_cd"] = self.max_cd dictified["min_cd"] = self.min_cd dictified["max_lvl"] = self.max_lvl if not thinify: dictified["owned_by_monsters"] = [ monster.id for monster in self.owned_by_monsters ] return dictified
class Monster(db.Model): __tablename__ = "monster" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) rarity = db.Column(db.Integer, nullable=False) team_cost = db.Column(db.Integer, nullable=False) sells_for_monster_points = db.Column(db.Integer, nullable=False) min_lvl = db.Column(db.Integer, nullable=False) max_lvl = db.Column(db.Integer, nullable=False) min_hp = db.Column(db.Integer, nullable=False) max_hp = db.Column(db.Integer, nullable=False) min_atk = db.Column(db.Integer, nullable=False) max_atk = db.Column(db.Integer, nullable=False) min_rcv = db.Column(db.Integer, nullable=False) max_rcv = db.Column(db.Integer, nullable=False) min_sell_value = db.Column(db.Integer, nullable=False) max_sell_value = db.Column(db.Integer, nullable=False) min_exp_feed = db.Column(db.Integer, nullable=False) max_exp_feed = db.Column(db.Integer, nullable=False) exp_needed = db.Column(db.Integer, nullable=False) monster_series_id = db.Column(db.Integer, db.ForeignKey("monster_series.id")) monster_series = db.relationship("MonsterSeries", backref="monsters_in_series", foreign_keys="Monster.monster_series_id") active_skill_id = db.Column(db.Integer, db.ForeignKey("active_skill.id")) active_skill = db.relationship("ActiveSkill", backref="owned_by_monsters", foreign_keys="Monster.active_skill_id") leader_skill_id = db.Column(db.Integer, db.ForeignKey("leader_skill.id")) leader_skill = db.relationship("LeaderSkill", backref="owned_by_monsters", foreign_keys="Monster.leader_skill_id") awoken_skills = db.relationship("AwokenSkill", secondary=awoken_skill_monster_n, backref="owned_by_monsters") def __init__(self, id, name, rarity, team_cost, sells_for_monster_points, min_lvl, max_lvl, \ min_hp, max_hp, min_atk, max_atk, min_rcv, max_rcv, min_sell_value, max_sell_value, \ min_exp_feed, max_exp_feed, exp_needed): self.id = id self.name = name self.rarity = rarity self.team_cost = team_cost self.sells_for_monster_points = sells_for_monster_points self.min_lvl = min_lvl self.max_lvl = max_lvl self.min_hp = min_hp self.max_hp = max_hp self.min_atk = min_atk self.max_atk = max_atk self.min_rcv = min_rcv self.max_rcv = max_rcv self.min_sell_value = min_sell_value self.max_sell_value = max_sell_value self.min_exp_feed = min_exp_feed self.max_exp_feed = max_exp_feed self.exp_needed = exp_needed def __str__(self): return str(self.dictify()) def dictify(self): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name dictified["rarity"] = self.rarity dictified["primary_type"] = self.common_monster.primary_type_id dictified["secondary_type"] = self.common_monster.secondary_type_id dictified["ternary_type"] = self.common_monster.ternary_type_id dictified["primary_element"] = self.common_monster.primary_element_id dictified[ "secondary_element"] = self.common_monster.secondary_element_id dictified["team_cost"] = self.team_cost dictified["sells_for_monster_points"] = self.sells_for_monster_points dictified["min_lvl"] = self.min_lvl dictified["max_lvl"] = self.max_lvl dictified["min_hp"] = self.min_hp dictified["max_hp"] = self.max_hp dictified["min_atk"] = self.min_atk dictified["max_atk"] = self.max_atk dictified["min_rcv"] = self.min_rcv dictified["max_rcv"] = self.max_rcv dictified["min_sell_value"] = self.min_sell_value dictified["max_sell_value"] = self.max_sell_value dictified["min_exp_feed"] = self.min_exp_feed dictified["max_exp_feed"] = self.max_exp_feed dictified["exp_needed"] = self.exp_needed # Iterate through all the evolution chains the current monster is a part of and add the monsters it can evolve to dictified["evolves_to"] = [ evolution.to_monster_id for evolution in self.current_evolution if evolution.to_monster_id != None ] # If the current monster doesn't evolve from any monster use None, otherwise find the monster it evolves from dictified[ "evolves_from"] = self.evolves_to.current_monster_id if self.evolves_to != None else None dictified["evolution_chain"] = [ evolution.id for evolution in self.current_evolution ] dictified["monster_series"] = self.monster_series.id dictified["active_skill"] = self.active_skill_id dictified["leader_skill"] = self.leader_skill_id dictified["awoken_skills"] = [ awoken_skill_monster_link.awoken_skill_id for awoken_skill_monster_link in db.session.query( awoken_skill_monster_n).filter_by(monster_id=self.id).all() ] dictified["dropped_in_dungeons"] = [ drop.enemy_monster.encounter_in_dungeon().id for drop in self.drops ] dictified["img"] = "Not available" dictified["thmb"] = "Not available" return dictified
class CommonMonster(db.Model): __tablename__ = "common_monster" id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) img = db.Column(db.String(128), nullable=False, unique=True) thmb = db.Column(db.String(128), nullable=False, unique=True) primary_type_id = db.Column(db.Integer, db.ForeignKey("type.id"), nullable=False) primary_type = db.relationship( "Type", backref="primary_type_owned_by_monsters", foreign_keys="CommonMonster.primary_type_id") secondary_type_id = db.Column(db.Integer, db.ForeignKey("type.id")) secondary_type = db.relationship( "Type", backref="secondary_type_owned_by_monsters", foreign_keys="CommonMonster.secondary_type_id") ternary_type_id = db.Column(db.Integer, db.ForeignKey("type.id")) ternary_type = db.relationship( "Type", backref="ternary_type_owned_by_monsters", foreign_keys="CommonMonster.ternary_type_id") primary_element_id = db.Column(db.Integer, db.ForeignKey("element.id"), nullable=False) primary_element = db.relationship( "Element", backref="primary_element_owned_by_monsters", foreign_keys="CommonMonster.primary_element_id") secondary_element_id = db.Column(db.Integer, db.ForeignKey("element.id")) secondary_element = db.relationship( "Element", backref="secondary_element_owned_by_monsters", foreign_keys="CommonMonster.secondary_element_id") monster_id = db.Column(db.Integer, db.ForeignKey("monster.id"), nullable=False) monster = db.relationship("Monster", backref=backref("common_monster", uselist=False)) def __init__(self, id, name, img, thmb): self.id = id self.name = name self.img = img self.thmb = thmb def __str__(self): return str(self.dictify()) def dictify(self): dictified = OrderedDict() dictified["id"] = self.id dictified["name"] = self.name dictified["img"] = self.img dictified["thmb"] = self.thmb dictified["primary_type"] = self.primary_type_id dictified["secondary_type"] = self.secondary_type_id dictified["ternary_type"] = self.ternary_type_id dictified["primary_element"] = self.primary_element_id dictified["secondary_element"] = self.secondary_element_id dictified["monster"] = self.monster_id return dictified