2f3e968d by Barry

Added cast for players to cast spells

1 parent bfcc117a
......@@ -13,5 +13,7 @@
"aa": "1d2",
"mpr": 0.25,
"star": 0.4,
"weapon": null
"weapon": null,
"sp": {},
"at": {}
}
\ No newline at end of file
......
......@@ -64,7 +64,8 @@ while True:
print('spawner error:')
print(e)
if tick >= 1:
print(mem_free())
if 'esp' in platform:
print(mem_free())
spawn += tick
tick = 0
# try:
......
{"name": "test", "room": "Outside", "inventory": {"candle": 1}, "prompt": "%hp> ", "aliases": {}, "hp": 593, "mp": 100, "sta": 10, "aa": "1d2", "mpr": 0.25, "star": 0.4, "maxhp": 953, "maxmp": 100, "maxsta": 10, "weapon": "sword"}
\ No newline at end of file
{"name": "test", "room": "Tavern", "inventory": {"candle": 1}, "prompt": "hp %hp mp %mp> ", "aliases": {}, "hp": 461, "mp": 50, "sta": 10, "aa": "1d2", "mpr": 0.25, "star": 0.4, "maxhp": 953, "maxmp": 100, "maxsta": 10, "weapon": "sword", "sp": {"fireball": {"cost": 5, "dmg": "2d4", "desc": "A fireball blasts from your fingertips striking the target"}}, "at": {}}
\ No newline at end of file
......
{"cricket": {"max": 1, "active": [{"hp": 100, "mp": 2.0, "sta": 4.550000000000075, "maxhp": 100, "maxmp": 10, "maxsta": 10, "action": "attack", "target": "test"}]}}
\ No newline at end of file
{"cricket": {"max": 1, "active": [{"hp": 48, "mp": 5.0, "sta": 0.35000000000008313, "maxhp": 100, "maxmp": 10, "maxsta": 10, "action": "attack", "target": "test"}]}}
\ No newline at end of file
......
......@@ -48,12 +48,15 @@ def get_att(d):
else:
att = int(d)
return att
def calc_att(mud, pid, attacks, bank):
def calc_att(mud, pid, attacks, bank, attack=None):
v_att = []
att = 0
for attack in attacks:
if attack['cost'] < bank:
v_att.append(attack)
if attack:
v_att.append(attack)
else:
for attack in attacks:
if attack['cost'] < bank:
v_att.append(attack)
# Select a random attack
if len(v_att) > 0:
attack = v_att[randrange(len(v_att))]
......