def __init__(self): GameUtils.__init__(self) self.creatures = {'rat': {'name': 'rat', 'freq': 70, 'att': 1}, 'wolf': {'name': 'wolf', 'freq': 35, 'att': 2}, 'spider': {'name': 'small spider', 'freq': 50, 'att': 2}, 'dragon': {'name': 'dragon', 'freq': 10, 'att': 30}, } self.creature_pops = [ 'A {} skitters about the room..', 'A {} runs under foot.', 'Without warning a {} growls at you.', 'A {} bares its teeth at you.', ] self.rooms_creatures = {}
def __init__(self): GameCommLib.__init__(self) GameUtils.__init__(self) GameItems.__init__(self) GamePlayer.__init__(self) GameCreatures.__init__(self) """ CONNECT TO DATABASE AND RETRIEVE ROOM DATA """ self.player_name = namebuilder(3, 9) self.last_name = namebuilder(5, 8) self.connect_db = sqlite3.connect('SQL_COMMAND_DEMO.db') # print(self.connect_db) self.conn = self.connect_db.cursor() self.grab = self.conn.execute("SELECT * FROM 'ROOMS'") self.column_name = self.grab.description self.stored_rooms_data = sorted(self.grab.fetchall()) # print('Stored Rooms Data == {}'.format(self.stored_rooms_data)) self.area = [ ['#','#','#','#'], ['#',101,102,'#'], ['#',103,104,'#'], ['#',105,'#','#'], ['#','#','#','#'] ] self.room_creat = {} self.inhabit_by = '' self.column = 1 self.row = 2 self.times = self.turn() self.room_temp = {'room': 104, 'row': 2, 'column': 2} #room_coords = [self.row,self.column] ## SQLite ROOMS data ## self.rooms = {} """ Store each room from database into dict values.. """ for each in self.stored_rooms_data: self.rooms[each[0]] = each # print('Each room stored {},{}'.format(self.rooms[each[0]][0], # self.rooms[each[0]])) # print('\n',self.rooms) self.room_select = choice(list(self.rooms.keys())) # print('RS',room_select) # print('ROOMS',rooms[room_select]) # = {100:{'items':['none']}} # = {'room':rooms[room_select][0],'row':rooms[room_select]['row'],'column':rooms[room_select]['column']} self.world = """ ---------- --------- | 101 | | 102 | | \ / | | <----> | | | | | ---| |--- --------- | | ---| |--- --------- | | | | | <----> | | / \ | | 103 | | 104 | ---| |--- --------- | | ---| |--- | | | | | 105 | ---------- """ # # DEFINE LISTS ######################################### self.cardinals = ['n','north','s','south','e','east','w','west'] self.commands = {'s':['search'], 'g':['get','pickup'], 'd':['drop'], 'u':['use'], 'i':['inventory','backpack'], 'l':['look'], 'p':['player','stats'], 'm':['move','walk'], 'v':['view map'], 'h':['help','commands']} self.commands_verbose = ['search','get','pickup','drop','use','inventory','backpack','look','player','stats','move','walk', 'map','help','commands','equip']