e64ece4e by Barry

Bug fix for missing users. It now checks users constantly and updates them if needed.

Added several things to pankration.
1 parent 989c737e
No preview for this file type
......@@ -385,20 +385,21 @@ def on_socket_raw_send(payload, binary=False):
@client.event
def on_status(member):
try:
db_member = db_get_member(member.id)
#log(db_member)
if not db_member:
log("Creating new member: {}".format(member) )
db_create_member(member)
else:
#log("Updating member: {}".format(member) )
db_update_member(member, db_member)
for member in client.get_all_members():
try:
db_member = db_get_member(member.id)
#log(db_member)
if not db_member:
log("Creating new member: {}".format(member) )
db_create_member(member)
else:
#log("Updating member: {}".format(member) )
db_update_member(member, db_member)
check_msg_queue()
except Exception as e:
log("Exception: {}".format(format_exception(e)))
pass
check_msg_queue()
except Exception as e:
log("Exception: {}".format(format_exception(e)))
pass
def get_game_names(game_id_list):
json_data=open(games_file).read()
......@@ -1143,6 +1144,7 @@ def on_ready():
print(client.user.name)
print(client.user.id)
print('------')
check_msg_queue()
retries = 0
......
import random
import time
FIND_PERCENTAGE = 80
class HuntResponse:
ERROR = -1
FAILURE = 0
SUCCESS = 1
def __init__(self, result, message, monster):
self.result = result
self.message = message
self.monster = monster
class Jobs:
WAR = 1
MNK = 2
......@@ -79,16 +96,35 @@ Monsters = {
}
}
print Families
class Pankration:
def __init__(self, arena_name):
def __init__(self):
pass
def start_battle(self, monster1, monster2, battle_type):
pass
def get_seeking_monsters(self):
pass
def list_zones(self):
zone_list = []
for monster in Monsters.itervalues():
if monster['zone'] not in zone_list:
zone_list.append(monster['zone'])
return zone_list
def get_monsters(self, zone):
monster_list = []
for monster_name, monster in Monsters.iteritems():
if monster['zone'] == zone:
monster_list.append(monster_name)
return monster_list
def hunt_monster(self, zone):
if random.randint(1, 100) > FIND_PERCENTAGE:
return HuntResponse(HuntResponse.SUCCESS, "You captured the monster!",
random.choice(self.get_monsters(zone)))
else:
return HuntResponse(HuntResponse.FAILURE, "You were unable to capture a monster's soul.",
None)
def get_action():
return ""
......@@ -121,3 +157,31 @@ class Battle:
class Arena:
pass
#print Families
p = Pankration()
print("Zones: \n\n{}".format('\n'.join(p.list_zones())))
hunt_zone = p.list_zones()[0]
print("Hunting for monster in zone: {}\n".format(hunt_zone))
hunt_response = p.hunt_monster(hunt_zone)
print("hunt_response")
print(str(hunt_response.result))
time.sleep(0.5)
if hunt_response.result == HuntResponse.SUCCESS:
print('Success! {} - {}'.format(hunt_response.message, hunt_response.monster))
else:
print(hunt_response.message)
......