コード例 #1
0
    def __init__(self, name, sprite, description, price, equipped_sprites,
                 body_part, defense, res, atk, weight, restrictions):
        Item.__init__(self, name, sprite, description, price)
        self.defense = defense
        self.res = res
        self.atk = atk
        self.weight = weight
        self.restrictions = restrictions
        self.body_part = body_part
        self.equipped_sprite = pg.transform.scale(
            pg.image.load(equipped_sprites[0]).convert_alpha(),
            (TILE_SIZE, TILE_SIZE))
        if len(equipped_sprites) > 1:
            for sp in equipped_sprites[1:]:
                self.equipped_sprite.blit(
                    pg.transform.scale(
                        pg.image.load(sp).convert_alpha(),
                        (TILE_SIZE, TILE_SIZE)), (0, 0))

        # Used when character wearing the equipment cannot be selected
        self.sprite_unavailable = self.equipped_sprite.copy()
        color_image = pg.Surface(self.sprite.get_size()).convert_alpha()
        color_image.fill(LIGHT_GREY)
        self.sprite_unavailable.blit(color_image, (0, 0),
                                     special_flags=pg.BLEND_RGBA_MULT)
        self.normal_sprite = self.equipped_sprite
コード例 #2
0
 def __init__(self, amount):
     Item.__init__(
         self,
         str(amount) + " Gold",
         "imgs/dungeon_crawl/item/gold/gold_pile_10.png",
         "Gold could be used to buy some items or other services", 0)
     self.amount = amount
コード例 #3
0
 def __init__(self,
              dialect,
              item_id,
              title,
              definition,
              user,
              contributor,
              cultural_note,
              reference,
              image_id,
              audio_id,
              video_id,
              children_archive,
              status,
              literal_translation=None,
              change=None):
     Item.__init__(self, dialect, item_id, title, user, change)
     self.definition = definition
     self.cultural_note = cultural_note
     self.reference = reference
     self.image_id = image_id
     self.audio_id = audio_id
     self.video_id = video_id
     self.contributor = contributor
     self.status = status
     self.children_archive = children_archive
     self.literal_translation = literal_translation
コード例 #4
0
 def __init__(self, name, sprite, description, equipped_sprite, body_part, res, magic_res, atk, weight):
     Item.__init__(self, name, sprite, description)
     self.res = res
     self.magic_res = magic_res
     self.atk = atk
     self.weight = weight
     self.body_part = body_part
     self.equipped_sprite = pg.transform.scale(pg.image.load(equipped_sprite).convert_alpha(), (TILE_SIZE, TILE_SIZE))
コード例 #5
0
 def determine_categories(item_data: dict, item: Item) -> None:
     for category1 in item_bases:
         for category2 in item_bases[category1]:
             for base in item_bases[category1][category2]:
                 if str(item_data['typeLine']).lower() == base.lower():
                     item.category1 = category1.lower()
                     item.category2 = category2.lower()
                     item.base = base
                     item.name = item_data['name']
                     return
コード例 #6
0
    def testGetPriceWhenZeroItemsInBasketshouldReturnZero(self):
        item1 = Item("PC", 2000.0, "Elettronica")
        item2 = Item("PC1", 4000.0, "Elettronica")
        item3 = Item("PC2", 2000.0, "Elettronica")

        self.items.add(item1)
        self.items.add(item2)
        self.items.add(item3)

        self.assertEqual(8000, self.items.getPrice())
コード例 #7
0
def random_item():
    name = random_string()
    sample_img = 'imgs/dungeon_crawl/item/potion/yellow_new.png'
    desc = random_string(min_len=10, max_len=100)
    cost = rd.randint(0, 1000)
    item = Item(name, sample_img, desc, cost)
    return item
コード例 #8
0
def itemNameToObject(item, resources):
    try:
        # If this is an item
        if item[:3] == 'it_':
            lookupEq = resources['items'][item]
            return Item(item, lookupEq['name'], lookupEq['description'],
                        lookupEq['usable'])

        # If this is a piece of equipment
        elif item[:3] == 'eq_':
            lookupEq = resources['equipment'][item]
            return Equipment(item, lookupEq['name'], lookupEq['description'],
                             lookupEq['position'], lookupEq['attribute'],
                             lookupEq['value'])

        # If this is a story log
        elif item[:3] == 'st_':
            lookupSt = resources['story'][item]
            return Story(item, lookupSt['name'], lookupSt['description'],
                         lookupSt['text'])

        # If this is anything else
        else:
            print(f'{item} is not a supported item type.')
            return None

    except KeyError:
        print(f'Exception Caught. KeyError: {item}')
        return None
コード例 #9
0
 def test_init_item(self):
     name = 'life_potion'
     sprite = 'imgs/dungeon_crawl/item/potion/magenta_new.png'
     description = 'This is a test description'
     item = Item(name, sprite, description)
     self.assertEqual(name, item.name)
     self.assertEqual(description, item.desc)
     self.assertEqual('Life Potion', str(item))
コード例 #10
0
    def test_name_format(self):
        sprite = 'imgs/dungeon_crawl/item/potion/magenta_new.png'
        description = 'This is a test description'

        name = 'test'
        item = Item(name, sprite, description)
        self.assertEqual('Test', str(item))

        name = 'Test'
        item = Item(name, sprite, description)
        self.assertEqual('Test', str(item))

        name = 'item_test'
        item = Item(name, sprite, description)
        self.assertEqual('Item Test', str(item))

        name = '5item_test_01'
        item = Item(name, sprite, description)
        self.assertEqual('5Item Test 01', str(item))
コード例 #11
0
 def copy_info(item_data: dict, item: Item) -> None:
     item.x = item_data['x']
     item.y = item_data['y']
     item.height = item_data['h']
     item.width = item_data['w']
     item.ilvl = item_data['ilvl']
     if 'implicitMods' in item_data:
         item.implicits = str(item_data['implicitMods']).split(',')
     item.explicits = str(item_data['explicitMods']).lower().split(',')
コード例 #12
0
 def test_init_item_with_price(self):
     name = 'life_potion'
     sprite = 'imgs/dungeon_crawl/item/potion/magenta_new.png'
     description = 'This is a test description'
     price = 200
     item = Item(name, sprite, description, price)
     self.assertEqual(name, item.name)
     self.assertEqual(description, item.desc)
     self.assertEqual('Life Potion', str(item))
     self.assertEqual(price, item.price)
     self.assertEqual(price // 2, item.resell_price)
コード例 #13
0
 def process_items_data(self) -> None:
     for item_data in self._items_data:
         item = Item()
         if 'explicitMods' in item_data and \
                 (item_data['frameType'] == 1  # magic item
                  or item_data['frameType'] == 2):  # rare item
             #  copy item information and mods
             self.copy_info(item_data, item)
             # determine item base and decide if we need it on our list of items
             self.determine_categories(item_data, item)
             if item.base:
                 self.items.append(item)
コード例 #14
0
 def test_init_chest(self):
     pos = (0, 0)
     sprite_close = 'imgs/dungeon_crawl/dungeon/chest_2_closed.png'
     sprite_open = 'imgs/dungeon_crawl/dungeon/chest_2_open.png'
     item = Item("TestItem", 'imgs/dungeon_crawl/item/potion/yellow_new.png', "This is a desc", 50)
     potential_items = [(item, 1.0)]
     chest = Chest(pos, sprite_close, sprite_open, potential_items)
     self.assertEqual(pos, chest.pos)
     self.assertEqual(sprite_close, chest.sprite_close_link)
     self.assertEqual(sprite_open, chest.sprite_open_link)
     self.assertEqual(chest.item, item)
     self.assertFalse(chest.opened)
     self.assertFalse(chest.pick_lock_initiated)
     # Chest's current sprite should be the closed one
     self.assertNotEqual(chest.sprite_open, chest.sprite)
コード例 #15
0
ファイル: PainterWidget.py プロジェクト: Essyer/PoETiS
    def draw_net(self, item: Item, chaos_draw=False) -> None:
        if not chaos_draw and len(
                item.mods_matched) < self.number_of_mods_to_draw:
            return
        cell_width = (self.width()) / self.stash_cells
        cell_height = (self.height() -
                       self.drag_button.height()) / self.stash_cells
        item_x = item.x * cell_width + pen_width
        item_w = item.width * cell_width - pen_width
        item_y = item.y * cell_width + pen_width
        item_h = item.height * cell_height - pen_width
        self.qp.drawRect(item_x, item_y, item_w, item_h)

        # Used in chaos_recipe to check if clicked on item
        item.geometry = QRect(item_x + self.geometry().x(),
                              item_y + self.geometry().y(), item_w, item_h)
コード例 #16
0
class itemTest(unittest.TestCase):
    def setUp(self) -> None:
        self.item = Item("PC", 2000.0, "Elettronica")

    def testAddWhenInputIsNullShouldRiseException(self):
        with self.assertRaises(TypeError):
            self.item.add(None)

    def testAddWhenInputIsNotNullShouldRiseException(self):
        itemX = Item("PC", 2600.0, "Elettronica")
        with self.assertRaises(ExceptionItem):
            self.item.add(itemX)

    def testRemoveWhenInputIsNullShouldRiseException(self):
        with self.assertRaises(TypeError):
            self.item.remove(None)

    def testRemoveWhenInputIsNotNullShouldRiseException(self):
        itemX = Item("PC", 3600.0, "Elettronica")
        with self.assertRaises(ExceptionItem):
            self.item.remove(itemX)
コード例 #17
0
    def validate(self):
        types = {
            1: self.dialect.nuxeo_imgs,
            2: self.dialect.nuxeo_videos,
            3: self.dialect.nuxeo_audio
        }
        for doc in types[self.type].values():
            if doc.title == self.title or LetterMapper().compare(
                    self.title, doc.title):
                self.doc = doc
                break

        if Item.validate(self):
            self.file_validate()
            self.recorder_validate()
            self.validate_int(self.shared, "fvm:shared")
            self.validate_text(self.description, "dc:description")
            self.contributor_validate(self.contributor, "fvm:source")
            self.status_validate()
        else:
            print("!!" + self.title)
            print(len(types[self.type].values()))
コード例 #18
0
ファイル: Requester.py プロジェクト: Essyer/PoETiS
 def process_items_data(self) -> None:
     for item_data in self._items_data:
         item = Item()
         if self.mode == "rare_scanner":
             if 'explicitMods' in item_data and \
                     ((item_data['frameType'] == 1 and self.mode == "rare_scanner")  # magic item
                      or item_data['frameType'] == 2):  # rare item
                 #  copy item information and mods
                 self.copy_info(item_data, item)
                 # determine item base and decide if we need it on our list of items
                 self.determine_categories(item_data, item)
                 if item.base:
                     self.items.append(item)
                 elif 'map' not in item_data['baseType'].lower():
                     print('Found item with not filled base, baseType: {}'.format(item_data['baseType']))
         else:
             if item_data['frameType'] == 2 and ('sockets' not in item_data or len(item_data['sockets']) < 6):  # rare item, not 6-sockets
                 if not item_data['identified'] or self.allow_identified:
                     #  copy item information
                     self.copy_info(item_data, item)
                     # determine item base and decide if we need it on our list of items
                     self.determine_categories(item_data, item)
                     self.items.append(item)
コード例 #19
0
def random_item(price=None):
    attrs = random_item_attributes(price)
    return Item(attrs['name'], attrs['sample_img'], attrs['desc'],
                attrs['cost'])
コード例 #20
0
ファイル: Cart.py プロジェクト: MarshalJoe/farmers-market
 def add(self, product_code, quantity=1):
     """ Add item to cart """
     for number in range(quantity):
         item = Item(product_code)
         self.items.append(item)
コード例 #21
0
def parse_item_file(name):
    # Retrieve data root for item
    it_tree_root = etree.parse('data/items.xml').getroot().find('.//' + name)

    sprite = 'imgs/dungeon_crawl/item/' + it_tree_root.find(
        'sprite').text.strip()
    info = it_tree_root.find('info').text.strip()
    price = it_tree_root.find('price')
    if price is not None:
        price = int(price.text.strip())
    else:
        price = 0
    category = it_tree_root.find('category').text.strip()

    if category == 'potion':
        effect_name = it_tree_root.find('effect').text.strip()
        power = int(it_tree_root.find('power').text.strip())
        duration = int(it_tree_root.find('duration').text.strip())
        effect = Effect(effect_name, power, duration)
        item = Potion(name, sprite, info, price, effect)
    elif category == 'consumable':
        effect_name = it_tree_root.find('effect').text.strip()
        power = int(it_tree_root.find('power').text.strip())
        duration = int(it_tree_root.find('duration').text.strip())
        effect = Effect(effect_name, power, duration)
        item = Consumable(name, sprite, info, price, effect)
    elif category == 'armor':
        body_part = it_tree_root.find('bodypart').text.strip()
        defense_el = it_tree_root.find('def')
        defense = int(defense_el.text.strip()) if defense_el is not None else 0
        weight = int(it_tree_root.find('weight').text.strip())
        eq_sprites = it_tree_root.find('equipped_sprites')
        if eq_sprites is not None:
            equipped_sprites = []
            for eq_sprite in eq_sprites.findall('sprite'):
                equipped_sprites.append('imgs/dungeon_crawl/player/' +
                                        eq_sprite.text.strip())
        else:
            equipped_sprites = [
                'imgs/dungeon_crawl/player/' +
                it_tree_root.find('equipped_sprite').text.strip()
            ]
        restrictions = load_restrictions(it_tree_root.find('restrictions'))
        item = Equipment(name, sprite, info, price, equipped_sprites,
                         body_part, defense, 0, 0, weight, restrictions)
    elif category == 'shield':
        parry = int(float(it_tree_root.find('parry_rate').text.strip()) * 100)
        defense_el = it_tree_root.find('def')
        defense = int(defense_el.text.strip()) if defense_el is not None else 0
        fragility = int(it_tree_root.find('fragility').text.strip())
        weight = int(it_tree_root.find('weight').text.strip())
        equipped_sprite = [
            'imgs/dungeon_crawl/player/hand_left/' +
            it_tree_root.find('equipped_sprite').text.strip()
        ]
        restrictions = load_restrictions(it_tree_root.find('restrictions'))
        item = Shield(name, sprite, info, price, equipped_sprite, defense,
                      weight, parry, fragility, restrictions)
    elif category == 'weapon':
        power = int(it_tree_root.find('power').text.strip())
        attack_kind = it_tree_root.find('kind').text.strip()
        weight = int(it_tree_root.find('weight').text.strip())
        fragility = int(it_tree_root.find('fragility').text.strip())
        w_range = [
            int(reach)
            for reach in it_tree_root.find('range').text.strip().split(',')
        ]
        equipped_sprite = [
            'imgs/dungeon_crawl/player/hand_right/' +
            it_tree_root.find('equipped_sprite').text.strip()
        ]
        restrictions = load_restrictions(it_tree_root.find('restrictions'))
        item = Weapon(name, sprite, info, price, equipped_sprite, power,
                      attack_kind, weight, fragility, w_range, restrictions)
    elif category == 'key':
        item = Key(name, sprite, info, price)
    elif category == 'spellbook':
        spell = it_tree_root.find('effect').text.strip()
        item = Spellbook(name, sprite, info, price, spell)
    else:
        # No special category
        item = Item(name, sprite, info, price)

    return item
コード例 #22
0
 def __init__(self, name, sprite, description, price, for_chest, for_door):
     Item.__init__(self, name, sprite, description, price)
     self.for_chest = for_chest
     self.for_door = for_door
コード例 #23
0
from src.Extract import Extract
from src.Item import Item
from src.StoreData import StoreData

url = "https://store.steampowered.com/search/?filter=topsellers&specials=1"
products = Item()
Extract(products, url)
x = 0
while (x < len(products.name)):
    print(products.name[x] + " " + products.price[x])
    x += 1
StoreData(products)
コード例 #24
0
 def setUp(self) -> None:
     self.item = Item("PC", 2000.0, "Elettronica")
コード例 #25
0
 def testRemoveWhenInputIsNotNullShouldRiseException(self):
     itemX = Item("PC", 3600.0, "Elettronica")
     with self.assertRaises(ExceptionItem):
         self.item.remove(itemX)
コード例 #26
0
 def __init__(self, name, sprite, description, price, effect):
     Item.__init__(self, name, sprite, description, price)
     self.effect = effect
コード例 #27
0
 def validate(self):
     self.doc = self.dialect.nuxeo_categories.get(self.id)
     Item.validate(self)
コード例 #28
0
 def __init__(self, name, sprite, description, price):
     Item.__init__(self, name, sprite, description, price)
コード例 #29
0
 def __init__(self):
     self.item = Item("CF1")
コード例 #30
0
 def testAddWhenInputIsNotNullShouldRiseException(self):
     itemX = Item("PC", 2600.0, "Elettronica")
     with self.assertRaises(ExceptionItem):
         self.item.add(itemX)