summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--battle/main.py39
1 files changed, 23 insertions, 16 deletions
diff --git a/battle/main.py b/battle/main.py
index d104db8..34123fc 100644
--- a/battle/main.py
+++ b/battle/main.py
@@ -161,7 +161,28 @@ def begin_quest(args, token, client_side=True):
return sjson
+# Action
+def _action(token, bat, bt, spheres):
+ global Battle
+
+ # Will they use a sphere?
+ idx=Battle[token]["party"].index(bat)
+ stdout("Check index %d" % idx, 2)
+ if (bt["sphere"][idx] == ACT_SPHERE):
+ # Remove the sphere
+ spheres[idx]=SPH_NONE
+ sphere_attack(token, bat, Battle[token]["spheres"][idx], idx)
+ Battle[token]["bp"]+=2
+ else:
+ sphere_attack(token, bat, SPH_NONE, idx)
+ Battle[token]["bp"]+=1
+ stdout("Attack performed", 2)
+
+ # If HP ends up broken
+ if (bat["hp"] > bat["max_hp"]):
+ bat["hp"]=0+bat["max_hp"]
+ return
# Advance turn button. Main turn logic
# Receives a list of units position, and if they'll use sphere:
# { "unit": [uid1, uid2 ....], "sphere": [True/False array, in future will save skill as 2] }
@@ -248,22 +269,8 @@ def battle(args, token):
if (bat["hp"] <= 0):
continue
- # Will you use a sphere?
- idx=Battle[token]["party"].index(bat)
- stdout("Check index %d" % idx, 2)
- if (bt["sphere"][idx] == ACT_SPHERE):
- # Remove the sphere
- spheres[idx]=SPH_NONE
- sphere_attack(token, bat, Battle[token]["spheres"][idx], idx)
- Battle[token]["bp"]+=2
- else:
- sphere_attack(token, bat, SPH_NONE, idx)
- Battle[token]["bp"]+=1
- stdout("Attack performed", 2)
-
- # If HP ends up broken
- if (bat["hp"] > bat["max_hp"]):
- bat["hp"]=0+bat["max_hp"]
+ # Execute whatever
+ _action(token, bat, bt, spheres)
# HOLD THAT! Handle victory/defeat conditions
check = conditions(token, spheres)