def migrate(meta, version, target_version): if version == "0.02a" and version != target_version: for q in session["quests"]: if not q["complete"]: q["completedTasks"] = 0 print("Reset quest completion") handle_quest_progress( meta, lambda task, progress, i, extra, *args: zero_yield(extra)) session['user_object']["userInfo"]["player"]["expansions"]["data"] = [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] unlock_expansion(156) unlock_expansion(157) unlock_expansion(181) unlock_expansion(182) unlock_expansion(206) unlock_expansion(207) version = "0.03a" session['save_version'] = version if version == "0.03a" and version != target_version: create_backup("Update to 0.04a") version = "0.04a" session['save_version'] = version if version == "0.04a" and version != target_version: create_backup("Update to 0.05a") version = "0.05a" session['save_version'] = version if version == "0.05a" and version != target_version: # upcoming 0.06 # create_backup("Update to 0.06a") # for release # version = "0.06a" # session['user_object']["experiments"]["empire_decorations_master"] = 2
def migrate(meta, version, target_version): if version == "0.02a" and version != target_version: for q in session["quests"]: if not q["complete"]: q["completedTasks"] = 0 print("Reset quest completion") handle_quest_progress(meta, lambda task, progress, i, extra, *args: zero_yield(extra)) session['user_object']["userInfo"]["player"]["expansions"]["data"] = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] unlock_expansion(156) unlock_expansion(157) unlock_expansion(181) unlock_expansion(182) unlock_expansion(206) unlock_expansion(207) version = "0.03a" session['save_version'] = version if version == "0.03a" and version != target_version: create_backup("Update to 0.04a") version = "0.04a" session['save_version'] = version if version == "0.04a" and version != target_version: create_backup("Update to 0.05a") version = "0.05a" session['save_version'] = version if version and version.startswith("0.05a") and version != target_version: # 0.06 create_backup("Update to 0.06a") version = "0.06a" govt_fixer() session['user_object']["experiments"]["empire_decorations_master"] = 2 session['user_object']["experiments"]["empire_doober_pickup"] = 3 session['user_object']["experiments"]["empires_consumable_2"] = 3 session['user_object']["experiments"]["empire_research_shield_upgrade"] = 2 session['user_object']["experiments"]["empires_support_units"] = 5 session['user_object']["experiments"]["empire_buildable_zrig_master"] = 3 session['save_version'] = version if version and version.startswith("0.06a") and version != target_version: # 0.07 create_backup("Update to 0.07a") version = "0.07a" session['save_version'] = version if version and version.startswith("0.07a") and version != target_version: # upcoming 0.08 # create_backup("Update to 0.07a") # for release pass
def do_state_rewards(state, reference_item, meta, playback_tend=False): player = session['user_object']["userInfo"]["player"] player['xp'] += int(state.get('-xp', 0)) energy = int(state.get('-energy', 0)) if playback_tend: energy = max(energy, 0); player['energy'] += energy player['cash'] += int(state.get('-cash', 0)) player['socialXpGood'] += int(state.get('-socialXpGood', 0)) player['socialXpBad'] += int(state.get('-socialXpBad', 0)) if str(state.get('-elementZ',0)) != '0': if not state.get('-elementZ',0) in player["inventory"]["items"]: player["inventory"]["items"][state.get('-elementZ',0)] = 1 else: player["inventory"]["items"][state.get('-elementZ', 0)] +=1 world = session['user_object']["userInfo"]["world"] resources = world['resources'] resources['coins'] += int(state.get('-coins', 0)) resources['energy'] += energy #which one? resources['oil'] += int(state.get('-oil', '0').split('|')[0]) resources['wood'] += int(state.get('-wood', '0').split('|')[0]) resource_order = world['resourceOrder'] resources[resource_order[0]] += int(state.get('-rare', '0').split('|')[0]) resources[resource_order[0]] += int(state.get('-nrare0', '0').split('|')[0]) resources[resource_order[1]] += int(state.get('-nrare1', '0').split('|')[0]) resources[resource_order[2]] += int(state.get('-nrare2', '0').split('|')[0]) resources[resource_order[3]] += int(state.get('-nrare3', '0').split('|')[0]) resources[resource_order[4]] += int(state.get('-nrare4', '0').split('|')[0]) resources["aluminum"] += int(state.get('-aluminum', '0').split('|')[0]) resources["copper"] += int(state.get('-copper', '0').split('|')[0]) resources["gold"] += int(state.get('-gold', '0').split('|')[0]) resources["iron"] += int(state.get('-iron', '0').split('|')[0]) resources["uranium"] += int(state.get('-uranium', '0').split('|')[0]) item_inventory = player["inventory"]["items"] if int(state.get('-buildable', '0')): if reference_item: item_inventory[reference_item] = item_inventory.get(reference_item, 0) + 1 print("Adding", reference_item, "to inventory") else: print("ERROR: Buildable present but no reference item") research = world["research"] if int(state.get('-upgrade', '0')): if reference_item: if reference_item.split(":")[0] not in research.get(reference_item.split(":")[1],[]): research[reference_item.split(":")[1]] = research.get(reference_item.split(":")[1],[]) + [reference_item.split(":")[0]] print("Adding", reference_item, "to research") handle_quest_progress(meta, progress_upgrades_count()) else: print("ERROR: Upgrade already added") else: print("ERROR: Upgrade present but no reference item") level_cash = 0 levels_count = 0 levels = [level for level in game_settings['settings']['levels']['level'] if int(level["-num"]) > player['level'] and int(level["-requiredXP"]) <= player['xp']] for level in levels: energy_cap = ([e['-cap'] for e in game_settings['settings']['energycaps']['energycap'] if e['-level'] == level["-num"]] + [46])[0] print("Level increased to", level["-num"], "New energy:", energy_cap) player['level'] = int(level["-num"]) player['energy'] = int(energy_cap) player['energyMax'] = int(energy_cap) levels_count += 1 if "reward" in level and level["reward"]["-type"] == "cash": player['cash'] += int(level["reward"]["-count"]) level_cash += int(level["reward"]["-count"]) create_backup("Level " + level["-num"]) log_rewards = ", ".join( [label + " " + ("+" if int(increment) > 0 else "") + str(increment) + " (" + str(total) + ")" for (label, increment, total) in [("xp:", state.get('-xp', '0'), player['xp']), ("energy:", str(energy), player['energy']), ("coins:", state.get('-coins', '0'), resources['coins']), ("oil:", state.get('-oil', '0'), resources['oil']), ("wood:", state.get('-wood', '0'), resources['wood']), ("cash:", state.get('-cash', '0'), player['cash']), ("cash (level):", str(level_cash), player['cash']), ("levels:", str(levels_count), player['level']), ("socialXpGood:", state.get('-socialXpGood', '0'), player['socialXpGood']), ("socialXpBad:", state.get('-socialXpBad', '0'), player['socialXpBad']), ("buildable:", state.get('-buildable', '0'), sum(item_inventory.values())), (resource_order[0] + ":", state.get('-rare', '0'), resources[resource_order[0]]), (resource_order[0] + ":", state.get('-nrare0', '0'), resources[resource_order[0]]), (resource_order[1] + ":", state.get('-nrare1', '0'), resources[resource_order[1]]), (resource_order[2] + ":", state.get('-nrare2', '0'), resources[resource_order[2]]), (resource_order[3] + ":", state.get('-nrare3', '0'), resources[resource_order[3]]), (resource_order[4] + ":", state.get('-nrare4', '0'), resources[resource_order[4]]), ("aluminum" + ":", state.get('-aluminum', '0'), resources["aluminum"]), ("copper" + ":", state.get('-copper', '0'), resources["copper"]), ("gold" + ":", state.get('-gold', '0'), resources["gold"]), ("iron" + ":", state.get('-iron', '0'), resources["iron"]), ("uranium" + ":", state.get('-uranium', '0'), resources["uranium"]) ] if int(increment.split('|')[0]) != 0]) if log_rewards: print("State rewards:", log_rewards) handle_quest_progress(meta, progress_resource_added_count(state, "-"))
def do_rewards(label, raw_rewards, meta): rewards = simple_list(raw_rewards) inc = {r.get("_type", r.get("-type")): int(r.get('_count', r.get('-count', 1))) for r in rewards if r.get("_type") != "item" and r.get("-type") != "item"} items = {r.get("_item", r.get("-item")): int(r.get('_count', r.get('-count', 1))) for r in rewards if r.get("_type") == "item" or r.get("-type") == "item"} player = session['user_object']["userInfo"]["player"] player['energy'] += int(inc.get('energy', 0)) player['xp'] += int(inc.get('xp', 0)) player['cash'] += int(inc.get('cash', 0)) player['socialXpGood'] += int(inc.get('socialXpGood', 0)) player['socialXpBad'] += int(inc.get('socialXpBad', 0)) world = session['user_object']["userInfo"]["world"] resources = world['resources'] resources['coins'] += int(inc.get('coins', 0)) resources['energy'] += int(inc.get('energy', 0)) #which one? #repleenish!! resources['oil'] += int(inc.get('oil', 0)) resources['wood'] += int(inc.get('wood', 0)) resource_order = world['resourceOrder'] resources[resource_order[0]] += int(inc.get('rare', 0)) resources[resource_order[0]] += int(inc.get('nrare0', 0)) resources[resource_order[1]] += int(inc.get('nrare1', 0)) resources[resource_order[2]] += int(inc.get('nrare2', 0)) resources[resource_order[3]] += int(inc.get('nrare3', 0)) resources[resource_order[4]] += int(inc.get('nrare4', 0)) level_cash = 0 levels_count = 0 levels = [level for level in game_settings['settings']['levels']['level'] if int(level["-num"]) > player['level'] and int(level["-requiredXP"]) <= player['xp'] ] for level in levels: [energy_cap] = [e['-cap'] for e in game_settings['settings']['energycaps']['energycap'] if e['-level'] == level["-num"]] print("Level increased to", level["-num"], "New energy:", energy_cap) player['level'] = int(level["-num"]) player['energy'] = int(energy_cap) resources['energy'] = int(energy_cap) player['energyMax'] = int(energy_cap) levels_count += 1 if "reward" in level and level["reward"]["-type"] == "cash": player['cash'] += int(level["reward"]["-count"]) level_cash += int(level["reward"]["-count"]) create_backup("Level " + level["-num"]) if inc: print(label, "rewards:", ", ".join( [label + " " + ("+" if int(increment) > 0 else "") + str(increment) + " (" + str(total) + ")" for (label, increment, total) in [("xp:", inc.get('xp', 0), player['xp']), ("energy:", inc.get('energy', 0), player['energy']), ("coins:", inc.get('coins', 0), resources['coins']), ("oil:", inc.get('oil', 0), resources['oil']), ("wood:", inc.get('wood', 0), resources['wood']), ("cash:", inc.get('cash', 0), player['cash']), ("cash (level):", level_cash, player['cash']), ("levels:", levels_count, player['level']), ("socialXpGood:", inc.get('socialXpGood', 0), player['socialXpGood']), ("socialXpBad:", inc.get('socialXpBad', 0), player['socialXpBad']), (resource_order[0] + ":", inc.get('rare', 0), resources[resource_order[0]]), (resource_order[0] + ":", inc.get('nrare0', 0), resources[resource_order[0]]), (resource_order[1] + ":", inc.get('nrare1', 0), resources[resource_order[1]]), (resource_order[2] + ":", inc.get('nrare2', 0), resources[resource_order[2]]), (resource_order[3] + ":", inc.get('nrare3', 0), resources[resource_order[3]]), (resource_order[4] + ":", inc.get('nrare4', 0), resources[resource_order[4]]) ] if int(increment) != 0])) if items: item_inventory = session['user_object']["userInfo"]["player"]["inventory"]["items"] for k,v in items.items(): item_inventory[k] = item_inventory.get(k, 0) + v print(label, "item rewards:", ", ".join([ k + ": " + str(v) for k,v in items.items()])) handle_quest_progress(meta, progress_resource_added_count(inc, ""))