summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-08-04 15:11:55 -0300
committerJesusaves <cpntb1@ymail.com>2021-08-04 15:11:55 -0300
commit543f81b095b48a131dc1c2dd51a48d562feb3ad3 (patch)
treece08dd4e5d070d9731b727c4f1c16a7b670fc600
parentfdb91e8d3555cd4ebd8edb31d5b74a2c11f1cf41 (diff)
downloadserver-543f81b095b48a131dc1c2dd51a48d562feb3ad3.tar.gz
server-543f81b095b48a131dc1c2dd51a48d562feb3ad3.tar.bz2
server-543f81b095b48a131dc1c2dd51a48d562feb3ad3.tar.xz
server-543f81b095b48a131dc1c2dd51a48d562feb3ad3.zip
Send action log and minor polishing
-rw-r--r--battle/common.py4
-rw-r--r--battle/main.py27
-rw-r--r--battle/skills.py1
-rw-r--r--battle/spheres.py3
4 files changed, 20 insertions, 15 deletions
diff --git a/battle/common.py b/battle/common.py
index 21c97d2..649d852 100644
--- a/battle/common.py
+++ b/battle/common.py
@@ -104,9 +104,9 @@ def find_target(token, scope):
continue
except:
try:
- print("(%d) Faulty structure: %s" % (i, str(Battle[token][scope][i])))
+ stdout("(%d) Faulty structure: %s" % (i, str(Battle[token][scope][i])))
except:
- print("(%d) TOTALLY Faulty structure: %s" % (i, str(Battle[token][scope])))
+ stdout("(%d) TOTALLY Faulty structure: %s" % (i, str(Battle[token][scope])))
continue
continue
targets.append(i)
diff --git a/battle/main.py b/battle/main.py
index 7ce64a9..c686231 100644
--- a/battle/main.py
+++ b/battle/main.py
@@ -42,6 +42,7 @@ random.seed()
def advance_wave(token, world, quest_id, next_wave):
global Battle, allquests
Battle[token]["enemy"]=[]
+ Battle[token]["log"].append(["WAVE", 0, True, "", 0])
stdout("advance_wave was called")
quest=dl_search(allquests[world], "quest_id", quest_id)
@@ -80,7 +81,8 @@ def get_result(token, victory, world, quest_id):
"exp": 0,
"crystals": 0,
"loot": [],
- "rank": 0
+ "rank": 0,
+ "log": Battle[token]["log"]
}
stdout("GR: Begin")
@@ -257,6 +259,7 @@ def begin_quest(args, token, client_side=True):
"party": [],
"party_id": int(bq["party_id"]),
"spheres": [],
+ "log": [],
"turn": 1}
stdout("Data set")
@@ -344,11 +347,11 @@ def battle_endturn(token, spheres):
Battle[token]["spheres"].remove(SPH_NONE)
stdout("Exceeding spheres removed")
- # Add 1~3 random spheres
- i=random.randint(1,3)
+ # Add 1~3 random spheres; But never go over 5 spheres
+ i=min(random.randint(1,3), len(Battle[token]["spheres"]) - 5)
while i > 0:
i-=1
- Battle[token]["spheres"].append(random.choice([
+ sp=random.choice([
SPH_WIDEATTACK,
SPH_PIERCE,
SPH_ASSAULT,
@@ -356,14 +359,12 @@ def battle_endturn(token, spheres):
SPH_HEALALL,
SPH_ATKUP,
SPH_DEFUP
- ]))
+ ])
+ 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"])))
- # Remove exceeding spheres
- if (len(Battle[token]["spheres"]) > 5):
- del(Battle[token]["spheres"][4:])
-
# Add empty spheres to keep length
while (len(Battle[token]["spheres"]) < 5):
Battle[token]["spheres"].append(SPH_NONE)
@@ -445,6 +446,7 @@ def battle(args, token):
# Erase temporary variables
del tmp
stdout("Party reordered (SKIPPED)")
+ Battle[token]["log"]=[]
#######################################
# Prepare temporary data
@@ -469,10 +471,10 @@ def battle(args, token):
if (bt["sphere"][idx] == ACT_SPHERE):
# Remove the sphere
spheres[idx]=SPH_NONE
- sphere_attack(token, bat, Battle[token]["spheres"][idx])
+ sphere_attack(token, bat, Battle[token]["spheres"][idx], idx)
Battle[token]["bp"]+=2
else:
- sphere_attack(token, bat, SPH_NONE)
+ sphere_attack(token, bat, SPH_NONE, idx)
Battle[token]["bp"]+=1
stdout("Attack performed")
@@ -510,7 +512,7 @@ def battle(args, token):
############
# Enemies
- for bat in Battle[token]["enemy"]:
+ for idx, bat in enumerate(Battle[token]["enemy"]):
# The dead can't fight
if (bat["hp"] <= 0):
continue
@@ -522,6 +524,7 @@ def battle(args, token):
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")
# If HP ends up broken
diff --git a/battle/skills.py b/battle/skills.py
index 4ba592f..56ee4ac 100644
--- a/battle/skills.py
+++ b/battle/skills.py
@@ -81,6 +81,7 @@ def skill_core(token, mask, force, element):
def handle_skill(token, skill_id):
global Battle
# TODO
+ #Battle[token]["log"].append(["who", 0, skill_id << ??, "target", 0])
return
diff --git a/battle/spheres.py b/battle/spheres.py
index 2a2b35b..e3b0d88 100644
--- a/battle/spheres.py
+++ b/battle/spheres.py
@@ -22,7 +22,7 @@ from consts import (SPH_WIDEATTACK, SPH_PIERCE, SPH_ASSAULT, SPH_HEAL, SPH_HEALA
from battle.common import find_target, attackall, calc_dmg
# Handle sphere attacks. Unit is a member from Battle[token][scope]
-def sphere_attack(token, unit, sphere):
+def sphere_attack(token, unit, sphere, idx=0):
stdout("%s is attacking" % str(unit))
stdout("Sphere selected: %d" % sphere)
@@ -74,5 +74,6 @@ def sphere_attack(token, unit, sphere):
# We are done!
#stdout("Attack completed")
+ Battle[token]["log"].append(["party", idx, sphere, "enemy", target_id])
return True