Exemplo n.º 1
0
    def setUp(self):
        # set up Inventory instances to test length and weight restrictions
        self.inv = inventory.Inventory()
        self.inv_len = inventory.Inventory(max_len=3)
        self.inv_wt = inventory.Inventory(max_weight=7)

        # set up Item objects for use
        self.generic1 = inventory.Item('item1')
        self.generic2 = inventory.Item('item2')
        self.generic3 = inventory.Item('item3')
        self.generic4 = inventory.Item('item4')
        self.light = inventory.Item('light', weight=1)
        self.medium = inventory.Item('medium', weight=4)
        self.heavy = inventory.Item('heavy', weight=8)
Exemplo n.º 2
0
def add_new_item(full_inventory):
    """
    Add new item to inventory
    """
    # TODO: this should clearly not be a constant or a global
    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rental_price = input("Enter item rental price: ")

    # Get price from the market prices module
    item_price = market_prices.get_latest_price(item_code)

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")
    if is_furniture.lower() == "y":
        item_material = input("Enter item material: ")
        item_size = input("Enter item size (S,M,L,XL): ")
        new_item = furniture.Furniture(item_code, item_description, item_price,
                                       item_rental_price, item_material, item_size)
    else:
        is_electric_appliance = input("Is this item an electric appliance? (Y/N): ")
        if is_electric_appliance.lower() == "y":
            item_brand = input("Enter item brand: ")
            item_voltage = input("Enter item voltage: ")
            new_item = electric_appliances.ElectricAppliances(item_code, item_description,
                                                              item_price,
                                                              item_rental_price,
                                                              item_brand, item_voltage)
        else:
            new_item = inventory.Inventory(item_code, item_description, item_price,
                                           item_rental_price)
    full_inventory[item_code] = new_item.return_dictionary()
    print("New inventory item added")
def process_file():

    #Create empty dictionary
    inventory_dict = {}

    #Open inventory data
    inventory_data = open(INVENTORY_FILE, "r")

    #Read data from file
    for line in inventory_data:

        #Split item
        values = line.split(",")

        #Store information in separate variable
        item_id = values[0]
        name = values[1]
        quantity = int(values[2])
        price = float(values[3])

        #Create an instance
        inventory_item = inventory.Inventory(item_id, name, quantity, price)

        #Add item to dictionary
        inventory_dict[item_id] = inventory_item

    #Close file
    inventory_data.close()

    #Return dictionary
    return inventory_dict
Exemplo n.º 4
0
    def create(self, event=None) -> None:
        """Check that valid imputs are given, if so then open a new tab with the inventory."""
        # check that a name is given
        if self.name_entry.get() != '':
            # check that the password is long enough
            if len(self.pass_entry.get()) > 6:
                # check that the passwords match
                if self.pass_entry.get() == self.pass2_entry.get():

                    self.window.remove_tab(self.frame)
                    inven = inventory.Inventory(name=self.name_entry.get(),
                                                password=self.pass_entry.get())
                    self.window.inven_instances.update({
                        self.name_entry.get():
                        invenscreen.InvenScreen(self.window, inven)
                    })

                else:
                    messagebox.showinfo('Error', 'Passwords do not match.')
                    self.pass_entry.delete(0, 'end')
                    self.pass2_entry.delete(0, 'end')
            else:
                messagebox.showinfo(
                    'Error', 'Password must be at least 7 characters long.')
                self.pass_entry.delete(0, 'end')
                self.pass2_entry.delete(0, 'end')
        else:
            messagebox.showinfo('Error', 'Name cannot be left blank.')
Exemplo n.º 5
0
    def __init__(self, name):
        self.name = name
        self.weapon = weapons.WoodenStaff
        self.max_health = 80
        self.damage_done = 0
        self.current_health = 80
        self.alive = True
        self.class_name = "Mage"
        self.strength = 5
        self.dexterity = 6
        self.max_mana = 30
        self.current_mana = 30
        self.fireball = spells.Fireball
        self.frozen_arrow = spells.FrozenArrow
        self.meteor_shower = spells.MeteorShower
        self.inventory = inventory.Inventory(f"{self.weapon.weapon_type}", 1,
                                             2)

        self.spell_list = [
            colored("\nMeteor Shower", "yellow"),
            colored("Fireball", "yellow"),
            colored("Frozen Arrow", "yellow")
        ]
        self.mana_costs = [
            "(15 mana)",
            "(10 mana)",
            "(10 mana)",
        ]

        print(
            f"Your mage's name is {self.name} and he is armed with a {self.weapon.weapon_type}."
        )
Exemplo n.º 6
0
 def __init__(self, name, health):
     self.name = name
     self.max_health = health
     self.health = health
     self.inventory = inventory.Inventory()
     print("Player {0} created. \nHealth:{1}".format(
         self.name, self.health))
Exemplo n.º 7
0
def seek_inventory():
    try:
        d = defaultdict(int)
        d.update(json.load(open('data.json', 'r')))

        for inventory_position in inventory.Inventory():
            while True:
                mouse.click(SEEK)
                mouse.click(SEAL)
                kb.press_and_release('enter')
                mouse.click(inventory_position)

                time.sleep(0.1)
                kb.combo('ctrl', 'c')
                data = clip.get_clipboard_data()

                try:
                    d[data.split('\r\n')[2]] += 1
                except:
                    print('F**K')

                if check_bad_prophecy(data):
                    delete_prophecy()
                else:
                    break
    finally:
        d = {
            k: v
            for k, v in d.items()
            if k.lower() not in [l.lower() for l in BAD_PROPHECIES]
        }
        json.dump(d, open('data.json', 'w'))
Exemplo n.º 8
0
def add_new_item():
    """Adds a new item to the inventory based on user-inputted
    item code, description, and rental price.
    """
    # global __full_inventory__
    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rental_price = input("Enter item rental price: ")

    # Get price from the market prices module
    item_price = market_prices.get_latest_price(item_code)

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")
    if is_furniture.lower() == "y":
        item_material = input("Enter item material: ")
        item_size = input("Enter item size (S,M,L,XL): ")
        new_item = furniture.Furniture(item_code, item_description, item_price,
                                       item_rental_price, item_material,
                                       item_size)

    else:
        is_electric_appliance = input("Is this item an electric "
                                      "appliance? (Y/N): ")
        if is_electric_appliance.lower() == "y":
            item_brand = input("Enter item brand: ")
            item_voltage = input("Enter item voltage: ")
            new_item = electric_appliances.ElectricAppliances(
                item_code, item_description, item_price, item_rental_price,
                item_brand, item_voltage)
        else:
            new_item = inventory.Inventory(item_code, item_description,
                                           item_price, item_rental_price)
    __full_inventory__[item_code] = new_item.return_as_dictionary()
    print("New inventory item added")
Exemplo n.º 9
0
 def __init__(self):
     # FLUFF
     self.name = ""
     self.character_class = ""
     self.character_race = ""
     self.inventory = inventory.Inventory()
     # LEVELING UP
     self.level = 1
     self.points = 0
     self.current_experience = 0
     self.next_lvl_experience = 15
     # BASIC STATS
     self.strength = 1
     self.dexterity = 1
     self.intelligence = 1
     # HP AND MANA
     self.max_hp = 10
     self.current_hp = 10
     self.max_mana = 10
     self.current_mana = 10
     # ATTACK
     self.weapon = weapons.WeaponsPool.weapons[1]
     self.attack = self.strength + self.weapon.attack
     # DEFENCE
     self.head = armors.ArmorsPool.armors[0]
     self.torso = armors.ArmorsPool.armors[1]
     self.arms = armors.ArmorsPool.armors[2]
     self.legs = armors.ArmorsPool.armors[3]
     self.shield = armors.ArmorsPool.armors[4]
     self.armor = self.head.armor + self.torso.armor + self.arms.armor + self.legs.armor + self.shield.armor
     # ADVANCED STATS
     self.speed = self.dexterity * 7
     self.dodge_chance = int(self.dexterity - self.armor // 2)
     # UI
     self.ui = ui.UI()
Exemplo n.º 10
0
def add_new_item():
    """ Add an item to the inventory """
    item_code = input("Enter item code: ")
    item_description = input("Enter item description: ")
    item_rental_price = input("Enter item rental price: ")

    # Get price from the market prices module
    item_price = pri.get_latest_price(item_code)

    is_furniture = input("Is this item a piece of furniture? (Y/N): ")
    if is_furniture.lower() == "y":
        item_material = input("Enter item material: ")
        item_size = input("Enter item size (S,M,L,XL): ")
        new_item = fur.Furniture(item_code, item_description, item_price,
                                 item_rental_price, item_material, item_size)
    else:
        is_electric_appliance = input(
            "Is this item an electric appliance? (Y/N): ")
        if is_electric_appliance.lower() == "y":
            item_brand = input("Enter item brand: ")
            item_voltage = input("Enter item voltage: ")
            new_item = e_app.ElectricAppliances(item_code, item_description,
                                                item_price, item_rental_price,
                                                item_brand, item_voltage)
        else:
            new_item = inv.Inventory(item_code, item_description, item_price,
                                     item_rental_price)
    FULL_INVENTORY[item_code] = new_item.return_as_dictionary()
    print("New inventory item added")
Exemplo n.º 11
0
 def get(self):
     user = self.get_user()
     if not user:
         return self.redirect('/')
     inv = inventory.Inventory(self.conn, self.cur)
     recommended_recipes = inv.get_recommended_recipes(user['id'])
     context = {"recommended_recipes": recommended_recipes}
     self.render_response('recommended_recipes_page.html', **context)
Exemplo n.º 12
0
def dump_inventory():
    mouse.click(STASH)

    with kb.hold('ctrl'):
        for inventory_position in inventory.Inventory():
            mouse.click(inventory_position)

    mouse.click(CLOSE_STASH)
Exemplo n.º 13
0
def filter_prophecies():
    time.sleep(1)
    for inventory_position in inventory.Inventory():
        mouse.move(inventory_position)
        kb.combo('ctrl', 'c')
        data = clip.get_clipboard_data()
        if check_bad_prophecy(data):
            delete_prophecy()
Exemplo n.º 14
0
def main():

    i1 = item.Item('Pillow', {'Amount': '10', 'Color': 'White'})
    i2 = item.Item('Blankets', {'Amount': '13', 'Size': 'Large'})

    cat = category.Category('Bed Supplies', [i1, i2])

    inv = inventory.Inventory('Warehouse', 'password', [cat], [i1])
    inv.save()
Exemplo n.º 15
0
def box_scene(main):
    """Создание инвентаря"""
    Scene = cocos.scene.Scene()

    background_layer = StaticImage("Resources/box_bg.png", 1920/2, 1080/2, 1)
    Scene.add(background_layer)

    Scene.add(inventory.Inventory(main))
    return Scene
Exemplo n.º 16
0
def getPorts():
    global MovieServer, ReviewServer, Baseport
    import inventory
    allserver = inventory.Inventory()
    Baseport = allserver.callBasePort(20000)
    allserver.findPorts(socket.gethostname(), NumMovie, NumReview, Baseport)
    MovieServer = allserver.getMoviePorts()
    ReviewServer = allserver.getReviewPorts()
    allserver.saveJson('./')
Exemplo n.º 17
0
 def post(self):
     user = self.get_user()
     if not user:
         return self.redirect('/')
     ingredient_name = self.request.POST["ingredient_name"]
     inv = inventory.Inventory(self.conn, self.cur)
     search_ingredients = inv.search_ingredient(ingredient_name)
     context = {"search_ingredients": search_ingredients}
     self.render_response('search_ingredient_page.html', **context)
Exemplo n.º 18
0
 def load_save(self, save):
     with open("data/save/{}.json".format(save), 'r',
               encoding='utf-8') as file:
         self._save = json.load(file)
     self.save_name = save
     if self.get_save_value("last_save", 0) == 0:
         self.save_data("last_save", int(time.time()))
     self.pokedex: dict[str, int] = self.get_save_value("pokedex", {})
     self.inv = inventory.Inventory(self.get_save_value("inventory", {}))
Exemplo n.º 19
0
def dict_to_inven(inven_dict: dict) -> 'Inventory':
    """returns an inventory object from a dict representing that inventory"""

    items = [
        item.Item(i['name'],
                  [item.Property(n, v) for n, v in i['properties'].items()])
        for i in inven_dict['items']
    ]
    return inventory.Inventory(inven_dict['name'], inven_dict['password'],
                               items)
Exemplo n.º 20
0
 def setUp(self):
     self.trans = transaction.Transaction()
     self.inv = inventory.Inventory()
     self.disc = discount.Discount()
     self.inv.add("caviar", 46.52, by_weight=True)
     self.inv.add("nutella", 7.99)
     self.inv.add("corn", 1.99, by_weight=True)
     self.trans.add(self.inv, "corn", 3)
     self.trans.add(self.inv, "caviar", 41)
     self.trans.add(self.inv, "nutella")
Exemplo n.º 21
0
 def __init__(self):
     super().__init__()
     self.name = None
     self.location = None
     self.set_location(self.starting_location)
     self.inv = inventory.Inventory()
     self.equip_dict = item.EquipTarget.make_dict(*self.equip_slots)
     self._parser = lambda line: Character.player_set_name(self, line)
     #TODO: make this a property
     self.is_alive = True
Exemplo n.º 22
0
    def __init__(self, color, initial_position):

        # All sprite classes should extend pygame.sprite.Sprite. This
        # gives you several important internal methods that you probably
        # don't need or want to write yourself. Even if you do rewrite
        # the internal methods, you should extend Sprite, so things like
        # isinstance(obj, pygame.sprite.Sprite) return true on it.
        pygame.sprite.Sprite.__init__(self)

        self.updateDelay = 10

        # Create the image that will be displayed and fill it with the
        # right color.
        #self.image = pygame.Surface([15, 15])
        #self.image.fill(color)

        self.images = pygame.image.load('images/player-sprite.png')
        self.images.convert_alpha()

        self.image = self.images.subsurface(pygame.Rect(0, 0, 30, 32))

        # Make our top-left corner the passed-in location.
        self.rect = self.image.get_rect()
        self.rect.topleft = initial_position

        self.nextUpdateTime = 0  # update() hasn't been called yet.
        self.walkingTime = 0
        self.nextAltWalkingImageTime = 0
        self.walkingImageAlt = False

        # Start in the air
        self.onGround = False
        self.jumpspeed = 6
        self.gravity = 0.2
        self.maxFallingSpeed = 30

        self.speed = 3
        self.xdirection = 0  # Start standing still
        self.ydirection = self.maxFallingSpeed  # Start falling

        self.equipment = inventory.Inventory(10)  # equipped items
        self.inventory = inventory.Inventory(50)  # inventory
        self.currentItem = None
Exemplo n.º 23
0
 def post(self):
     user = self.get_user()
     if not user:
         return self.redirect('/')
     item_name = self.request.POST["item_name"]
     inv = inventory.Inventory(self.conn, self.cur)
     item = inv.get_item(item_name)
     item_id = item.id
     inv.remove_user_item(user['id'], item_id)
     return self.redirect('/myitems')
    def main(self):
        self.num_of_strings = 12
        self.inv = inventory.Inventory()

        customer_specs = {"model":"abc"}
        instr_spec = InstrumentSpec.InstrumentSpec(customer_specs)
        self.initialize_inventory()

        instruments_found = self.inv.search(instr_spec)
        
        print("Instrument Not found") if not instruments_found else [print(i.srl_num) for i in instruments_found]
Exemplo n.º 25
0
 def __init__(self):
     super(HomeWindow, self).__init__()
     uic.loadUi('./UserInterfaces/homeWindow.ui', self)
     self.vendor_list = vendors.VendorList(self)
     self.customer_list = customers.CustomerList(self)
     self.balance_sheet = financialStatements.BalanceSheet(self)
     self.income_statement = financialStatements.IncomeStatement(self)
     self.employee_list = employees.EmployeeList(self)
     self.inventory = inventory.Inventory(self)
     self.initializeScreens()
     self.show()
Exemplo n.º 26
0
 def __init__(self):
     self.surface = pygame.Surface((1, 1))
     self.players = pygame.sprite.Group()
     self.entities = pygame.sprite.Group()
     self.npcs = pygame.sprite.Group()
     self.players.field = self
     self.entities.field = self
     self.npcs.field = self
     self.inventory = inventory.Inventory()
     self.target = None
     self.pan = (0, 0)
     self.send_message = lambda x: None
    def main(self):
        num_of_strings = 12
        self.inv = inventory.Inventory()

        customer_guitar = guitarSpec.GuitarSpec(Builder.FENDER, "Sratocastor",
                                                Type.ELECTRIC, Wood.ALDER,
                                                Wood.ALDER, num_of_strings)
        self.initialize_inventory()

        gtrs_found = self.inv.search(customer_guitar)
        print("Not found") if not gtrs_found else self.inv.display_guitar(
            gtrs_found)
Exemplo n.º 28
0
 def get(self):
     user = self.get_user()
     if not user:
         return self.redirect('/')
     inv = inventory.Inventory(self.conn, self.cur)
     thumbnail_items = inv.get_user_thumbnail_items(user['id'])
     thumbnail_recipes = inv.get_user_thumbnail_recipes(user['id'])
     context = {
         "thumbnail_items": thumbnail_items,
         "thumbnail_recipes": thumbnail_recipes
     }
     self.render_response('profile_page.html', **context)
Exemplo n.º 29
0
    def __init__(self):
        self.settings = settings.Settings()
        self.game_data = gf.GameData(inv.Inventory(), stack.Stack())

        self.game_data.set_loc_list(self.init_locations())
        self.game_data.set_item_list(self.init_items())
        self.game_data.set_npc_list(self.init_npcs())
        self.game_data.set_current_loc(
            self.game_data.get_loc_from_name("Entrance Room"))

        stick = self.game_data.get_item_from_name('stick')
        stick.set_pickup_allowed()

        keys = self.game_data.get_item_from_name('keys')
        keys.set_pickup_allowed()

        room_map = self.game_data.get_item_from_name('map')
        room_map.set_usable()
        room_map.set_pickup_allowed()
        room_map.set_interaction(interactions.map_interaction)
        room_map.set_unique_verb("read")

        chest = self.game_data.get_item_from_name('chest')
        chest.add_contents(room_map)
        chest.set_usable_with(keys)
        chest.set_unique_verb("open")

        rubble = self.game_data.get_item_from_name('rubble')
        rubble.set_usable_with(stick)
        rubble.set_block_dir('n')

        mirror = self.game_data.get_item_from_name('mirror')
        mirror.set_pickup_allowed()

        sphere = self.game_data.get_item_from_name('sphere')

        pond = self.game_data.get_item_from_name('pond')
        pond.set_usable_with(mirror)
        pond.set_interaction(interactions.pond_interaction)
        pond.add_contents(sphere)

        self.game_data.create_map()
        self.game_data.distribute_items()
        self.game_data.distribute_npcs()

        chest.location = self.game_data.get_loc_from_name("Entrance Room")
        keys.location = self.game_data.get_loc_from_name("Entrance Room")
        rubble.location = self.game_data.get_loc_from_name("Debris Room")
        pond.location = self.game_data.get_loc_from_name("Water Chamber")

        with open("internals/logo.txt") as f_obj:
            self.logo = f_obj.read()
Exemplo n.º 30
0
 def get(self):
     user = self.get_user()
     if not user:
         return self.redirect('/')
     suggest_item_name = self.request.GET[
         "suggest"] if "suggest" in self.request.GET else ""
     inv = inventory.Inventory(self.conn, self.cur)
     my_items = inv.get_user_items(user['id'])
     context = {
         "my_items": my_items,
         "suggest_item_name": suggest_item_name
     }
     self.render_response('my_items_page.html', **context)