summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2021-08-11 00:04:01 -0300
committerJesusaves <cpntb1@ymail.com>2021-08-11 00:04:01 -0300
commit69683a1f984f6ea12ed62cd22e6a0014d6d35bcc (patch)
treefbb2413d6ec468a66285c32841947855a35b374f
parent7dc285029db11348ae9ef2d90b805a39ba61f918 (diff)
downloadserver-69683a1f984f6ea12ed62cd22e6a0014d6d35bcc.tar.gz
server-69683a1f984f6ea12ed62cd22e6a0014d6d35bcc.tar.bz2
server-69683a1f984f6ea12ed62cd22e6a0014d6d35bcc.tar.xz
server-69683a1f984f6ea12ed62cd22e6a0014d6d35bcc.zip
Alpha version of summoning
-rw-r--r--battle/main.py6
-rw-r--r--battle/skills.py19
-rw-r--r--battle/spheres.py6
-rw-r--r--battle/summons.py15
-rw-r--r--consts.py2
-rw-r--r--protocol.py4
6 files changed, 33 insertions, 19 deletions
diff --git a/battle/main.py b/battle/main.py
index 6911935..ad2a67a 100644
--- a/battle/main.py
+++ b/battle/main.py
@@ -1,6 +1,6 @@
-########################################################################################
+#################################################################################
# This file is part of Spheres.
-# Copyright (C) 2019 Jesusalva
+# Copyright (C) 2019-2021 Jesusalva
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -15,7 +15,7 @@
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-########################################################################################
+#################################################################################
# Battle Module - Main module
from utils import stdout, compress, allunits, Player, Battle, allquests
from consts import (ERR_ERR, ERR_BAD, ST_TOWN, ST_QUEST,
diff --git a/battle/skills.py b/battle/skills.py
index 91bb990..29608ff 100644
--- a/battle/skills.py
+++ b/battle/skills.py
@@ -1,6 +1,6 @@
-########################################################################################
+#################################################################################
# This file is part of Spheres.
-# Copyright (C) 2019 Jesusalva
+# Copyright (C) 2019-2021 Jesusalva
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -14,11 +14,13 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-########################################################################################
+#################################################################################
# Battle Module - Skills
+# SRV_NOCAST => Effects of SRV_SKILL follows
from utils import stdout, Battle
from consts import (SK_SINGLE_DMG, SK_MULTI_DMG, SK_ATK_UP, SK_DEF_UP,
- SK_SINGLE_HEAL, SK_MULTI_HEAL, SC_ATKUP, SC_DEFUP)
+ SK_SINGLE_HEAL, SK_MULTI_HEAL, SC_ATKUP, SC_DEFUP,
+ SRV_SKILL, SRV_NOCAST)
from battle.common import find_target, calc_dmg, attackall
def skill_core(token, mask, force, element):
global Battle
@@ -41,7 +43,9 @@ def skill_core(token, mask, force, element):
target_id=find_target(token, "enemy")
stdout("Enemy selected: %d" % target_id)
target=Battle[token]["enemy"][target_id]
- target["hp"]-=calc_dmg(token, dummy, target, dummy["atk"])
+ dmg = calc_dmg(token, dummy, target, dummy["atk"])
+ target["hp"] -= dmg
+ Battle[token]["log"].append(["", 0, SRV_NOCAST, dmg, "enemy", target_id])
if mask & SK_MULTI_DMG:
# Multi Damage skill: 1 strength = 1 damage
@@ -80,8 +84,9 @@ def skill_core(token, mask, force, element):
def handle_skill(token, skill_id):
global Battle
- # TODO
- #Battle[token]["log"].append(["who", 0, skill_id << ??, dmg, "target", 0])
+ # TODO / FIXME
+ dmg = 0
+ Battle[token]["log"].append(["who", 0, SRV_SKILL+skill_id, dmg, "target", 0])
return
diff --git a/battle/spheres.py b/battle/spheres.py
index 594636f..3a312a7 100644
--- a/battle/spheres.py
+++ b/battle/spheres.py
@@ -79,6 +79,10 @@ def sphere_attack(token, unit, sphere, idx=0):
# We are done!
#stdout("Attack completed")
- Battle[token]["log"].append(["party", idx, sphere, dmg, "enemy", target_id])
+ ## FIXME
+ if sphere not in [SPH_HEAL, SPH_HEALALL]:
+ Battle[token]["log"].append(["party", idx, sphere, dmg, "enemy", target_id])
+ elif sphere == SPH_HEAL:
+ Battle[token]["log"].append(["party", idx, sphere, dmg, "party", target_id])
return True
diff --git a/battle/summons.py b/battle/summons.py
index 18ce106..ff128e1 100644
--- a/battle/summons.py
+++ b/battle/summons.py
@@ -1,6 +1,6 @@
#################################################################################
# This file is part of Spheres.
-# Copyright (C) 2019 Jesusalva
+# Copyright (C) 2019-2021 Jesusalva
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -16,10 +16,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#################################################################################
# Battle Module - Summons
-import json
+import json, traceback
from utils import (compress, allsummons, stdout, dl_search,
Player, Battle)
-from consts import (ERR_ERR, ERR_BAD, SRV_SUMMON)
+from consts import (ERR_ERR, ERR_SUMMON, SRV_SUMMON)
from battle.skills import skill_core
from battle.common import conditions
#from battle.main import advance_wave, battle_endturn, get_result
@@ -28,16 +28,19 @@ def handle_summon(token, summon):
global Battle, Player
try:
+ # Log that summon was used
+ Battle[token]["log"].append(["", 0, SRV_SUMMON, summon["summon_id"], "", 0])
+
# Summon strength is based on player rank
force=summon["strength"]*Player[token]["level"]
# Cast the skill, return error 500 on exception
skill_core(token, summon["type"], force, summon["attribute"])
except:
+ traceback.print_exc()
return ERR_ERR
stdout("Summon: Victory/Defeat Check", 2)
- Battle[token]["log"].append(["", 0, SRV_SUMMON, summon["summon_id"], "", 0])
# HOLD THAT! Handle victory/defeat conditions
check = conditions(token, Battle[token]["spheres"])
@@ -74,13 +77,13 @@ def summon(args, token):
stdout("All fine thus far")
except:
# Invalid data
- return ERR_BAD
+ return ERR_SUMMON
# Already summoned (reverse logic)
try:
Battle["s"]+=1
Battle["s"]-=1
- return ERR_BAD
+ return ERR_SUMMON
except:
pass
diff --git a/consts.py b/consts.py
index 285e283..5820039 100644
--- a/consts.py
+++ b/consts.py
@@ -56,6 +56,7 @@ SRV_SKILL =1000
SRV_WAVE =9901
SRV_SPHERE =9902
SRV_SUMMON =9903
+SRV_NOCAST =9904
# Status Conditions
SC_ATKUP =1
@@ -131,6 +132,7 @@ ERR_DONE ="200"
#"You cannot perform this operation! Not enough Crystals"
ERR_INS =105
ERR_FULL =106
+ERR_SUMMON =108
#"Operation complete"
ERR_OK =200
ERR_LOGIN =5000
diff --git a/protocol.py b/protocol.py
index 5556bc6..b5327d2 100644
--- a/protocol.py
+++ b/protocol.py
@@ -105,8 +105,8 @@ def parse(packet, conn):
r=player.sellunits(data[2], t);
elif data[1] == "recruit":
r=tavern.recruit(data[2], t)
- #elif data[1] == "summon":
- # r=battle.summon(data[2], t)
+ elif data[1] == "summon":
+ r=battle.summon(data[2], t)
else:
r=ERR_BAD