Ejemplo n.º 1
0
    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 __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']