612192b6 by Barry

Most of the magic system is now in place.

1 parent 03403a56
......@@ -67,6 +67,7 @@ def db_buy_ticket(member_id, amount):
return True, int(credits[1]) + int(amount)
except Exception as e:
log(e)
def db_update_credit(member_id, amount):
conn = sqlite3.connect('db.sqlite3')
c = conn.cursor()
......@@ -168,7 +169,6 @@ def db_get_fortune():
try:
conn = sqlite3.connect('db.sqlite3')
c = conn.cursor()
# TODO: Move this shit to data
return c.execute("SELECT fortune FROM fortunes ORDER BY RANDOM() LIMIT 1;").fetchone()[0]
finally:
conn.close()
......@@ -192,7 +192,6 @@ def db_get_fortune():
try:
conn = sqlite3.connect('db.sqlite3')
c = conn.cursor()
# TODO: Move this shit to data
return c.execute("SELECT fortune FROM fortunes ORDER BY RANDOM() LIMIT 1;").fetchone()[0]
finally:
conn.close()
......
No preview for this file type
......@@ -27,7 +27,7 @@ import wolframalpha
import sqlite3
from blackjack import Blackjack
import data
from pankration import Pankration, HuntResponse, Jobs, Action, MissAction, AttackAction, DefeatAction, TemperamentPosture, TemperamentAttitude
from pankration import Pankration, HuntResponse, Jobs, Action, MagicResistAction, MissAction, AttackAction, DefeatAction, TemperamentPosture, TemperamentAttitude
VERSION = 2.3
......@@ -1203,7 +1203,7 @@ def do_hunt_monster(client, message_parts, message):
if not result:
send_message(client, message.author, error_message)
return
send_message(client, message.channel, 'Soul Plate purchased for {} credits\n Hunting in {}'.format(cost, zone))
send_message(client, message.channel, '{} Soul Plate purchased for {} credits\n Hunting in {}'.format(message.author.name, cost, zone))
time.sleep(3)
hunt_response = p.hunt_monster(' '.join(message_parts))
str_out = hunt_response.message + "\n\n"
......@@ -1212,7 +1212,7 @@ def do_hunt_monster(client, message_parts, message):
member = data.db_get_member(message.author.id)
data.db_add_soul_plate(member['member_id'], soul_plate)
str_out += str(soul_plate.get_soul_plate_description())
send_message(client, message.channel, str_out)
send_message(client, message.channel, "{} {}".format(message.author.name, str_out))
def do_list_zones(client, message_parts, message):
......@@ -1271,12 +1271,20 @@ def check_arena():
time.sleep(4)
out_str = ""
for action in actions:
# TODO: Decide if I should merge magicresistaction with miss action
if isinstance(action, MagicResistAction):
out_str += "{} {} {} while casting {}.\n".format(action.attacker.get_monster_name(), action.message, action.target.get_monster_name(), action.spell)
if isinstance(action, MissAction):
out_str += "{} {} {}.\n".format(action.attacker.get_monster_name(), action.message, action.target.get_monster_name())
if action.spell:
out_str += "{} {} {} while casting {}.\n".format(action.attacker.get_monster_name(), action.message, action.target.get_monster_name(), action.spell)
else:
out_str += "{} {} {}.\n".format(action.attacker.get_monster_name(), action.message, action.target.get_monster_name())
if isinstance(action, AttackAction):
out_str += "{} {} {} for {}.\n".format(action.attacker.get_monster_name(), action.message, action.target.get_monster_name(), int(action.damage))
if action.spell:
out_str += "{} {} {} against {} for {}.\n".format(action.attacker.get_monster_name(), action.message, action.spell, action.target.get_monster_name(), int(action.damage))
else:
out_str += "{} {} {} for {}.\n".format(action.attacker.get_monster_name(), action.message, action.target.get_monster_name(), int(action.damage))
if isinstance(action, DefeatAction):
out_str += "\n\n**{}** {}. {} gains {} xp.\n\n".format(action.target.get_monster_name(), action.message, action.attacker.get_monster_name(), action.xp)
fighting = False
if action.attacker == monster:
......@@ -1294,7 +1302,8 @@ def check_arena():
monster2.wins += 1
monster.losses += 1
break
out_str += "\n{} {}% - {} {}%\n".format(monster.get_monster_name(), monster.get_hp_percent(), monster2.get_monster_name(), monster2.get_hp_percent())
if fighting:
out_str += "\n{} {}% - {} {}%\n".format(monster.get_monster_name(), monster.get_hp_percent(), monster2.get_monster_name(), monster2.get_hp_percent())
log(out_str)
send_message(client, arena_channel, byteify(out_str))
# Heal the monsters before they are returned to the player inventory
......