Esempio n. 1
0
def create_weapon_stat(db_session, record, item):
    if not "weaponStats" in record:
        return
    db_session.query(ModelWeaponStat).filter_by(item_id=item.uuid).delete()

    weapon_stat = ModelWeaponStat(
        item_id=item.uuid,
        ap_cost=record["weaponStats"]["apCost"],
        uses_per_turn=record["weaponStats"]["usesPerTurn"],
        min_range=record["weaponStats"]["minRange"],
        max_range=record["weaponStats"]["maxRange"],
    )

    if record["weaponStats"]["baseCritChance"] > 0:
        weapon_stat.base_crit_chance = (record["weaponStats"]["baseCritChance"],)
        weapon_stat.crit_bonus_damage = (record["weaponStats"]["critBonusDamage"],)

    db_session.add(weapon_stat)
    db_session.flush()

    for effect in record["weaponStats"]["weapon_effects"]:
        weapon_effects = ModelWeaponEffect(
            weapon_stat_id=weapon_stat.uuid,
            effect_type=to_effect_enum[effect["stat"]],
            min_damage=effect["minStat"],
            max_damage=effect["maxStat"],
        )
        db_session.add(weapon_effects)
Esempio n. 2
0
                ap_cost=record["weaponStats"]["apCost"],
                uses_per_turn=record["weaponStats"]["usesPerTurn"],
                min_range=record["weaponStats"]["minRange"],
                max_range=record["weaponStats"]["maxRange"],
            )

            if record["weaponStats"]["baseCritChance"] > 0:
                weapon_stat.base_crit_chance = (
                    record["weaponStats"]["baseCritChance"], )
                weapon_stat.crit_bonus_damage = (
                    record["weaponStats"]["critBonusDamage"], )

            for effect in record["weaponStats"]["weapon_effects"]:
                weapon_effects = ModelWeaponEffect(
                    effect_type=to_effect_enum[effect["stat"]],
                    min_damage=effect["minStat"],
                    max_damage=effect["maxStat"],
                )
                weapon_stat.weapon_effects.append(weapon_effects)

            item.weapon_stats = weapon_stat

        db.session.commit()

    print("Adding pets to database")
    with open(os.path.join(app_root, "app/database/data/pets.json"),
              "r") as file:
        data = json.load(file)
        for record in data:
            item = ModelItem(
                dofus_db_id=record["dofusID"],