From 18a101982c132f4359d545f325e0b13b7769eca7 Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Wed, 4 Aug 2021 16:11:10 -0300 Subject: Next gen battle action logger (incomplete) --- game/01_init.rpy | 15 ++++++++++ game/battle.rpy | 90 +++++++++++++++++++++++++++++++++++--------------------- 2 files changed, 71 insertions(+), 34 deletions(-) diff --git a/game/01_init.rpy b/game/01_init.rpy index 343b6bf..7b18a09 100644 --- a/game/01_init.rpy +++ b/game/01_init.rpy @@ -108,6 +108,21 @@ init -3 python: IRC_AUTH_NICK =2 IRC_AUTH_CHAN =3 + # Spheres + SPH_NONE =0 + SPH_WIDEATTACK =1 + SPH_PIERCE =2 + SPH_ASSAULT =3 + SPH_HEAL =4 + SPH_HEALALL =5 + SPH_ATKUP =6 + SPH_DEFUP =7 + + # Combat code + SRV_SKILL =1000 + SRV_WAVE =9901 + SRV_SPHERE =9902 + # Special error structs ERR_MOBSTRUCT ={ "name": "ERROR", diff --git a/game/battle.rpy b/game/battle.rpy index 02ac498..8f5b8eb 100644 --- a/game/battle.rpy +++ b/game/battle.rpy @@ -122,53 +122,75 @@ label combat: return - # TODO The server should send a JSON of results... - - # Wait for server to confirm the fight end - if (response["result"] != ""): - $ renpy.free_memory() - # TODO: Announce the result screen - jump results - - # Fight continues - # TODO this is suboptimal, and the loops are also wrong - # Maybe we should get info about what was used and whatnot? + # The server should send a JSON of results... + # Which is being stored as `log` field in an array + # [who, id, what, damage, target, id] + # [ 0, 1, 2, 3, 4, 5] python: - # TODO: Render sphere usage - # Render enemy damage - idx=0 - while idx < len(Battle["enemy"]): + print str(response["log"]) + print len(response["log"]) + for entry in response["log"]: + # The most important is entry[2], which contains the action + # Oh noes - I forgot the damage -.- try: - # TODO: Draw the updates in "sequence" - if (response["wave"] != Battle["wave"]): - hit_someone_verbose(Battle["enemy"][idx], - Battle["enemy"][idx]["hp"]) - else: - hit_someone_verbose(Battle["enemy"][idx], - Battle["enemy"][idx]["hp"]-response["enemy"][idx]["hp"]) - idx+=1 - renpy.pause(0.1) + print("ACTION %d (DMG %d)" % (entry[2], entry[3])) + # TODO: Highlight caster + # TODO: Unmark cards + # TODO: SRV_WAVE (ends waves) SRV_SPHERE (updates spheres) + if entry[2] in [SPH_NONE, SPH_PIERCE, SPH_ASSAULT, SPH_HEAL]: + hit_someone_verbose(Battle[entry[4]][entry[5]], + entry[3]) + sdelay(0.1) + print("Attacked Battle[%s][%d]" % (entry[4], entry[5])) + except: + traceback.print_exc() + + ## Not everything can be calculated from the logs... + ## Legacy render system cannot handle finished battles + if (response["result"] == ""): + stdout("Extrapolating...") + # Extrapolate & Render enemy damage + idx=0 + while idx < len(Battle["enemy"]): + try: + # TODO: Draw the updates in "sequence" + if (response["wave"] != Battle["wave"]): + hit_someone_verbose(Battle["enemy"][idx], + Battle["enemy"][idx]["hp"]) + else: + hit_someone_verbose(Battle["enemy"][idx], + Battle["enemy"][idx]["hp"]-response["enemy"][idx]["hp"]) + idx+=1 + renpy.pause(0.1) + except: + idx+=1 + pass + + # Extrapolate & Render party damage + idx=0 + try: + while idx < len(Battle["party"]): + hit_someone_verbose(Battle["party"][idx], Battle["party"][idx]["hp"]-response["party"][idx]["hp"]) + idx+=1 + renpy.pause(0.1) except: idx+=1 pass - # Render party damage - idx=0 - try: - while idx < len(Battle["party"]): - hit_someone_verbose(Battle["party"][idx], Battle["party"][idx]["hp"]-response["party"][idx]["hp"]) - idx+=1 - renpy.pause(0.1) - except: - idx+=1 - pass + # Maybe we received the victory code + if (response["result"] != ""): + $ renpy.free_memory() + # TODO: Announce the result screen + jump results # We may be going to boss fight if (response["wave"] != Battle["wave"] and response["wave"] == response["max_wave"]): play music MUSIC_BOSS.id() fadein 0.5 $ renpy.notify("BOSS FIGHT!") + # Continue the combat $ Battle=response + $ Battle["log"]=[] jump combat label results: -- cgit v1.2.3-70-g09d2