Пример #1
0
def handle_party_list(data):
    wanted = "name series_id acc atk def eva matk mdef mnd series_acc series_atk series_def series_eva series_matk series_mdef series_mnd"
    topn = OrderedDict()
    topn["atk"] = 5
    topn["matk"] = 2
    topn["mnd"] = 2
    topn["def"] = 5
    find_series = [101001, 102001, 104001, 105001, 106001, 107001, 108001, 110001]
    equips = defaultdict(list)
    for item in data["equipments"]:
        kind = item.get("equipment_type", 1)
        heapq.heappush(equips[kind], Equipment(slicedict(item, wanted)))

    for series in find_series:
        print "Best equipment for FF{0}:".format((series - 100001) / 1000)

        # Need to use lists for column ordering
        tbl = ["stat n weapon stat n armor stat n accessory".split()]
        tbldata = [[],[],[],[]]
        for itemtype in range(1, 4): ## 1, 2, 3
            for stat, count in topn.iteritems():
                for equip in best_equipment(series, equips[itemtype], stat, count):
                    name = equip["name"].replace(u"\uff0b", "+")
                    tbldata[itemtype].append([stat, equip[stat], name])

        # Transpose data
        for idx in range(0, len(tbldata[1])):
            tbl.append(tbldata[1][idx] + tbldata[2][idx] + tbldata[3][idx])
        print tabulate(tbl, headers="firstrow")
        print ""
Пример #2
0
def handle_party_list(data):

    # log data
    debug_path = os.getcwd() + "/data/raw/handle_party_list/handle_party_list_" + 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()

    wanted = "name series_id acc atk def eva matk mdef mnd series_acc series_atk series_def series_eva series_matk series_mdef series_mnd"
    topn = OrderedDict()
    topn["atk"] = 5
    topn["matk"] = 5
    topn["mnd"] = 3
    topn["def"] = 5
    topn["mdef"] = 3
    find_series = [200001, 101001, 102001, 103001, 104001, 105001, 106001, 107001, 108001, 109001, 110001, 112001, 113001]
    equips = defaultdict(list)
    for item in data["equipments"]:
        kind = item.get("equipment_type", 1)
        heapq.heappush(equips[kind], Equipment(slicedict(item, wanted)))

    # uncomment this to see best equipment for each realm
    # for series in find_series:
    #     if series == 200001:
    #         print "Best equipment for FF Core"
    #     else:
    #         print "Best equipment for FF{0}:".format((series - 100001) / 1000)

    #     # Need to use lists for column ordering
    #     tbl = ["stat n weapon stat n armor stat n accessory".split()]
    #     tbldata = [[],[],[],[]]
    #     for itemtype in range(1, 4): ## 1, 2, 3
    #         for stat, count in topn.iteritems():
    #             for equip in best_equipment(series, equips[itemtype], stat, count):
    #                 name = equip["name"].replace(u"\uff0b", "+")
    #                 tbldata[itemtype].append([stat, equip[stat], name])

    #     # Transpose data
    #     for idx in range(0, len(tbldata[1])):
    #         tbl.append(tbldata[1][idx] + tbldata[2][idx] + tbldata[3][idx])
    #     print tabulate(tbl, headers="firstrow")
    #     print ""


### NO LONGER NEEDED ###
    # print equipment to json file
    # save_equipment_list(data, get_user_id(data))
    # save_equipment(data)

    get_buddy_info(data)
    temp_party_list = data