summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-08-10 23:42:41 -0300
committerJesusaves <cpntb1@ymail.com>2021-08-10 23:42:41 -0300
commit3fd94b26028d817a0ed0c6cb14a5f2646022811f (patch)
treeeeac01fe33cefbadfdba13a7b3d4326aecd35531
parent217abb0dd2acc08e0f4f3b7c50c458fb5470cd35 (diff)
downloadserver-3fd94b26028d817a0ed0c6cb14a5f2646022811f.tar.gz
server-3fd94b26028d817a0ed0c6cb14a5f2646022811f.tar.bz2
server-3fd94b26028d817a0ed0c6cb14a5f2646022811f.tar.xz
server-3fd94b26028d817a0ed0c6cb14a5f2646022811f.zip
Initial version of priority-based attack order (spheres > skills > attack)
-rw-r--r--battle/main.py58
1 files changed, 39 insertions, 19 deletions
diff --git a/battle/main.py b/battle/main.py
index 34123fc..c503f62 100644
--- a/battle/main.py
+++ b/battle/main.py
@@ -18,7 +18,8 @@
########################################################################################
# Battle Module - Main module
from utils import stdout, compress, allunits, Player, Battle, allquests
-from consts import (ERR_ERR, ERR_BAD, ST_TOWN, ST_QUEST, ACT_SPHERE,
+from consts import (ERR_ERR, ERR_BAD, ST_TOWN, ST_QUEST,
+ ACT_SPHERE, ACT_SKILL, ACT_NONE,
SPH_WIDEATTACK, SPH_PIERCE, SPH_ASSAULT, SPH_HEAL, SPH_HEALALL, SPH_ATKUP,
SPH_DEFUP, SPH_NONE)
import json, random, traceback
@@ -162,12 +163,14 @@ def begin_quest(args, token, client_side=True):
# Action
-def _action(token, bat, bt, spheres):
+def _action(token, bat, bt, spheres, idx):
global Battle
+ # The dead can't fight
+ if (bat["hp"] <= 0):
+ return
# Will they use a sphere?
- idx=Battle[token]["party"].index(bat)
- stdout("Check index %d" % idx, 2)
+ stdout("Execute index %d" % idx, 2)
if (bt["sphere"][idx] == ACT_SPHERE):
# Remove the sphere
spheres[idx]=SPH_NONE
@@ -260,23 +263,40 @@ def battle(args, token):
print("Sphere list: "+str(spheres))
#######################################
- # TODO: determine battle order
-
- ############
# Friends
- for bat in Battle[token]["party"]:
- # The dead can't fight
- if (bat["hp"] <= 0):
- continue
-
- # Execute whatever
- _action(token, bat, bt, spheres)
-
- # HOLD THAT! Handle victory/defeat conditions
- check = conditions(token, spheres)
- if check is not None:
- return check
+ ############
+ ## Spheres
+ for i, j in enumerate(bt["action"]):
+ bat = Battle[token]["party"][i]
+ if j == ACT_SPHERE:
+ _action(token, bat, bt, spheres, i)
+ # HOLD THAT! Handle victory/defeat conditions
+ check = conditions(token, spheres)
+ if check is not None:
+ return check
+
+ ## Skills
+ for i, j in enumerate(bt["action"]):
+ bat = Battle[token]["party"][i]
+ if j == ACT_SKILL:
+ _action(token, bat, bt, spheres, i)
+ # HOLD THAT! Handle victory/defeat conditions
+ check = conditions(token, spheres)
+ if check is not None:
+ return check
+
+ ## Normal Attacks
+ for i, j in enumerate(bt["action"]):
+ bat = Battle[token]["party"][i]
+ if j == ACT_NONE:
+ _action(token, bat, bt, spheres, i)
+ # HOLD THAT! Handle victory/defeat conditions
+ check = conditions(token, spheres)
+ if check is not None:
+ return check
+
+ ## Anything unrecognized is ignored
stdout("Friends executed", 2)
############