summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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)
############