Example #1
0
def handle_get_battle_init_data(data):
    battle_data = data["battle"]
    battle_id = battle_data["battle_id"]
    battle_name = BATTLES.get(battle_id, "battle #" + battle_id)
    print "Entering {0}".format(battle_name)
    all_rounds_data = battle_data['rounds']
    tbl = [["rnd", "enemy", "drop"]]
    for round_data in all_rounds_data:
        round = round_data.get("round", "???")
        for round_drop in round_data["drop_item_list"]:
            tbl.append([round, "<round drop>", round_drop["type"]])
        for enemy in round_data["enemy"]:
            had_drop = False
            enemyname = get_display_name(enemy)
            for drop in get_drops(enemy):
                if "item_id" in drop:
                    kind = "orb id#" if drop["type"] == 51 else "equipment id#"
                    item = ITEMS.get(drop["item_id"], kind + drop["item_id"])
                    itemname = "{0}* {1}".format(drop.get("rarity", "1"), item)
                else:
                    itemname = "{0} gold".format(drop.get("amount", 0))
                had_drop = True
                tbl.append([round, enemyname, itemname])
            if not had_drop:
                tbl.append([round, enemyname, "nothing"])
    print tabulate(tbl, headers="firstrow")
    print ""
Example #2
0
def handle_get_battle_init_data(data):
    battle_data = data["battle"]
    battle_id = battle_data["battle_id"]
    battle_name = BATTLES.get(battle_id, "battle #" + battle_id)
    print "Entering {0}".format(battle_name)
    all_rounds_data = battle_data['rounds']
    tbl = [["rnd", "enemy", "drop"]]
    for round_data in all_rounds_data:
        round = round_data.get("round", "???")
        for round_drop in round_data["drop_item_list"]:
            item_type = int(round_drop.get("type", 0))
            if item_type == 21:
                itemname = "potion"
            elif item_type == 22:
                itemname = "hi-potion"
            elif item_type == 23:
                itemname = "x-potion"
            elif item_type == 31:
                itemname = "ether"
            elif item_type == 32:
                itemname = "turbo ether"
            else:
                itemname = "unknown"
            tbl.append([round, "<round drop>", itemname])
        for enemy in round_data["enemy"]:
            had_drop = False
            enemyname = get_display_name(enemy)
            for drop in get_drops(enemy):
                item_type = drop.get("type", 0)
                if item_type == 11:
                    itemname = "{0} gil".format(drop.get("amount", 0))
                elif item_type == 41 or item_type == 51:
                    type_name = "orb id#" if item_type == 51 else "equipment id#"
                    item = ITEMS.get(drop["item_id"], type_name + drop["item_id"])
                    itemname = "{0}* {1}".format(drop.get("rarity", 1), item)
                elif item_type == 61:
                    itemname = "event item"
                else:
                    itemname = "unknown"
                had_drop = True
                tbl.append([round, enemyname, itemname])
            if not had_drop:
                tbl.append([round, enemyname, "nothing"])
    print tabulate(tbl, headers="firstrow")
    print ""
def handle_get_battle_init_data(data):
    enemy_list = []
    ability_list = []
    soul_strike_list = []
    enemy_ability_list = []
    character_list = []
    copy = data
    pp = pprint.PrettyPrinter(indent=4)

    # if path.endswith("get_battle_init_data"):

    #         battle = data['battle']
    #         for buddy in battle['buddy']:
    #             for params in buddy['params']:
    #                 params['atk'] = 9999
    #                 params['acc'] = 9999
    #                 params['mdef'] = 9999
    #                 params['eva'] = 9999
    #                 params['spd'] = 9999
    #                 params['def'] = 9999

    #             for materia in buddy['materias']:
    #                 # makes Blue Moon Barrage proc 100% of the time
    #                 if materia['arg2'] == "30151111":
    #                     materia['arg1'] = "100"

    #                 # Blue Moon Barrage
    #                 # "materias": [
    #                 # {
    #                 #     "slot": 1, 
    #                 #     "arg1": "16", 
    #                 #     "arg2": "30151111", 
    #                 #     "arg3": "0", 
    #                 #     "arg4": "0", 
    #                 #     "arg5": "0", 
    #                 #     "effect_type": "13"
    #                 # }

    #         flow.response.content = json.dumps(data)

    # log data
    debug_path = os.getcwd() + "/data/raw/handle_get_battle_init_data/handle_get_battle_init_data_" + time.strftime("%m%d%Y-%H%M%S") + ".json" 
    test_file = open(debug_path, 'w')
    print >> test_file, json.dumps(data, indent=4, sort_keys=False)
    test_file.close()

    battle_data = data["battle"]
    battle_id = battle_data["battle_id"]
    battle_name = BATTLES.get(battle_id, "battle #" + battle_id)
    print ""
    print "Entering {0}".format(battle_name)
    all_rounds_data = battle_data['rounds']
    tbl = [["rnd", "enemy", "hp", "drop"]]
    for round_data in all_rounds_data:
        round = round_data.get("round", "???")
        for round_drop in round_data["drop_item_list"]:
            item_type = int(round_drop.get("type", 0))
            if item_type == 21:
                itemname = "potion"
            elif item_type == 22:
                itemname = "hi-potion"
            elif item_type == 23:
                itemname = "x-potion"
            elif item_type == 31:
                itemname = "ether"
            elif item_type == 32:
                itemname = "turbo ether"
            else:
                itemname = "unknown"
            tbl.append([round, "<round drop>","", itemname])
        for enemy in round_data["enemy"]:
            had_drop = False
            enemyname = get_display_name(enemy)
            enemyhp = get_enemy_hp(enemy)
            for drop in get_drops(enemy):
                item_type = drop.get("type", 0)
                if item_type == 11:
                    itemname = "{0} gil".format(drop.get("amount", 0))
                elif item_type == 41 or item_type == 51:
                    type_name = "orb id#" if item_type == 51 else "equipment id#"
                    item = ITEMS.get(drop["item_id"], type_name + drop["item_id"])
                    itemname = "{0}* {1}".format(drop.get("rarity", 1), item)
                elif item_type == 61:
                    itemname = "event item"
                else:
                    itemname = "unknown"
                had_drop = True
                tbl.append([round, enemyname, enemyhp, itemname])
            if not had_drop:
                tbl.append([round, enemyname, enemyhp, "nothing"])
            # for child in enemy["children"]

            enemy_list.append(enemy)
            # print enemy_list
            # pp.pprint(enemy_list)

    # print "enemy_list: " + str(len(enemy_list))
    print tabulate(tbl, headers="firstrow")
    print ""
    # print tabulate(tbl)

    save_enemy_stats(enemy_list, battle_id)

# fire/blizzard/thunder/dark/-ara/-aga/-aja
# arg1 = power multiplier
# arg2 = element 
# arg3 = ?
# arg4 = ?
# arg5 = ?

# elements
# 100 = fire
# 101 = ice
# 102 = thunder
# 103 = earth
# 104 = wind
# 105 = water
# 106 = holy(cure/a/aga/aja)
# 107 = dark
# 108 = poison


# "status_ailments_factor" = % chance to inflict status ailment
# "status_ailments_id" = ID for status ailment
# 200 = poison
# 201 = silence
# 202 = paralyze
# 203 = confuse
# 204 = haste
# 205 = slow
# 206 = stop
# 207 = protect
# 208 = shell
# 209 = reflect
# 210 = blind
# 211 = sleep
# 212 = stone/pretrify
# 213 = ? Doom ?
# 214 = instant KO (death)/gravity/cripple
# 215 = ? Berserk ?
# 216 = regen

# ### For "attribute_id": "1XX" ####

# "factor": "1" = this means that said enemy is weak to the element with that corresponding attribute_id
# "factor": "6" = this means that said enemy resists the corresponding element
# "factor": "11" = this means that said enemy nulls (takes zero damage from) the corresponding element
# "factor": "21" = this means that said enemy absorbs the corresponding element


# ### For "attribute_id": "2XX" ####
# "factor": "1" = with a factor of one and the attribute_id preset to "2XX", it means said enemy is immune to that debuff


    # ability data
    buddy_data = battle_data["buddy"]
    for buddy in buddy_data:
        for ability in buddy["abilities"]:
            ability_list.append(ability)
       

    # only need to save abilities when new ones come out or create the ones I don't have

    enemy_ability_data = battle_data["enemy_abilities"]
    for enemy_ability in enemy_ability_data:
        enemy_ability_list.append(enemy_ability)

    # print "\nsoul_stike_list:\n" 
    # # print soul_strike_list
    # for option in soul_strike_list["options"]:
    #     print option
    # print "\ncharacter_list:\n"
    # print character_list
    # print enemy_ability_list

    save_abilities(ability_list, "/data/abilities")
    # save_abilities(soul_strike_list, "/data/soul_strikes")
    save_abilities(enemy_ability_list, "/data/enemy_abilities")