Exemplo n.º 1
0
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
Exemplo n.º 2
0
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
Exemplo n.º 3
0
class Floor(db.Model):

    __tablename__ = "floor"

    id = db.Column(db.Integer, primary_key=True)
    number = db.Column(db.Integer)

    dungeon_id = db.Column(db.Integer, db.ForeignKey("dungeon.id"))
    dungeon = db.relationship("Dungeon",
                              backref=backref("floors",
                                              order_by="Floor.number"),
                              foreign_keys="Floor.dungeon_id")

    def __init__(self, number):
        self.number = number

    def dictify(self):
        dictified = OrderedDict()
        dictified["floor_number"] = self.number
        dictified["encounter"] = [
            monster.dictify() for monster in self.encounters
        ]
        dictified["memos"] = [floor.memo for floor in self.floor_memos]

        return dictified
Exemplo n.º 4
0
class Drop(db.Model):
    __tablename__ = "monster_drop"

    id = db.Column(db.Integer, primary_key=True)
    chance = db.Column(db.Integer)

    enemy_monster_id = db.Column(db.Integer, db.ForeignKey("enemy_monster.id"))
    enemy_monster = db.relationship("EnemyMonster",
                                    backref="drops",
                                    foreign_keys="Drop.enemy_monster_id")

    monster_id = db.Column(db.Integer, db.ForeignKey("monster.id"))
    monster = db.relationship("Monster",
                              backref="drops",
                              foreign_keys="Drop.monster_id")

    def __init__(self, chance=None):
        self.chance = chance
Exemplo n.º 5
0
class Evolution(db.Model):

    __tablename__ = "evolution"

    id = db.Column(db.Integer, primary_key=True)

    from_monster_id = db.Column(db.Integer, db.ForeignKey("monster.id"))
    from_monster = db.relationship("Monster",
                                   backref="evolves_from",
                                   foreign_keys="Evolution.from_monster_id")

    current_monster_id = db.Column(db.Integer,
                                   db.ForeignKey("monster.id"),
                                   nullable=False)
    current_monster = db.relationship(
        "Monster",
        backref="current_evolution",
        foreign_keys="Evolution.current_monster_id")

    to_monster_id = db.Column(db.Integer, db.ForeignKey("monster.id"))
    to_monster = db.relationship("Monster",
                                 backref=backref("evolves_to", uselist=False),
                                 foreign_keys="Evolution.to_monster_id")

    required_materials = db.relationship(
        "Monster",
        secondary=required_materials_evolution_n,
        backref="material_for_evolution")

    def __init__(self):
        pass

    def __str__(self):
        return str(self.dictify())

    def dictify(self):
        dictified = OrderedDict()
        dictified["id"] = self.id
        dictified["from_monster"] = self.from_monster_id
        dictified["current_monster"] = self.current_monster_id
        dictified["to_monster"] = self.to_monster_id

        return dictified
Exemplo n.º 6
0
class Task(_Task):
    __table_args__ = {"useexisting": True}
    project_id = db.Column(db.Integer,
                           db.ForeignKey("project.id"),
                           nullable=False,
                           server_default=db.FetchedValue())
    project = db.relationship('app.model.project.Project')

    @property
    def project_name(self):
        return self.project.name if self.project else None
Exemplo n.º 7
0
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}
Exemplo n.º 8
0
    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


enemy_move_move_type_n = db.Table(
    "enemy_move_move_type_n", db.Column("id", db.Integer, primary_key=True),
    db.Column("enemy_move_id", db.ForeignKey("enemy_move.id")),
    db.Column("enemy_move_type_id", db.ForeignKey("enemy_move_type.id")))


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",
Exemplo n.º 9
0
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
Exemplo n.º 10
0
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
Exemplo n.º 11
0
        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


awoken_skill_monster_n = db.Table(
    "awoken_skill_monster_n", db.Column("id", db.Integer, primary_key=True),
    db.Column("awoken_skill_id", db.ForeignKey("awoken_skill.id")),
    db.Column("monster_id", db.ForeignKey("monster.id")))


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)