summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-08-04 16:11:10 -0300
committerJesusaves <cpntb1@ymail.com>2021-08-04 16:11:10 -0300
commit18a101982c132f4359d545f325e0b13b7769eca7 (patch)
tree315f437e7abd13249b6ce226bb765ffc773e711e
parent4d280b991834adc4768b1dea427761948a8bb615 (diff)
downloadclient-18a101982c132f4359d545f325e0b13b7769eca7.tar.gz
client-18a101982c132f4359d545f325e0b13b7769eca7.tar.bz2
client-18a101982c132f4359d545f325e0b13b7769eca7.tar.xz
client-18a101982c132f4359d545f325e0b13b7769eca7.zip
Next gen battle action logger (incomplete)
-rw-r--r--game/01_init.rpy15
-rw-r--r--game/battle.rpy90
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: