diff options
author | Jesusaves <cpntb1@ymail.com> | 2021-08-04 15:26:49 -0300 |
---|---|---|
committer | Jesusaves <cpntb1@ymail.com> | 2021-08-04 15:26:49 -0300 |
commit | 27c66ba593683aa167d364964b5385b9a0d0bdd8 (patch) | |
tree | 3afec735589c26272e28acef0e79f8370fa5b392 /battle | |
parent | 00b6b129f1848613404ead84ef2754fd1f614b8a (diff) | |
download | server-27c66ba593683aa167d364964b5385b9a0d0bdd8.tar.gz server-27c66ba593683aa167d364964b5385b9a0d0bdd8.tar.bz2 server-27c66ba593683aa167d364964b5385b9a0d0bdd8.tar.xz server-27c66ba593683aa167d364964b5385b9a0d0bdd8.zip |
Add another verbosity level, otherwise debug.txt will be a monster
Diffstat (limited to 'battle')
-rw-r--r-- | battle/main.py | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/battle/main.py b/battle/main.py index f3b13f9..4cd5f7c 100644 --- a/battle/main.py +++ b/battle/main.py @@ -47,7 +47,7 @@ def advance_wave(token, world, quest_id, next_wave): quest=dl_search(allquests[world], "quest_id", quest_id) if quest == "ERROR": - stdout("ERROR, INVALID QUEST: %d" % (quest_id)) + stdout("ERROR, INVALID QUEST: %d" % (quest_id), 0) # TODO: HANDLE THIS ERROR (FIXME) for en in quest["waves"][next_wave]: @@ -56,7 +56,7 @@ def advance_wave(token, world, quest_id, next_wave): mil*=5.5 mil=mil - stdout("Recording new enemy with mil: %d" % mil) + stdout("Recording new enemy with mil: %d" % mil, 2) Battle[token]["enemy"].append({ "name": en["name"], "unit_id": en["sprite"], @@ -68,7 +68,7 @@ def advance_wave(token, world, quest_id, next_wave): }) # Update wave - stdout("Advancing wave") + stdout("Advancing wave", 2) Battle[token]["wave"]+=1 return True @@ -85,7 +85,7 @@ def get_result(token, victory, world, quest_id): "log": Battle[token]["log"] } - stdout("GR: Begin") + stdout("GR: Begin", 2) # You lost? if not victory: result["result"]="DEFEAT" @@ -96,11 +96,11 @@ def get_result(token, victory, world, quest_id): quest=dl_search(allquests[world], "quest_id", quest_id) if quest == "ERROR": print("ERROR, INVALID QUEST") - stdout("Quest %d is invalid", str(quest_id)) + stdout("Quest %d is invalid" % quest_id, 0) # TODO: HANDLE THIS ERROR (FIXME) return result - stdout("GR: Rolling") + stdout("GR: Rolling", 2) # Roll each wave # Base quest experience gain result["exp"]+=quest["difficulty"]*10 @@ -117,7 +117,7 @@ def get_result(token, victory, world, quest_id): # TODO: Roll the loots for every enemy in every death result["exp"]=int(result["exp"]) - stdout("GR: Looting") + stdout("GR: Looting", 2) # For now, loots are rolled for quest # 2- Roll loot list for loot, chance in quest["loot"]: @@ -135,7 +135,7 @@ def get_result(token, victory, world, quest_id): else: result["loot"].append(int(loot)*100) # Fix Unit ID from base to ID - stdout("GR: Flagging") + stdout("GR: Flagging", 2) # Mark the quest as complete and grant you crystals for first clear # But this is based on the flags (we can have special quests) if (not (quest["flags"] & SFLAG_SPECIAL) and Player[token]["quest"] < quest["quest_id"]): @@ -156,7 +156,7 @@ def get_result(token, victory, world, quest_id): if (quest["flags"] & SFLAG_DOUBLEGP): result["gp"]*=2 - stdout("GR: Applying") + stdout("GR: Applying", 2) # Apply the results to player data Player[token]["gp"]+=result["gp"] Player[token]["exp"]+=result["exp"] @@ -174,7 +174,7 @@ def get_result(token, victory, world, quest_id): result["loot"].remove(it) # TODO: Send result ERR_FULL - stdout("GR: EXPing") + stdout("GR: EXPing", 2) # Grant to party the same amount of experience pid=Battle[token]["party_id"] for m in Player[token]["party_"+str(pid)]: @@ -187,7 +187,7 @@ def get_result(token, victory, world, quest_id): stdout("Unit %d levelled up %d times" % (m["inv_id"], v5)) - stdout("GR: Ranking") + stdout("GR: Ranking", 2) # Player rank up rk=player.check_rank_up(token) if rk["code"]: @@ -210,7 +210,7 @@ def begin_quest(args, token, client_side=True): try: stdout("Begin Quest: %s" % args) bq=json.loads(args) - stdout("JSON loaded") + stdout("JSON loaded", 2) # Validation tmp=int(bq["quest_id"]) tmp=int(bq["party_id"]) @@ -223,9 +223,9 @@ def begin_quest(args, token, client_side=True): break if (quest["quest_id"] != bq["quest_id"]): raise Exception("Quest not found") - stdout("All fine thus far") + stdout("All fine thus far", 2) except: - stdout(traceback.format_exc()) + stdout(traceback.format_exc(), 0) # Invalid data return ERR_BAD @@ -238,7 +238,7 @@ def begin_quest(args, token, client_side=True): return ERR_BAD if (Player[token]["ap"] < quest["cost"] and client_side): return ERR_BAD - stdout("You can begin it!") + stdout("You can begin it!", 2) Player[token]["status"]=int(quest["quest_id"]) @@ -262,7 +262,7 @@ def begin_quest(args, token, client_side=True): "log": [], "turn": 1} - stdout("Data set") + stdout("Data set", 2) # Write the current wave enemies data advance_wave(token, bq["world"], quest["quest_id"], 0) @@ -287,7 +287,7 @@ def begin_quest(args, token, client_side=True): print("Error, un and ux differs: %s vs %s" % (str(un["unit_id"]), str(ux["unit_id"]))) return ERR_ERR - stdout("Preparing party member") + stdout("Preparing party member", 2) # How much HP/ATK bonus per level you'll get? # Each level boosts your stats in 1% @@ -337,7 +337,7 @@ def battle_endturn(token, spheres): stdout("Turn has ended") # Resave spheres - stdout("Sphere list: "+str(spheres)) + stdout("Sphere list: "+str(spheres), 2) Battle[token]["spheres"]=[] for i in spheres: Battle[token]["spheres"].append(int(i)) @@ -345,7 +345,7 @@ def battle_endturn(token, spheres): # Remove an eventual none spheres while (Battle[token]["spheres"].count(SPH_NONE)): Battle[token]["spheres"].remove(SPH_NONE) - stdout("Exceeding spheres removed") + stdout("Exceeding spheres removed", 2) # Add 1~3 random spheres; But never go over 5 spheres i=min(random.randint(1,3), len(Battle[token]["spheres"]) - 5) @@ -363,7 +363,7 @@ def battle_endturn(token, spheres): Battle[token]["log"].append(["SP", len(Battle[token]["spheres"]), sp, "", 0]) Battle[token]["spheres"].append(sp) - stdout("Spheres added; Status before adjust: %s" % (str(Battle[token]["spheres"]))) + stdout("Spheres added; Status before adjust: %s" % (str(Battle[token]["spheres"])), 2) # Add empty spheres to keep length while (len(Battle[token]["spheres"]) < 5): @@ -376,7 +376,7 @@ def battle_endturn(token, spheres): pass # Send data to client - stdout("Sending data") + stdout("Sending data", 2) sjson=compress(Battle[token]) stdout("Data sent: %s" % sjson) return sjson @@ -445,7 +445,7 @@ def battle(args, token): # Erase temporary variables del tmp - stdout("Party reordered (SKIPPED)") + stdout("Party reordered (SKIPPED)", 2) Battle[token]["log"]=[] ####################################### @@ -467,7 +467,7 @@ def battle(args, token): # Will you use a sphere? idx=Battle[token]["party"].index(bat) - stdout("Check index %d" % idx) + stdout("Check index %d" % idx, 2) if (bt["sphere"][idx] == ACT_SPHERE): # Remove the sphere spheres[idx]=SPH_NONE @@ -476,7 +476,7 @@ def battle(args, token): else: sphere_attack(token, bat, SPH_NONE, idx) Battle[token]["bp"]+=1 - stdout("Attack performed") + stdout("Attack performed", 2) # If HP ends up broken if (bat["hp"] > bat["max_hp"]): @@ -500,7 +500,7 @@ def battle(args, token): del Battle[token] return compress(result) - stdout("Friends executed") + stdout("Friends executed", 2) # It never harms checking for suicide... if (not check_player_alive(token)): @@ -519,13 +519,13 @@ def battle(args, token): # Simple Attack target_id=find_target(token, "party") - stdout("ENEMY: Perform attack against %d" % target_id) + stdout("ENEMY: Perform attack against %d" % target_id, 2) target=Battle[token]["party"][target_id] target["hp"]-=calc_dmg(token, bat, target, bat["atk"]) Battle[token]["bp"]+=1 Battle[token]["log"].append(["enemy", idx, SPH_NONE, "party", target_id]) - stdout("ENEMY: Attack performed") + stdout("ENEMY: Attack performed", 2) # If HP ends up broken if (bat["hp"] > bat["max_hp"]): @@ -541,7 +541,7 @@ def battle(args, token): return compress(result) - stdout("Enemies executed") + stdout("Enemies executed", 2) return battle_endturn(token, spheres) # Reload battle will only inform the client again of the battle status |