Ejemplo n.º 1
0
 def clone(self):
     newBoard = []
     ants1 = []
     ants2 = []
     cons1 = []
     cons2 = []
     cons3 = []
     food1 = self.inventories[PLAYER_ONE].foodCount
     food2 = self.inventories[PLAYER_TWO].foodCount
     for col in xrange(0,len(self.board)):
         newBoard.append([])
         for row in xrange(0,len(self.board)):
             newLoc = self.board[col][row].clone()
             newBoard[col].append(newLoc)
             #Organize constructions into inventories
             if newLoc.constr != None and type(newLoc.constr) is Building and newLoc.constr.player == PLAYER_ONE:
                 cons1.append(newLoc.constr)
             elif newLoc.constr != None and type(newLoc.constr) is Building and newLoc.constr.player == PLAYER_TWO:
                 cons2.append(newLoc.constr)
             #Organize ants into inventories
             if newLoc.ant != None and newLoc.ant.player == PLAYER_ONE:
                 ants1.append(newLoc.ant)
             elif newLoc.ant != None and newLoc.ant.player == PLAYER_TWO:
                 ants2.append(newLoc.ant)
     for constr in self.inventories[NEUTRAL].constrs:
         cons3.append(constr.clone())
     newInventories = [Inventory(PLAYER_ONE, ants1, cons1, food1),
                       Inventory(PLAYER_TWO, ants2, cons2, food2),
                       Inventory(NEUTRAL, [], cons3, 0) ]
     return GameState(newBoard, newInventories, self.phase, self.whoseTurn)
Ejemplo n.º 2
0
    def load_entities(self):
        grid = self.create_grid(self.map_file)

        entities = []

        for row in range(grid.shape[0]):
            for col in range(grid.shape[1]):
                entity = None

                if grid[row][col] == 1:
                    entity = Player(col, row, Inventory(2, 10))
                elif grid[row][col] == 2:
                    inventory = Inventory(3, 5)
                    inventory.add_item(DamageItem())
                    entity = Enemy(col, row, inventory)
                elif grid[row][col] == 3:
                    entity = Wall(col, row)
                elif grid[row][col] == 4:
                    entity = Treasure(col, row, [DamageItem()])
                elif grid[row][col] == 5:
                    entity = EndLevel(col, row)

                if entity:
                    entities.append(entity)

        return entities
Ejemplo n.º 3
0
 def setup_state(self):
     board = [[Location((col, row)) for row in xrange(0, c.BOARD_LENGTH)]
              for col in xrange(0, c.BOARD_LENGTH)]
     p1Inventory = Inventory(c.PLAYER_ONE, [], [], 0)
     p2Inventory = Inventory(c.PLAYER_TWO, [], [], 0)
     neutralInventory = Inventory(c.NEUTRAL, [], [], 0)
     return GameState(board, [p1Inventory, p2Inventory, neutralInventory],
                      c.SETUP_PHASE_1, c.PLAYER_ONE)
Ejemplo n.º 4
0
    def getBlankState():
        board = []
        for y in range(10):
            tmp = []
            for x in range(10):
                tmp.append(Location((x, y)))
            board.append(tmp)

        invents = [
            Inventory(PLAYER_ONE, [], [], 0),
            Inventory(PLAYER_TWO, [], [], 0),
            Inventory(NEUTRAL, [], [], 0)
        ]
        return GameState(board, invents, SETUP_PHASE_1, PLAYER_ONE)
Ejemplo n.º 5
0
def run_tests():
    """Test Store class."""

    # Create Inventory
    item1 = Item("Blue Wool", "2 Stacks", 1)
    item2 = Item("Red Wool", "2 Stacks", 1)
    inv = Inventory()
    inv.add_item(item1)
    inv.add_item(item2)

    # Create Store
    store = Store("All Australian Wool", 300, 400, "All your wool Needs!", inv)
    print(store)

    # Test update_description
    store.update_description("Lots of wool Colours")
    print(store)

    # Test update Location
    store.update_location(509, 5002)
    print(store)

    # Test list Inventory
    for item in store.inventory.items:
        print(item)
Ejemplo n.º 6
0
    def __init__(self):
        super().__init__()

        self.stage_level = 1
        self.ended = False
        self.animation_update_time = 0.13
        self.animation_update_time = 0.13

        self.map = Map()
        self.player = Player("image/player.png",
                             x_pos=0,
                             y_pos=0,
                             stat_hp=25,
                             stat_str=5,
                             stat_arm=1)
        self.staircase = Structure.Staircase(0, 0)
        self.player.position, self.staircase.position, character_list, object_list\
            = self.map.generate_map(self.stage_level)
        self.character_list = [self.player] + character_list
        self.object_list = [self.staircase] + object_list

        self.draw = Draw()
        self.inventory = Inventory(self.draw.view)
        self.setWindowTitle("ADRogue")
        self.setStyleSheet("background-color: #B7A284")
        self.setCentralWidget(self.draw)

        self.map.set_object_map(self.object_list)
        self.map.set_character_map(self.character_list)

        self.draw.setFixedSize(QSize(1294, 810))
        self.update_animation_thread = threading.Thread(
            target=self.update_animation)

        self.update_animation_thread.start()
Ejemplo n.º 7
0
 def toInventory(self, checked):
     if self.inventory_window is None:
         self.inventory_window = Inventory()
         self.inventory_window.show()
     else:
         self.inventory_window.close()
         self.inventory_window = None
Ejemplo n.º 8
0
    def __init__(self):
        self.name = "Character"
        self.player_name = "Zorg"
        self.character_level = 1
        self.hp = 100
        self.location_x, self.location_y = (0, 0)

        self.inventory = Inventory()
        self.inventory.add_to_pouch("Gold", 15)
        self.inventory.add_to_inventory(Items.Fist(), 1)
        self.inventory.equip_main_hand("Fist")

        self.character_class = "No Class"
        self.strength = 10
        self.dexterity = 10
        self.constitution = 10
        self.intellect = 10
        self.attributes = {
            "Strength: ": self.strength,
            "Dexterity: ": self.dexterity,
            "Constitution: ": self.constitution,
            "Intellect: ": self.intellect
        }

        self.weapon = self.inventory.get_main_hand_equipped()
        self.dmg_mod = 2
Ejemplo n.º 9
0
    def __init__(self,
                 name="Player",
                 health=20,
                 shield=10,
                 dodge=0,
                 parry=0,
                 criticalHit=1,
                 mana=10,
                 damageMin=1,
                 damageMax=2,
                 armor=0,
                 xp=0,
                 inventory=Inventory()):
        Character.__init__(self, name, health, shield, dodge, parry,
                           criticalHit, mana, damageMin, damageMax, armor, xp,
                           inventory)

        self.statistics = Statistics()
        self.success = {
            "monster_hunter": Success(name="Monster hunter"),
            "commercial": Success(name="Commercial"),
            "lucky": Success(name="Lucky"),
            "compulsive_buyer": Success(name="Compulsive buyer"),
            "vendor": Success(name="Vendor on the run"),
            "consumer": Success(name="Consumer"),
            "the_end": Success(name="The End")
        }
Ejemplo n.º 10
0
 def __init__(self):
     """
     creates a new program
     """
     self.input = Input()
     self.output = Output()
     self.inventory = Inventory()
     self.choice = None
Ejemplo n.º 11
0
 def __init__(self, env):
     random.seed(5)
     self.clock = env
     # Create Instances of main components
     self.floor = Floor(env)
     self.inventory = Inventory(env, self.floor)
     self.robot_scheduler = RobotScheduler(env, self.floor)
     self.order_control = OrderControl(env, self.inventory)
Ejemplo n.º 12
0
 def __init__(self, x, y):
     self.x = x
     self.y = y
     self.ammo = 10
     self.healthPacks = 3
     self.inventory = Inventory()
     self._current_weapon = None
     self._health = 20
     self._maxHealth = self._health
Ejemplo n.º 13
0
 def __init__(self):
     self.db = DB()
     self.__employees = Employees(self)
     self.__vendors = Vendors(self)
     self.__time_clock = TimeClock(self)
     self.__orders = Orders(self)
     self.__inventory = Inventory(self)
     self.__register = Register(self)
     self.account = Account()
Ejemplo n.º 14
0
 def __init__(self):
     super().__init__()
     self._Health = 100
     self._Armor = 0
     self._MaxHealth = 100
     self._MaxArmor = 100
     self._Dead = False
     self._Inventory = Inventory()
     self._MoveAble = True
Ejemplo n.º 15
0
 def __create_pending(self, num_sublots, arrival, today):
     # return pending_lst or None
     pending_q = self.product.get_sublot_quantity()
     pending_inv = []
     for i in range(num_sublots):
         sell = today + timedelta(days=self.product.get_sell_by())
         inv = Inventory(self.product.grp_id, 0, 0, pending_q, arrival,
                         sell)
         pending_inv.append(inv)
     return pending_inv
Ejemplo n.º 16
0
def create_app(inventory_file_path="inventory.txt"):
    app = web.Application()
    app["inventory"] = Inventory(load_inventory_from_file(inventory_file_path))
    app.add_routes([
        web.get('/get-categories-for-store/{store_id}',
                get_categories_for_store),
        web.get('/get-item-inventory/{item_name}', get_item_inventory),
        web.get('/get-median-for-category/{category}',
                get_median_for_category),
    ])
    return app
Ejemplo n.º 17
0
 def testUse(self):
     dummy = Character('dummy', 20, 0, 0,
                       Inventory([HealingPotion('normal')]))
     dummy.hp = 5
     charController = CharacterController()
     charController.makeUse(dummy, dummy.inventory.items[0], dummy)
     self.assertEqual(dummy.hp, 15)
     self.assertFalse(dummy.inventory.items)
     dummy.pickup(self.potion)
     charController.makeUse(dummy, dummy.inventory.items[0], dummy)
     self.assertEqual(dummy.hp, 20)
Ejemplo n.º 18
0
    def fastclone(self):
        newBoard = None
        #For speed, preallocate the lists at their eventual size
        ants1 = [None] * len(self.inventories[PLAYER_ONE].ants)
        ants2 = [None] * len(self.inventories[PLAYER_TWO].ants)
        cons1 = [None] * len(self.inventories[PLAYER_ONE].constrs)
        cons2 = [None] * len(self.inventories[PLAYER_TWO].constrs)
        cons3 = [None] * len(self.inventories[NEUTRAL].constrs)
        antIndex1 = 0
        antIndex2 = 0
        conIndex1 = 0
        conIndex2 = 0
        conIndex3 = 0

        #clone all the entries in the inventories
        for ant in self.inventories[PLAYER_ONE].ants:
            ants1[antIndex1] = ant.clone()
            antIndex1 += 1
        for ant in self.inventories[PLAYER_TWO].ants:
            ants2[antIndex2] = ant.clone()
            antIndex2 += 1
        for constr in self.inventories[PLAYER_ONE].constrs:
            cons1[conIndex1] = constr.clone()
            conIndex1 += 1
        for constr in self.inventories[PLAYER_TWO].constrs:
            cons2[conIndex2] = constr.clone()
            conIndex2 += 1
        for constr in self.inventories[NEUTRAL].constrs:
            cons3[conIndex3] = constr.clone()
            conIndex3 += 1

        #clone the list of inventory objects
        food1 = self.inventories[PLAYER_ONE].foodCount
        food2 = self.inventories[PLAYER_TWO].foodCount
        newInventories = [
            Inventory(PLAYER_ONE, ants1, cons1, food1),
            Inventory(PLAYER_TWO, ants2, cons2, food2),
            Inventory(NEUTRAL, [], cons3, 0)
        ]

        return GameState(newBoard, newInventories, self.phase, self.whoseTurn)
Ejemplo n.º 19
0
 def __init__(self, env):
     # Seed in which the randomness of the simulation pans out
     # Change the number to see different Order schedules
     random.seed(5)
     # env is the SimPy simulation environment. It works as our world clock for this simulation
     # env is created and can be adjusted at the bottom of Warehouse.py
     self.clock = env
     # Create Instances of main components
     self.floor = Floor(env)
     self.inventory = Inventory(env, self.floor)
     self.robot_scheduler = RobotScheduler(env, self.floor)
     self.order_control = OrderControl(env, self.inventory)
Ejemplo n.º 20
0
    def __init__(self, x=0, y=0):
        self.x = x
        self.y = y
        self.status = -1
        self.area = None

        self.name = "BigPigMoon"
        self.hp = 100
        self.damage = 1
        self.level = 1
        self.damage_resistance = 0.5

        self.inventory = Inventory()
Ejemplo n.º 21
0
    def test_get_median_for_category_simple(self):
        items = [
            {
                "store": 1,
                "category": 1,
                "item_name": "The Item",
                "items": 4,
                "price": 200
            },
        ]

        inventory = Inventory(items)

        assert inventory.get_median_for_category(1) == 200
Ejemplo n.º 22
0
    def new(self):
        """Game class method to start a new game.

        """
        # start a new game
        # initialise sprite groups
        self.all_sprites = pygame.sprite.LayeredUpdates()
        self.walls = pygame.sprite.LayeredUpdates()
        self.gui = pygame.sprite.LayeredUpdates()
        self.enemies = pygame.sprite.LayeredUpdates()
        self.item_drops = pygame.sprite.LayeredUpdates()

        # instantiate dungeon
        self.dungeon = Dungeon(self, cfg.DUNGEON_SIZE)
        if self.loaded:
            self.dungeon.tileset = self.saveGame.data['tileset']
        else:
            self.dungeon.create()

        self.WSign = self.imageLoader.WarnSign
        self.WSign2 = self.imageLoader.WarnSign2

        self.inventory = Inventory(self)

        # spawn the player in the middle of the room
        self.player = Player(self, (cfg.WIDTH // 2, cfg.TILESIZE * 12))

        self.currentpistol = Pistol(self, self.player)
        self.currentmachine = MachineGun(self, self.player)

        if self.pistolpick == True:
            self.player.itemA = self.currentpistol

        elif self.machinegunpick == True:
            self.player.itemA = self.currentmachine

        # load settings
        if self.loaded:
            self.loadSavefile()

        # spawn the new objects (invisible)
        self.prev_room = self.dungeon.current_room_index
        self.transitRoom(self, self.dungeon)

        # create a background image from the tileset for the current room
        self.background = self.tileRoom(self, self.imageLoader.tileset,
                                        self.dungeon.current_room_index)

        self.run()
Ejemplo n.º 23
0
 def __init__(self,
              name,
              hp=10,
              strength=5,
              toughness=1,
              inventory=None,
              equipment=None):
     self.name = name
     self.maxHp = hp
     self.hp = hp
     self.strength = strength
     self.toughness = toughness
     self.equipment = Equipment() if equipment is None else equipment
     self.inventory = Inventory([HealingPotion()
                                 ]) if inventory is None else inventory
Ejemplo n.º 24
0
 def __init__(self):
     self.name = 'Richard'
     self.max_hp = 50
     self.hp = self.max_hp
     self.lvl = 1
     self.exp = 0
     self._expForLvlUp = 30
     self.damage = 10
     self.defence = 0
     self.atk = ''
     self.defend = ''
     self.inventory = Inventory()
     self.equipment = Equipment()
     self.gold = 0
     self.rewards = Rewards()
Ejemplo n.º 25
0
 def __init__(self,
              name="Zombie",
              health=20,
              shield=2,
              dodge=0,
              parry=0,
              criticalHit=1,
              mana=0,
              damageMin=2,
              damageMax=4,
              armor=0,
              xp=0,
              inventory=Inventory()):
     Character.__init__(self, name, health, shield, dodge, parry,
                        criticalHit, mana, damageMin, damageMax, armor, xp,
                        inventory)
Ejemplo n.º 26
0
def main():
    # Set up Rick's guitar inventory
    inventory = Inventory()
    initialize_inventory(inventory)

    what_erin_likes = Guitar("", 0, "fender", "Stratocastor", "electric",
                             "Alder", "Alder")

    guitar = inventory.search(what_erin_likes)
    if guitar != None:
        print("Erin you might like this", guitar.builder, guitar.model,
              guitar.type, "guitar:\n", guitar.back_wood, "back and sides,\n",
              guitar.top_wood, "top.\n You can have it for only $",
              guitar.price, "!")
    else:
        print("Sorry, Erin, we have nothing for you.")
def run_tests():
    """Test Inventory class."""

    # Test empty Inventory (defaults)
    print("Test empty Inventory:")
    inv = Inventory()
    assert not inv.items  # an empty list is considered False

    # Test adding an Item with values
    print("\nTest adding Item:")
    inv.add_item(Item("Red Wool", "2 Stacks", 2))
    inv.add_item(Item("Green Wool", "2 Stacks", 2))

    # Test list_inventory
    for item in inv.list_items():
        print(item)
Ejemplo n.º 28
0
def runWarehouse():
    env = simpy.Environment()
    # Test Instances of Areas
    floor = Floor(env)
    inventory = Inventory(env)
    robotScheduler = RobotScheduler(env, floor)
    orderControl = OrderControl(env)

    # Place items into shelves within ShelfAreas
    shelveStock()

    orders_to_complete = orderControl.allOrders
    order_one = orders_to_complete[0]

    processOrder(floor, inventory, order)
    floor.printMap()
Ejemplo n.º 29
0
    def __init__(self, name, north, east, south, west, description=""):
        if name.endswith("*"):
            self.name = name[:-1]
            self.visited = True
        else:
            self.name = name
            self.visited = False
        self.description = description

        self.surrounding = {
            "north": north,
            "east": east,
            "south": south,
            "west": west
        }
        self.inventory = Inventory(self)
        self.test_tile_validity()
Ejemplo n.º 30
0
    def __init__(self):

        self.heroRace = Race()
        self.heroClass = ""

        #Получаем Данные от пользователя
        self.getName()
        self.getClass()
        self.getRace()

        super().__init__(self.name, self.heroRace.stats, Elements(), 0)

        ## Инвентарь героя
        self.inventory = Inventory()
        ## Обмундирование героя
        self.equipment = Equipment()
        ## Карман с Лечебками героя
        self.potionsPocket = PotionsPocket()