Exemple #1
0
    def __init__(self, position=sc([0, 0, 0])):
        super().__init__("ast", position)

        self.velocity = np.array([0.0, 0.0, 0.0])
        self.thrust_acc = np.array([0.0, 0.0, 0.0])

        self.inventory.insert(items.item("ice", np.random.rand() * 100000.0))
        self.inventory.insert(items.item("iron", np.random.rand() * 1000.0))
        self.inventory.insert(items.item("gold", np.random.rand() * 1000.0))
        self.inventory.insert(items.item("stone", np.random.rand() * 100000.0))
        self.inventory.insert(items.item("uranium", np.random.rand() * 10.0))
Exemple #2
0
    def __init__(self, position=sc([0, 0, 0])):
        super().__init__("ship", position)
        self.modules = {
            "radio":
            commands.radio(),
            "thruster":
            commands.thrusters(self),
            "rudder":
            commands.rudder(self, np.array([100000.0, 100000.0, 100000.0])),
            "ship":
            commands.ship_info(self),
            "log":
            commands.log(),
            "time":
            commands.timer(),
            "radar":
            commands.radar(self),
            "crew":
            commands.crew(self),
            "reactor":
            commands.reactor(self, 1000000000),
            "cargo":
            commands.cargo(self),
            "laser":
            commands.laser(self),
            "shield":
            commands.shield(self),
        }

        self.name = 'Восток'
        self.inventory.insert(items.item("uranium", 10.0))

        #Vector for telling  where ship is going
        self.velocity = np.array([0.0, 0.0, 0.0])
        self.thrust_acc = np.array([0.0, 0.0, 0.0])
Exemple #3
0
 def newInventoryItem(self, gamedata, connection, handler):
     (index, amount, itemno, identify, attribute, refine) = struct.unpack('HHHBBB', gamedata[2:11])
     
     (card0, card1, card2, card3, equippoint, type, fail)=struct.unpack('HHHHHBB', gamedata[11:])
     new=items.item(index, itemno, type, identify, amount, equippoint, 0, attribute, refine, card0, card1, card2, card3);
     
     connection.inventory.append(new)
Exemple #4
0
 def newCartItem(self, gamedata, connection, handler):
     (index,) = struct.unpack('H', gamedata[2:4]) 
     (amount, itemno, identify, attribute, refine) = struct.unpack('IHBBB', gamedata[4:13]) 
     (card0, card1, card2, card3) = struct.unpack('HHHH', gamedata[13:]) 
     new=items.item(index, itemno, type, identify, amount, 0, 0, attribute, refine, card0, card1, card2, card3);
     
     connection.cart.append(new)
Exemple #5
0
    def getCartItemList(self, gamedata, connection, handler):
        len=struct.unpack('H', gamedata[2:4])[0];
        numitems=(len-4)/18
 
        for n in range(numitems):
            data=gamedata[4+18*n: 22+18*n];            
            (index, itemno, type, identify, amount, equip, card0, card1, card2, card3)=struct.unpack('HHBBHHHHHH', data);
            new=items.item(index, itemno, type, identify, amount, 0, equip, 0, 0, card0, card1, card2, card3);
            connection.cart.append(new)
Exemple #6
0
    def getCartEquipList(self, gamedata, connection, handler):
        len=struct.unpack('H', gamedata[2:4])[0];
        numitems=(len-4)/20
 
        for n in range(numitems):
            data=gamedata[4+20*n: 24+20*n];  
            (index, itemno, type, identify, equip, cartequip, attribute, refine, card0, card1, card2, card3)=struct.unpack('HHBBHHBBHHHH', data)
                     
            new=items.item(index, itemno, type, identify, 1, cartequip, equip, attribute, refine, card0, card1, card2, card3);
            connection.cart.append(new)
Exemple #7
0
    def draw_objects(self):
        xx = ((self.WIDTH - (self.HEIGHT / 2)) / 2,
              self.HEIGHT - (self.HEIGHT / 4))
        yy = ((self.WIDTH + (self.HEIGHT / 2)) / 2, self.HEIGHT / 4)
        xy = (self.main_unit * np.cos(1 * self.counter),
              self.main_unit * np.sin(1 * self.counter))
        moving_point = (self.centre[0] + xy[0], self.centre[1] + xy[1])
        new_radius = (self.main_unit / 2) / (4 / (1 * np.pi))
        coords_p1 = (self.centre[0] - self.main_unit,
                     self.centre[1] - self.main_unit)
        coords_p2 = (self.centre[0] + self.main_unit,
                     self.centre[1] + self.main_unit)

        items.item(canvas=self.CANVAS,
                   counter=self.counter,
                   dims_1=coords_p1 + coords_p2,
                   centre=moving_point,
                   dims_2=self.centre + moving_point,
                   radius=new_radius,
                   recursions=self.RECURSIONS,
                   iteration=1)
 def parseCategoryFromXML(self, user, cat_name, items_list):
     cat_to_parse_query = db.GqlQuery('SELECT * FROM category WHERE creator = \'%s\' AND name = \'%s\'' %(user.nickname(), cat_name))
     cat_to_parse = cat_to_parse_query.get()
     if cat_to_parse: #replace old category
         self.replaceCategory(user, cat_name, items_list)
     else: #create new category
         new_category = categories.category(name=cat_name, creator=user.nickname())
         new_category.put()
         for item in items_list:
             new_item = items.item(name=item, creator=user.nickname(), category=cat_name)
             new_item.put()
             
     self.rendering(user)
Exemple #9
0
 def give(self, args):
     item_name = args[2]
     amount = float(args[3])
     logger.info('Player give {} {}'.format(amount, item_name))
     try:
         item = items.item(item_name, amount)
     except:
         logger.info("Player requested item that doesn't exist: {}".format(
             item_name))
         return player.response.ok, "There is no such thing as \"{}\" in the universe".format(
             item_name)
     self.inventory.insert(item)
     reply = "{} {} added to your inventory, you dirty little cheater.".format(
         amount, item_name)
     return player.response.ok, reply
 def replaceCategory(self, user, cat_name, items_list):
     current_items = []
     current_list_items_query = db.GqlQuery('SELECT * FROM item WHERE creator = \'%s\' AND category = \'%s\'' %(user.nickname(), cat_name))
     for item_name in current_list_items_query:
         #logging.debug("current list %s" %item_name.name)
         current_items.append(item_name.name)
         
     for item_name in current_items:
         if item_name not in items_list: #items in the previous version not present in the new (to be deleted)
             #logging.debug("delete %s" %item_name)
             self.deleteItem(user, cat_name, item_name)
     
     for item_name in items_list:
         if item_name not in current_items: #items in the new version not present in the old (to be added)
             #logging.debug("add %s" %item_name)
             new_item = items.item(name=item_name, creator=user.nickname(), category=cat_name)
             new_item.put()
 def post(self):
     user = users.get_current_user()
     new_cat_name = self.request.get('newcatname', None)
     item_name = self.request.get('newitemname', None)
     import_cat_path = self.request.get('importcatpath', None)
     rename_type = self.request.get('renametype', None)
     if rename_type is not None:
         if rename_type == 'renameitem':
             cat_name = self.request.get('category', None)
             old_item_name = self.request.get('item', None)
             rename_item_name = self.request.get('renameitem', None)
             self.renameItem(user, cat_name, old_item_name, rename_item_name)
             self.editCategory(cat_name, user)
     else:       
         if import_cat_path is None:
             if item_name is None:
                 if new_cat_name is not None: #new category is to be added
                     check_if_cat_exists_query = db.GqlQuery('SELECT * FROM category WHERE creator = \'%s\' AND name = \'%s\'' %(user.nickname(), new_cat_name))
                     check_if_cat_exists = check_if_cat_exists_query.get()
                     if not check_if_cat_exists: #checks if the category already exists in the datastore, if not then adds it
                         new_category = categories.category(name=new_cat_name, creator=user.nickname())
                         new_category.put()
                     self.rendering(user)
             else:
                 category_name = self.request.get('cat_name', None) #new item to be added
                 check_if_item_exists_query = db.GqlQuery('SELECT * FROM item WHERE name = \'%s\' AND creator = \'%s\' AND category = \'%s\'' %(item_name, user.nickname(), category_name))
                 check_if_item_exists = check_if_item_exists_query.get()
                 if not check_if_item_exists: #checks if the category already has that item, if not then adds it
                     new_item = items.item(name=item_name, creator=user.nickname(), category=category_name)
                     new_item.put()
                 self.editCategory(category_name, user)
         else: #Existing category is to be imported from the given file
             tree=ET.parse(import_cat_path)
             root = tree.getroot()
             names = root.findall('NAME')
             for name in names:
                 import_cat_name = name.text
                 items_list = []
                 root_items = root.findall('ITEM/NAME')
                 for item in root_items:
                     import_item_name = item.text
                     #logging.debug("new list %s" %item.text)
                     items_list.append(import_item_name)
                 self.parseCategoryFromXML(user, import_cat_name, items_list)
             del tree
Exemple #12
0
 def setUp(self):
     self.i1 = item("abc","thing",500)
Exemple #13
0
def main():
    global pontuacao_anterior
    global enemy_time

    # estado de jogo
    game_state = 'start'

    # ticks do ultimo frame para calcular dt e fps
    ticks_last_frame = 0
    # ticks do ultimo inimigo para poder spawnar os inimigos
    ticks_last_enemy = 0

    # mude para true para ver o fps
    show_fps = False
    if show_fps:
        font = pg.font.Font(None, 20)
        clock = pg.time.Clock()

    # loop infinito que roda o jogo
    while True:
        # permite fechar a janela
        for event in pg.event.get():
            if event.type == pg.QUIT:
                pg.quit()

        # fechar a janela apretando esc
        if pg.key.get_pressed()[pg.K_ESCAPE]:
            pg.quit()

        # começa uma fase
        if pg.key.get_pressed()[pg.K_SPACE] and game_state == 'start':
            ticks_last_enemy = pg.time.get_ticks()
            game_state = 'play'

        # Calcula delta time, usado pra fazer o movimento continuo
        t = pg.time.get_ticks()
        dt = (t - ticks_last_frame)
        ticks_last_frame = t

        # roda a parte da gameplay
        if game_state == 'play':
            # responsavel por spawnar os inimigos
            dt_enemy = t - ticks_last_enemy
            if dt_enemy > enemy_time and king.active_item['clock'] == -1:
                zombies.append(
                    ini.inimigo(32, 32, win, WINDOW_WIDTH, WINDOW_HEIGHT,
                                mapa))
                ticks_last_enemy = t

            # update o jogador e as balas
            king.update(dt, mapa)

            # reseta tudo e troca de mapa se o jogador morrer
            if king.health <= 0:
                # salva a pontuação atual para mostrar na tela se inicio da poxima fase
                pontuacao_anterior = collected_itens
                # muda o game_state
                game_state = 'start'
                # reseta tudo
                reset_all()

            # checka por inimigos em todas as balas
            for bullet in king.bullets:
                killed = bullet.check_enemy(zombies)
                # check_enemy() retorna -1 se a bala não está tocando em nenhum inimigo, caso contrario, ela retorna o inimigo
                if killed != -1:
                    if enemy_time > 300:
                        enemy_time -= 5
                    # toca o som de morte do inimigo
                    enemy_death.play()
                    # remove o inimigo da lista de inimigos
                    zombies.pop(zombies.index(killed))
                    # gera um número aleatório que vai determinar o item
                    rand = round((random() * 1000) % 100)
                    # só nasce um item se o número aleatório estiver nesse intervalo
                    if 0 <= rand < 62:
                        # cria um novo item
                        items.append(it.item(killed.x, killed.y, win, rand, t))

            # updates todos itens
            for item in items:
                item.update(t)
                # checa por itens coletados e adiciona eles no dicionário
                col = item.player_colision(king)
                # player_colision retorna -1 se o item não está tocando no jogador
                if col != -1 and col != 'S_coin':
                    collected_itens[col] += 1
                # S_coins contam como 10 coins normais
                if col == 'S_coin':
                    collected_itens['coin'] += 10
                # bootas e café tem influênci mecânica até o jogador morrer
                elif col == 'boots':
                    if king.vel <= 0.35:
                        king.vel *= 1.05
                        king.d_vel *= 1.05
                    if king.vel > 0.35:
                        king.vel = 0.35
                        king.d_vel = 0.35 / (2**(1 / 2))
                elif col == 'coffee':
                    if king.shot_cooldown_normal >= 300:
                        king.shot_cooldown_normal *= 0.90
                    if king.shot_cooldown_normal < 300:
                        king.shot_cooldown_normal = 300
                # multi_shot, fast_shot e clock são consumiveis, se o jogador coleta um e não tem nada em mãos,
                # ele pode usar mais tarde, se ele já tiver um item, ele automaticamente usa o item que acabou de coletar
                elif col in ['multi_shot', 'fast_shot', 'clock', 'wheel'
                             ] and king.current_item == None:
                    king.current_item = col
                else:
                    # o item está ativo quando ele tem um valor diferente de -1, o valor dado para o item
                    # representa o tempo no momento em que o item foi usado, esse tempo é usado para calcular quando
                    # item deve desaparecer
                    king.active_item[col] = t

                # remove os itens que não existem mais
                if item.existes == False:
                    items.pop(items.index(item))

            # print(king.current_item, collected_itens)
            # update do inimigo
            for zombie in zombies:
                # quando a função update do zombie recebe -1, eles não se movem
                # se o item 'clock' está ativado, os inimigos não saem do lugar
                if king.active_item['clock'] != -1:
                    zombie.update(-1, -1, dt, mapa)
                else:
                    # caso contrario, os inimigos recebem a posição atual do jogador para poder se mover em sua direção
                    zombie.update(king.x, king.y, dt, mapa)

            # desativa o item 'clock' se ele já está ativo a tempo suficiente
            if t - king.active_item['clock'] > king.item_duration / 2:
                king.active_item['clock'] = -1

            # checa se algum inimigo está tocando o jogador e toca o som de dano
            if king.check_enemy(zombies, t):
                damage_sound.play()

            # isso é usa solução temporária para mostrar o item atual e a vida do jogador
            # o plano é mover isso para a tela do jogo

        # desenha tudo
        draw_all(game_state)

        # mostra o fps do jogo e o dicionário de itens coletados
        if show_fps:
            fps = font.render(str(int(clock.get_fps())), True,
                              pg.Color('Black'))
            win.blit(fps, (50, 50))
            itens = font.render(str(collected_itens), True, pg.Color('Black'))
            win.blit(itens, (50, 70))
            pg.display.flip()
            clock.tick(60)

        # update diplay
        pg.display.update()
Exemple #14
0
from items import item

apple = item("Apple",
             price_per_unit=1.00,
             weight_per_unit=0.1,
             priced_by_weight=True)
banana = item("Banana",
              price_per_unit=1.99,
              weight_per_unit=0.1,
              priced_by_weight=True)
beer = item("Beer",
            price_per_unit=0.50,
            weight_per_unit=0.5,
            priced_by_weight=False)
paprika = item("Paprika",
               price_per_unit=0.60,
               weight_per_unit=0.3,
               priced_by_weight=True)
broccoli = item("Broccoli",
                price_per_unit=1.20,
                weight_per_unit=1.50,
                priced_by_weight=True)
cabbage = item("Cabbage",
               price_per_unit=0.30,
               weight_per_unit=0.5,
               priced_by_weight=True)
cheese = item("Cheese",
              price_per_unit=2.00,
              weight_per_unit=0.8,
              priced_by_weight=False)
guacamole = item("Guacamole",
Exemple #15
0
import items
#創建道具
Health_potion = items.item('Health_potion',5,10)
Mana_potion = items.item('Mana_potion',5,3)

#互動
def option():  
    print('==============================')
    print('          Main Menu')
    print('------------------------------')
    print('d/D : Forward')
    print('a/A : Backward')
    print('i/I : Item')
    print('s/S : State')
    print('r/R : Save Game')
    print('q/Q : Quit')
    print('------------------------------')
    option_state = {'d':1,'D':1,'a':-1,'A':-1,'i':'item','I':'item','s':'state','S':'state','r':'save','R':'save','q':'quit','Q':'quit'}
    tmp = 0
    while tmp == 0: 
        o = input('Option : ')
        if option_state.get(o) != None:
            option_self = option_state.get(o)
            tmp = 1
        else:
            print('無效的要求 請重新輸入!')     
    return option_self
def itemact():
    print('請輸入選項來使用道具,離開請輸入 q/Q')
    print('============================')
    print(f'1 {Health_potion.name}   {Health_potion.num}個')
Exemple #16
0
def main():
    global pontuacao_anterior

    game_state = 'start'

    ticks_last_frame = 0
    ticks_last_enemy = -2000

    press_start = pg.transform.scale(pg.image.load('images/press_start.png'),
                                     (98 * 3, 14 * 3))

    # mude para true para ver o fps
    show_fps = True
    if show_fps:
        font = pg.font.Font(None, 20)
        clock = pg.time.Clock()

    # loop infinito que roda o jogo
    while True:
        # permite fechar a janela
        for event in pg.event.get():
            if event.type == pg.QUIT:
                pg.quit()
        # fechar a janela apretando esc
        if pg.key.get_pressed()[pg.K_ESCAPE]:
            pg.quit()

        if pg.key.get_pressed()[pg.K_SPACE] and game_state == 'start':
            ticks_last_enemy = pg.time.get_ticks()
            game_state = 'play'

        if game_state == 'play':
            # Calcula delta time, usado pra fazer o movimento continuo
            t = pg.time.get_ticks()
            dt = (t - ticks_last_frame)
            ticks_last_frame = t

            # responsavel por spawnar os inimigos
            dt_enemy = t - ticks_last_enemy
            if dt_enemy > 1000 and king.active_item['clock'] == -1:
                zombies.append(
                    ini.inimigo(0, WINDOW_HEIGHT // 2, 32, 32, win,
                                WINDOW_WIDTH, WINDOW_HEIGHT, mapa))
                ticks_last_enemy = t

            # update o jogador e as balas
            king.update(dt, mapa)
            if king.health <= 0:
                pontuacao_total.append(collected_itens['coin'])
                pontuacao_anterior = collected_itens
                game_state = 'start'
                reset_all()
            for bullet in king.bullets:
                killed = bullet.check_enemy(zombies)
                if killed != -1:
                    enemy_death.play()
                    zombies.pop(zombies.index(killed))
                    rand = round((random() * 1000) % 65)
                    if 0 <= rand < 65:
                        items.append(it.item(killed.x, killed.y, win, rand, t))

            # updates todos itens
            for item in items:
                item.update(t)
                # checa por itens coletados e adiciona eles no dicionário
                col = item.player_colision(king)
                if col != -1 and col != 'S_coin':
                    collected_itens[col] += 1
                if col == 'S_coin':
                    collected_itens['coin'] += 10
                elif col == 'boots':
                    if king.vel <= 0.35:
                        king.vel *= 1.05
                        king.d_vel *= 1.05
                    if king.vel > 0.35:
                        king.vel = 0.35
                        king.d_vel = 0.35 / (2**(1 / 2))
                elif col == 'coffee':
                    if king.shot_cooldown_normal >= 300:
                        king.shot_cooldown_normal *= 0.90
                    if king.shot_cooldown_normal < 300:
                        king.shot_cooldown_normal = 300
                elif col in ['multi_shot', 'fast_shot', 'clock', 'wheel'
                             ] and king.current_item == None:
                    king.current_item = col
                else:
                    king.active_item[col] = t

                if item.existes == False:
                    items.pop(items.index(item))
            # print(king.current_item, collected_itens)
            # update do inimigo
            for zombie in zombies:
                if king.active_item['clock'] != -1 and t - king.active_item[
                        'clock'] < king.item_duration:
                    zombie.update(-1, -1, dt, mapa)
                else:
                    zombie.update(king.x, king.y, dt, mapa)

            if t - king.active_item['clock'] > king.item_duration:
                king.active_item['clock'] = -1

            # checa se algum inimigo está tocando o jogador e toca o som de dano
            if king.check_enemy(zombies, t):
                damage_sound.play()

        # desenha tudo
        draw_all(game_state, press_start)

        # mostra o fps do jogo
        if show_fps:
            fps = font.render(str(int(clock.get_fps())), True,
                              pg.Color('Black'))
            win.blit(fps, (50, 50))
            itens = font.render(str(collected_itens), True, pg.Color('Black'))
            win.blit(itens, (50, 70))
            pg.display.flip()
            clock.tick(60)

        # update diplay
        pg.display.update()
Exemple #17
0
#python

import rooms
import items
import people
import npcs
import weapons
import armors

centralRooms=[
	#(location, adjacent rooms[n,s,e,w], description, dark, inventory, containers, monsters, bed, people, secret passageways[n,s,e,w])
    rooms.room(0, [3,1,-1,-1], "\nYou are in a small cellar.\nThere is a stairwell to the north.\nThere is a small crack in the wall to the south that you may be able to fit through.", True, [], {}, [], False, [], [False, False, False, False]),

	rooms.room(1, [0,2,-1,-1], "\nYou are in a small winding rocky corridor.\nThere is a small opening to the north.\nThe corridor continues south.", True, [], {}, [], False, [], [False, False, False, False]),
	
	rooms.room(2, [1,-1,-1,-1], "\nYou are in a small cave.\nThere is a waterfall filling a pool of water to the south.\nThere is a small crack in the wall to the north that you may be able to fit through.", True, [items.item("gem")], {}, [npcs.npc("bugbear",10,2,4)], False, [], [False, False, False, False]),
	
	rooms.room(3, [5,0,4,6], "\nYou are in a small kitchen.\nThere is a table with three chairs in front of you.\nIn the northwest corner of the room there is an oven.\nIn the northeast corner there is a cupboard.\nThere are doors to the north, east, and west.\nTo the south is a staricase descending down.", False, [], {"cupboard":[False,items.item("garlic"),items.item("salt"),items.healthPotion()]}, [], False, [], [False, False, False, False]),
	
	rooms.room(4, [7,-1,10,3], "\nYou are in the backyard of an old log house.\nThere is an old battered door on the side of the house to your west.\nThere are paths into the woods to the east and north.", False, [], {}, [], False, [], [False, False, False, False]),
	
	rooms.room(5, [-1,3,-1,8], "\nYou are in a rectangular room.\nThere is a long table that appears to have hosted many meals in the center of the room.\nThere is cake on the table.\nOutside of the table and doors to the south and west there is not much here.", False, [], {}, [], False, [], [False, False, False, False]),
	
	rooms.room(6, [8,-1,3,9], "\nYou are in a small cozy room.\nThere is a fireplace that does not appear to have been used in quite some time.\nThere are two lounge charis in the center of the room.\nThere are doors to the north, east, and west.\nThe west wall has two boarded up windows on either side of the door.", False, [], {}, [], False, [], [False, False, False, False]),
	
	rooms.room(7, [-1,-1,4,9], "\nYou are on a wooded pathway.\nThe path continues to the east and west.", False, [], {}, [], False, [], [False, False, False, False]),
	
	rooms.room(8, [-1,6,5,-1], "\nYou are in a tiny room.\nThere is a disheveled bed in the corner of the room.\nThere are doors to the south and east.", False, [], {}, [], True, [], [False, False, False, False]),
	
	rooms.room(9, [7,12,6,-1], "\nYou are on the porch of an old wooden house.\nThe house has a door to the east.\nOn either side of the door are boarded up windows.\nThere is a mail box infront of the door.\nThere is a garden path to the north and a road leading south.", False, [], {"mailbox":[False,items.item("letter")]}, [], True, [], [False, False, False, False]),
import rooms
import items
import weapons
import money
import workbench
import descriptions

# Initialize all the items
small_bowl = items.item('Small bowl', descriptions.small_bowl_description, 1)
large_bowl = items.item('Large bowl', descriptions.large_bowl_description, 2)
medium_bowl = items.item('Medium bowl', descriptions.medium_bowl_description,
                         1)
slimey_goo = items.item('Slime', descriptions.slimey_goo_description, 0)

small_emerald = items.item('small Emerald',
                           descriptions.small_emerald_description, 10)
large_diamond = items.item('large Diamond',
                           descriptions.large_diamond_description, 25)
pile_of_gold_coins = items.item('Gold coins',
                                descriptions.pile_of_gold_coins_description,
                                20)

thatched_matt = items.item('A thatched matt',
                           descriptions.thatched_matt_description, 2)
floor_chains = items.item('floor chains',
                          descriptions.floor_chains_description, 1)

wierd_hook = items.item('A strange hook', descriptions.wierd_hook_description,
                        4)
hanging_chains = items.item('Hanging chains',
                            descriptions.hanging_chains_description, 1)
Exemple #19
0
                    print(current_workbench)
                    for widgets in current_workbench.contains:
                        if widgets.name.lower().find(item) != -1:
                            print(widgets)

def parse_instructions(instruction):
    instructions = instruction.split()
    return instructions

name = input('Tell me your name adventurer : ')

playing = True
player = player.player(name)
os.system('cls')
current_room = 'entry_room'
current_workbench = items.item()
print(initialize_dungeon.entry_room)

while playing:
    instruction = input('What would you like to do: \n').lower()
    if instruction == '':
        os.system('cls')
        print(help_strings.help_look)
    else:
        instructions = parse_instructions(instruction)

        if (instructions[0] == 'go' or instructions[0] == 'walk' or instructions[0] == 'move'):
            if (instructions[1] == 'west' and current_room == 'entry_room'):
                os.system('cls')
                current_room = 'hallway'
                print(initialize_dungeon.hallway)
	def addItem(self, name, price, date=None): 
		newItem = item(name,price, date)
		self.inStoreItem.append(newItem)
Exemple #21
0
    def create_item_from_id(self, id_):
        try:
            item_data = self.data[id_]
        except KeyError:
            return False

        # flags
        item_flags = item_data["flags"]
        item_dynamic = "DYNAMIC" in item_flags

        if not item_dynamic:
            if id_ in self.items:
                return self.items[id_]

        # create new instance of item plural, icon, color, description, description_long,  weight, volume
        item_type = item_data["type"]

        item_name = item_data["name"]
        item_plural = item_data["plural"]
        item_slot = item_data["slot"]
        if item_slot == "None":
            item_slot = None
        item_icon = item_data["icon"]
        item_color = item_data["color"]
        item_description = item_data["description"]
        try:
            item_description_long = item_data["description long"]
        except KeyError:
            item_description_long = None
        item_weight = item_data["weight"]
        item_volume = item_data["volume"]

        try:
            item_buffs = item_data["buffs"]
        except KeyError:
            item_buffs = {}

        try:
            item_multipliers = item_data["multipliers"]
        except KeyError:
            item_multipliers = {}

        if item_type == "standard":
            item_obj = items.item(type=item_type,
                                  id_=id_,
                                  name=item_name,
                                  plural=item_plural,
                                  slot=item_slot,
                                  icon=item_icon,
                                  color=item_color,
                                  description=item_description,
                                  description_long=item_description_long,
                                  weight=item_weight,
                                  volume=item_volume,
                                  buffs=item_buffs,
                                  multipliers=item_multipliers)

        elif item_type == "melee weapon":
            item_base_damage = item_data["base damage"]
            item_actions_ids = item_data["actions"]

            item_actions = []

            # convert action ids into objects
            for action_id in item_actions_ids:
                item_actions.append(
                    self.game.action_generator.get_action_from_id(action_id))

            item_obj = items.melee_weapon(
                type=item_type,
                id_=id_,
                name=item_name,
                plural=item_plural,
                slot=item_slot,
                icon=item_icon,
                color=item_color,
                description=item_description,
                description_long=item_description_long,
                weight=item_weight,
                volume=item_volume,
                buffs=item_buffs,
                multipliers=item_multipliers,
                base_damage=item_base_damage,
                actions=item_actions)

        if not item_dynamic:
            self.items[id_] = item_obj

        return item_obj