def __init__(self): GameItems.__init__(self) GamePlayer.__init__(self) self.connect_db = sqlite3.connect('SQL_COMMAND_DEMO.db') self.conn = self.connect_db.cursor() self.exam = self.conn.execute("SELECT * FROM 'room_objects'") self.stored_objects_data = sorted(self.exam.fetchall()) self.commands_proc = {'search': self.search_command, 'get': self.get_command, 'drop': self.drop_command, 'inventory': self.inventory_command, 'help': self.help_command, 'look': self.look_command, 'stats': self.player_command, 'player': self.player_command, 'equip': self.equip_command, 'attack': 0, 'examine': self.examine_command, } self.room_temp = {'room': 104, 'row': 2, 'column': 2} self.list_items = GameItems() self.gold = [] self.player_name = namebuilder(3, 9) self.last_name = namebuilder(5, 8) """ will be assigned to DB later """ self.can_be_equipped = { 'FF1': {'name': 'helm', 'type': 'head'}, 'FF2': {'name': 'buckler', 'type': 'lhand'}, 'FF3': {'name': 'knife', 'type': 'rhand'}, 'FF4': {'name': 'stick', 'type': 'rhand'}, 'FF5': {'name': 'cotton shirt', 'type': 'body'}, 'FF6': {'name': 'leather leggings', 'type': 'legs'}, 'FF7': {'name': 'cloth hat', 'type': 'head'} } self.equipped = [] self.equipped_on_player = [] self.STR = mt.ceil(rnd.randrange(6,20)) self.DEX = mt.ceil(rnd.randrange(6,20)) self.CON = mt.ceil(rnd.randrange(6,20)) self.stats = [self.STR, self.DEX, self.CON] self.area = [ ['#','#','#','#'], ['#',101,102,'#'], ['#',103,104,'#'], ['#',105,'#','#'], ['#','#','#','#'] ] self.backpack = ['knife','buckler','cloth hat','knife','cotton shirt']
def intro(self): get_name = """\n\n\n Before we begin, a few questions if you would? What name would you like your player to be called? If you prefer not to choose a name; a random one will be assigned to your player. Do you wish to choose a name? (Y/N) """ g_name = input(get_name) if g_name == "Y": self.player_name = input('Please enter a name. > ') else: self.player_name = namebuilder(3, 8) self.clr_screen(10) room_title = ('\t]{}[\t\t]TURNS: {}[\t\t] SCORE: 0['.format(self.rooms[self.room_temp['room']][1], next(self.times))) room_exit = ('>>The room is exited to the {}'.format(self.rooms[self.room_temp['room']][3])) room_exits = ('>>Exits lead to the {}.'.format(self.rooms[self.room_temp['room']][3])) room_break = """-#"""*50 intro_ = """{0}\n {1}\n\n\n THE PASSAGE CHAPTER 1 "INTO THE DEPTHS" You awaken... Your head aches as you try to stand, you rub the back of your neck discovering a large, and somewhat sensitive bump at the base of your skull. Blurry-eyed you attempt to get your bearings, realizing that nothing around you appears familiar... A door in front of you appears to be the only way out. Odd markings of a apparently mystic origin adorn the walls that make up the circum- ference of the room.\n\n {2} \n {3} """.format(room_title, room_break, room_break, room_exit) text_intro = tw.TextWrapper() text_intro.width = 50 #text_intro.fill = intro_ #text_intro = tw.fill(intro_, 85) print(intro_)
def __init__(self): """ CONNECT TO DATABASE AND RETRIEVE ROOM DATA """ 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()) self.player_name = namebuilder(3, 9) self.last_name = namebuilder(5, 8) self.area = [ ['#','#','#','#'], ['#',101,102,'#'], ['#',103,104,'#'], ['#',105,'#','#'], ['#','#','#','#'] ] self.column = 1 self.row = 2 #room_temp = {'room': 104, 'row': 2, 'column': 2} #room_coords = [self.row,self.column] ## SQLite ROOMS data ## self.rooms = {101: self.stored_rooms_data[0], 102: self.stored_rooms_data[1], 103: self.stored_rooms_data[2], 104: self.stored_rooms_data[3], 105: self.stored_rooms_data[4], } self.room_select = choice(list(self.rooms.keys())) #print('RS',room_select) #print('ROOMS',rooms[room_select]) #room_items = {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 ######################################### cardinals = ['n','north','s','south','e','east','w','west'] 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']} commands_verbose = ['search','get','pickup','drop','use','inventory','backpack','look','player','stats','move','walk', 'map','help','commands','equip']
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']
# items will temporarily be a list # will eventually be changed to a dict to hold item info # connect_db = sqlite3.connect('SQL_COMMAND_DEMO.db') print(connect_db) conn = connect_db.cursor() grab = conn.execute("SELECT * FROM 'ROOMS'") column_name = grab.description # for each in column_name: # print(each) stored_rooms_data = sorted(grab.fetchall()) # for each in data: # print(each) player_name = namebuilder(3,9) last_name = namebuilder(5,8) items = ['sword','food','pouch','cheese','shield','stick','gems','chest','armor'] equipable = ['sword','shield','armor','stick'] equipped = [] STR = mt.ceil(rnd.randrange(6,20)) DEX = mt.ceil(rnd.randrange(6,20)) CON = mt.ceil(rnd.randrange(6,20)) stats = [STR,DEX,CON] area = [ ['#','#','#','#'], ['#',101,102,'#'], ['#',103,104,'#'], ['#',105,'#','#'], ['#','#','#','#']