def __init__(self, x, y, worldwidth, worldheight): self.mX = x self.mY = y self.mWorldWidth = worldwidth self.mWorldHeight = worldheight self.mItems = [] #add top row of items for i in range(2): for j in range(6): currentItem = item.Item(x + (15 * j), y + (15 * i), 15, 15, self.mWorldWidth, self.mWorldHeight) self.mItems.append(currentItem) #add left leg of items for i in range(3): for j in range(2): currentItem = item.Item(x + (15 * j), y + 30 + (15 * i), 15, 15, self.mWorldWidth, self.mWorldHeight) self.mItems.append(currentItem) #add right leg for i in range(3): for j in range(2): currentItem = item.Item(x + 60 + (15 * j), y + 30 + (15 * i), 15, 15, self.mWorldWidth, self.mWorldHeight) self.mItems.append(currentItem)
def get_obj_from_phoxiinfo_nobgf(phxilocator, load=True, phoxi_f_name=None, reconstruct_surface=False, resolution=1, x_range=(400, 1080), y_range=(-100, 300), z_range=(790, 1000), sample_num=None): grayimg, depthnparray_float32, pcd = load_phxiinfo( phoxi_f_name=phoxi_f_name, load=load) objpcd_list = phxilocator.find_objpcd_list_by_pos(pcd, scan_num=resolution, toggledebug=False, x_range=x_range, y_range=y_range, z_range=z_range) if len(objpcd_list) == 0: print("No obj is detected!") return None else: objpcd = phxilocator.find_largest_objpcd(objpcd_list) if sample_num is None: return item.Item(pcd=objpcd * 1e-3, reconstruct=reconstruct_surface) else: objcm = pcdu.reconstruct_surface(objpcd * 1e-3, radii=[.005]) return item.Item(reconstruct=reconstruct_surface, sample_num=sample_num, objcm=objcm)
def generate_shop(_id): SI_list = database_mongo.get_all_shop_items_list() shop = Shop(int(_id), {}) for SI in SI_list: shop.add_item(get_shop_item(SI)) five_star_chars = character.get_five_star_characters() four_star_chars = character.get_four_star_characters() count = 0 uniques = [] while count < 4: r = random.randint(1, 30) if r == 1: r = random.randint(1, len(five_star_chars)) c = five_star_chars[r - 1] if c.URL_name not in uniques: shop.add_item( Shop_Item( item.Item(c.name, c.URL_name, c.description, 1, c.rarity, "character").get_dict(), 100, "sg", 1, 1)) count += 1 uniques.append(c.URL_name) else: r = random.randint(1, len(four_star_chars)) c = four_star_chars[r - 1] if c.URL_name not in uniques: shop.add_item( Shop_Item( item.Item(c.name, c.URL_name, c.description, 1, c.rarity, "character").get_dict(), 50, "sg", 1, 1)) count += 1 uniques.append(c.URL_name) database_mongo.save_shop(shop)
def tester(): item1 = item.Item(0, "Weapon", "Sword", "An ancient sword passed down", 1, (0, 0), "./Assets/sword.png") item2 = item.Item(1, "Food", "Apple", "An apple picked fresh from a tree", 16, (0, 0), "./Assets/apple.png") item3 = item.Item(2, "Mineral", "Gem", "A precious gemstone", 3, (0, 0), "./Assets/gem.png") item4 = None item5 = None item6 = item.Item(2, "Mineral", "Gem", "A precious gemstone", 15, (0, 0), "./Assets/gem.png") item_list = [item1, item4, item3, item2, item5, item6] print("starting list") for i in range(0, len(item_list)): if item_list[i] is not None: print(item_list[i].get_name()) # sort by item number item_list = sort_by_number(item_list) print("Sorting by number") for i in range(0, len(item_list)): if item_list[i] is not None: print(item_list[i].get_name(), item_list[i].get_num()) else: print("Null")
def __init__(self, x=0, y=0, layer=0): super(Player, self).__init__(ika.Entity(x, y, layer, PLAYER_SPRITE), _playerAnim) self._animator = _Anim() self.state = self.standState() self.stats = initialStats.clone() self.baseStats = self.stats.clone() self.expFactor = 50.0 self.exponent = 1.9 self.sword = Sword() self.spear = Spear() self.spear.item = item.Item('Fishing Pole') self.sword.item = item.Item('Sharp Slicer') self.armor = None self.grapple = Grapple() self.items = [] #self.weapon = self.spear self.weapon = self.sword
def __init__(self): self.caves = self.create_caves() cave1 = self.caves[0] sword = item.Item("sword", "A pointy sword.", cave1) coin = item.Item("coin", "A shiny gold coin. " "Your first piece of treasure!", cave1) orc = monster.Monster(cave1, 'orc', 'A generic dungeon monster') self.player = player.Player(cave1)
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()
def readmbox(self, location): for message in mailbox.mbox(location): if sys.hexversion >= 0x03000000: _item.Item(self, eml=message.as_bytes(unixfrom=True), create=True) else: # pragma: no cover _item.Item(self, eml=message.as_string(unixfrom=True), create=True)
def read_maildir(self, location): for message in mailbox.MH(location): if sys.hexversion >= 0x03000000: _item.Item(self, eml=message.as_bytes(unixfrom=True), create=True) else: _item.Item(self, eml=message.as_string(unixfrom=True), create=True)
def _split(mapiobj, store): notif = Notification(mapiobj) notif.mapiobj = mapiobj notif.object = None notif.object_type = None notif.event_type = None # object if mapiobj.ulObjType == MAPI_MESSAGE: item = _item.Item() item.store = store item.server = store.server item._entryid = mapiobj.lpEntryID notif.object_type = 'item' notif.object = item elif mapiobj.ulObjType == MAPI_FOLDER: folder = _folder.Folder(store=store, entryid=_benc(mapiobj.lpEntryID), _check_mapiobj=False) notif.object = folder notif.object_type = 'folder' # event if mapiobj.ulEventType in (fnevObjectCreated, fnevObjectCopied): notif.event_type = 'created' yield notif elif mapiobj.ulEventType == fnevObjectModified: notif.event_type = 'updated' yield notif elif mapiobj.ulEventType == fnevObjectDeleted: item._folder = store.folder(entryid=_benc(mapiobj.lpParentID)) notif.event_type = 'deleted' yield notif elif mapiobj.ulEventType == fnevObjectMoved: notif.event_type = 'created' yield notif notif = copy.copy(notif) item = _item.Item() item.store = store item.server = store.server item._entryid = mapiobj.lpOldID notif.object = item item._folder = store.folder(entryid=_benc(mapiobj.lpOldParentID)) notif.event_type = 'deleted' yield notif
def tester(): item1 = item.Item(0, "Weapon", "Sword", "An ancient sword passed down", 1, (0, 0), "./Assets/sword.png") item2 = item.Item(1, "Food", "Apple", "An apple picked fresh from a tree", 32, (0, 0), "./Assets/apple.png") item3 = item.Item(2, "Mineral", "Gem", "A precious gemstone", 3, (0, 0), "./Assets/gem.png") item4 = None item5 = None item_list = [item1, item4, item3, item2, item5] print("starting list") for i in range(0, len(item_list)): if item_list[i] is not None: print(item_list[i].get_name()) # sort by id item_list = sort_by_id(item_list) print("Sorting by id") for i in range(0, len(item_list)): if item_list[i] is not None: print(item_list[i].get_name()) else: print("Null") # sort by item name item_list = sort_by_name(item_list) print("Sorting by name") for i in range(0, len(item_list)): print(item_list[i].get_name()) # sort by item type item_list = sort_by_type(item_list) print("Sorting by type") for i in range(0, len(item_list)): print(item_list[i].get_name()) # sort by item number item_list = sort_by_number(item_list) print("Sorting by number") for i in range(0, len(item_list)): print(item_list[i].get_name()) # sort by highlight item1.set_highlight(False) item2.set_highlight(True) item3.set_highlight(True) item_list = sort_by_highlight(item_list) print("Sorting by highlight") for i in range(0, len(item_list)): print(item_list[i].get_name())
def game(): """Game Loop and Setup""" # Item test_item1 = item.Item("candle", "It lights the way.") test_item2 = item.Item("rope", "It is long and sturdy.") test_item3 = item.Item("chalice", "It is a dull copper.") # Create room object t_room1 = room.Room("R1", "D1", test_item1) t_room2 = room.Room("R2", "D2", test_item2) t_room3 = room.Room("R3", "D3", test_item3) # Room adds go as: North South East West t_room1.connect_rooms(t_room2, None, None, None) t_room2.connect_rooms(None, t_room1, None, t_room3) t_room3.connect_rooms(None, None, t_room2, None) """ Map: 3 - 2 | 1 """ current_room = t_room1 game_loop = True character = player.Player(input("Your name? "), [], 10, 10, 5, 5) print("Start the game, {}!".format(character.name)) while game_loop: user_input = input(">").lower() if user_input in ["end", "stop", "quit", "bye", "exit"]: game_loop = False elif user_input == "test": print(current_room) elif user_input == "menu": character.navigate_menu() elif user_input == "inspect": current_room.inspect_room() elif user_input == "get": character.add_to_backpack(current_room) elif user_input == "move": temp_room = current_room.move_rooms(input("N, S, E, W? ")[0]) if temp_room is None: print("There is no room there!") else: current_room = temp_room else: print("Invalid input.") print("Game over.")
def update(self): self.api.sync() temp = self._load_config() for _item in self.api.items.all(): if _item['due']: if str(_item["id"]) in temp.keys(): self.item_list[_item["id"]] = item.Item( self.api, self.habit, _item["id"], temp[str(_item["id"])]) else: self.item_list[_item["id"]] = item.Item( self.api, self.habit, _item["id"])
def __init__(self): monster.Monster.__init__( self, "skeleton archer", 60, loot.Loot( "the skeleton archer", 4, 80, [[item.Nothing(), 0.4], [ item.Item("cracked bone", "dirty gray with a scratch along its middle", 3, 9), 0.3 ], [ item.Item( "unfeathered arrow", "its tip seems to be made of tempered brown clay", 4, 6), 0.2 ], [ gear.Boots( "crude sabatons", "probably held together with mud and bone marrow", sellCost=15, buyCost=44, stats={ "armor": 2, "criticalChance": 0.02 }), 0.1 ]]), [ # [name, cooldown, caster (always self), cast logic (takes ablty, which means ability but can't be confused with the module, and target)], probability [ ability.Ability( "iron bolt", 0, lambda ablty, caster, target: ability. damage(ablty, caster, target, 9, 14)), 0.5 ], [ ability.Ability( "arrow as dagger", 0, lambda ablty, caster, target: ability.damage(ablty, caster, target, 3, 21)), 0.4 ], [ ability.Ability( "archer's resolve", 2, lambda ablty, caster, target: caster.addEffect( effect.CriticalChanceBuffAdd( "archer's resolve", 2, 0.6))), 0.1 ] ])
def _process_text(self, text): "Assign values from text" # 1. Split the text into floor number and items match = RE_FLOOR.fullmatch(text) if not match: print("Unable to parse floor: %s" % text) return # 2. Save the floor number self.ordinal = match.group(1) self.number = ORDINAL.index(self.ordinal) # 3. Break up the items parts = match.group(2).replace(" and ", ",").replace(",,", ",").split(",") # 4. Handle nothing floors -- they have no items if len(parts) == 1 and parts[0].startswith(NOTHING): return # 5. Loop for all the parts for part in parts: part = part.replace("a ", "").strip() # 6. Create the item an_item = item.Item(part) # 7. Add it to the items on the floor self.items.add(an_item)
def __init__(self, leagueid, opendotajson, indexjson): # init self._leagueid = leagueid # self._name = name # self._year = year self._opendotajson = opendotajson self._indexjson = indexjson self._herojson = {} self._ability = ability.Ability(self._indexjson) self._item = item.Item(self._indexjson) # init league stats # single stats self._match_num = self._opendotajson.get_match_num() self._radiant_win_num = self._opendotajson.get_radiant_win_num() self._last_matchid = self._opendotajson.get_last_matchid() self._last_unixdate = self._opendotajson.get_last_unixdate() self._name = self._opendotajson.get_leaguename() self._year = self._make_year_from_lastdate() # arr stats self._match_id_arr = self._opendotajson.get_match_id_arr() self._unixdate_arr = self._opendotajson.get_unixdate_arr() self._duration_arr = [] # dict stats self._pickbans = {} self._pickbans_ranking = {} # output json self.leaguejson = {} # init dictionary self._init_herojson() # make stats self._make_stats()
def ScanItems(self, inventory, curr_item): if curr_item in "REGISTER": # show current receipt self.PrintReceipt(inventory) elif curr_item in "DONE": # determine total price and print entire receipt self.FinishCheckout(inventory) else: while curr_item not in inventory.keys( ): # if input is invalid, re-prompt user print() print( "****** Sorry, the item/input entered is invalid. Please try again! ******" ) print() self.PromptUser(inventory) temp_item = item.Item( curr_item, inventory.get(curr_item)[1], False, self.receipt_index, self.receipt_index) # price will be retail price of that item self.all_items.append(temp_item) self.basket.append(temp_item) self.UpdateReceipt(temp_item, self.receipt_index, inventory, False, "") self.CheckForDiscounts(temp_item, inventory) self.PromptUser(inventory)
def get_obj_from_phoxiinfo_withmodel(phxilocator, stl_f_name, load_f_name=None, match_filp=False, bg_f_name="bg_0217.pkl"): objcm = cm.CollisionModel(objinit=os.path.join(config.ROOT + '/obstacles/' + stl_f_name)) grayimg, depthnparray_float32, pcd = load_phxiinfo( phoxi_f_name=load_f_name) workingarea_uint8 = phxilocator.remove_depth_bg(depthnparray_float32, bg_f_name=bg_f_name, toggledebug=False) obj_depth = phxilocator.find_paintingobj(workingarea_uint8) if obj_depth is None: print("painting object not detected!") objpcd = pcdu.trans_pcd( pcdu.remove_pcd_zeros(vu.map_depth2pcd(obj_depth, pcd)), phxilocator.amat) objmat4 = phxilocator.match_pcdncm(objpcd, objcm, match_rotz=match_filp) objcm.sethomomat(objmat4) return item.Item(objcm=objcm, pcd=objpcd, objmat4=objmat4)
def item(self, entryid=None, guid=None): """Return :class:`Item` with given entryid.""" item = _item.Item() # XXX copy-pasting.. item.store = self item.server = self.server if guid is not None: # 01 -> entryid format version, 05 -> object type (message) entryid = '00000000' + self.guid + '0100000005000000' + guid + '00000000' if entryid is not None: eid = _utils._bdec_eid(entryid) else: raise ArgumentError("no guid or entryid specified") try: item.mapiobj = _utils.openentry_raw(self.mapiobj, eid, 0) # XXX soft-deleted item? except MAPIErrorNotFound: raise NotFoundError("no item with entryid '%s'" % entryid) except MAPIErrorInvalidEntryid: raise ArgumentError("invalid entryid: %r" % entryid) return item
def lerArquivo(instancia): global QTD_ITENS global TAM_MAX_PACOTE global ITENS #leitura do arquivo passado como primeiro parametro arquivo = open(instancia, 'r') info = arquivo.readline() graph = arquivo.readlines() arquivo.close() #armazenamento das informacoes info = info.split() QTD_ITENS = int(info[0]) TAM_MAX_PACOTE = int(info[1]) #preenchimento dos dados dos itens for i in graph: token = i.split() if token: aux = items.Item(token[0], token[1], token[2:]) ITENS.append(aux) for i in ITENS: for j in i.conflitos: ITENS[int(j) - 1].conflitos.append(i.get_id())
def create_item(self, eml=None, ics=None, vcf=None, load=None, loads=None, attachments=True, save=True, **kwargs): # XXX associated read = kwargs.get('read') # needs to be set before first save item = _item.Item(self, eml=eml, ics=ics, vcf=vcf, load=load, loads=loads, attachments=attachments, create=True, save=save, read=read) for key, val in kwargs.items(): if key != 'read': setattr(item, key, val) return item
def __init__(self): monster.Monster.__init__( self, "giant sewer rat", 40, loot.Loot( "the giant sewer rat", 3, 30, [[item.Nothing(), 0.85], [ item.Item( "strange doubloon", "cracked and faded, but it looks to be made of gold", 19, 84), 0.15 ]]), [ # [name, cooldown, caster (always self), cast logic (takes ablty, which means ability but can't be confused with the module, and target)], probability [ ability.Ability( "gnaw", 0, lambda ablty, caster, target: ability. damage(ablty, caster, target, 8, 13)), 0.4 ], [ ability.Ability( "bite", 0, lambda ablty, caster, target: ability. damage(ablty, caster, target, 4, 11)), 0.4 ], [ ability.Ability( "sewer plague", 1, lambda ablty, caster, target: target.addEffect( effect.DamageOverTime("sewer plague", 3, 4, 6, self ))), 0.2 ] ])
def __init__(self): monster.Monster.__init__( self, "ghoul", 60, loot.Loot( "the ghoul", 5, 120, [[item.Nothing(), 0.8], [ item.Item("decayed fingernail", "dry, brittle, came from a ghoul", 1, 4), 0.2 ]]), [ # [name, cooldown, caster (always self), cast logic (takes ablty, which means ability but can't be confused with the module, and target)], probability [ ability.Ability( "knitting flesh", 999, lambda ablty, caster, target: caster.addEffect( effect.HealOverTime("knitting flesh", 9, 4, 10))), 999 ], [ ability.Ability( "mindless maul", 0, lambda ablty, caster, target: ability.damage(ablty, caster, target, 9, 18)), 0.7 ], [ ability.Ability( "putrid breath", 5, lambda ablty, caster, target: target.addEffect( effect.ArmorBuff("putrid breath", 4, -0.3))), 0.3 ] ])
class App: def __init__(self): pyxel.init(128, 128, caption="Snake Game", fps=5) pyxel.load( os.path.dirname(os.path.abspath(__file__)) + "/assets.pyxel") pyxel.run(self.update, self.draw) def update(self): if pyxel.btnp(pyxel.KEY_Q): pyxel.quit() self.item.update() self.me.update() if self.item.x == self.me.x and self.item.y == self.me.y: self.eat() def draw(self): pyxel.cls(0) self.me.draw() self.item.draw() self.score.draw() def eat(self): self.item.alives = False self.score.point += 1 self.me.ghosts += 1 me = me.Me() item = item.Item() score = score.Score()
def ImportMessageChange(self, props, flags): if self.skip: raise MAPIError(SYNC_E_IGNORE) try: entryid = PpropFindProp(props, PR_ENTRYID) if self.importer.store: mapistore = self.importer.store.mapiobj else: store_entryid = PpropFindProp(props, PR_STORE_ENTRYID).Value store_entryid = WrapStoreEntryID(0, b'zarafa6client.dll', store_entryid[:-4]) + self.server.pseudo_url + b'\x00' mapistore = self.server._store2(store_entryid) item = _item.Item() item.server = self.server item.store = _store.Store(mapiobj=mapistore, server=self.server) try: item.mapiobj = _utils.openentry_raw(mapistore, entryid.Value, 0) props = item.mapiobj.GetProps([PR_EC_HIERARCHYID, PR_EC_PARENT_HIERARCHYID, PR_STORE_RECORD_KEY], 0) # XXX properties don't exist? item.docid = props[0].Value item.storeid = _benc(props[2].Value) if hasattr(self.importer, 'update'): self.importer.update(item, flags) except (MAPIErrorNotFound, MAPIErrorNoAccess): # XXX, mail already deleted, can we do this in a cleaner way? self.log.debug('received change for entryid %s, but it could not be opened', _benc(entryid.Value)) except Exception: self.log.error('could not process change for entryid %s (%r):', _benc(entryid.Value), props) self.log.error(traceback.format_exc()) if self.stats: self.stats['errors'] += 1 raise MAPIError(SYNC_E_IGNORE)
def build_house_items(item_name, item_value, item_weight): """Return a list of items found in the house""" item_list = [] for count in range(len(item_name)): item_list.append( item.Item(item_name[count], item_value[count], item_weight[count])) return item_list
def old_object(self): if self.mapiobj.ulObjType == MAPI_MESSAGE and self.mapiobj.lpOldID: item = _item.Item() item.store = self.store item.server = self.store.server item._entryid = self.mapiobj.lpOldID return item
def __init__(self): monster.Monster.__init__( self, "prowling fox", 60, loot.Loot( "the prowling fox", 5, 50, [[item.Nothing(), 0.9], [ item.Item("bushy tail", "a muddled red to blend in with the trees", 4, 19), 0.1 ]]), [ # [name, cooldown, caster (always self), cast logic (takes ablty, which means ability but can't be confused with the module, and target)], probability [ ability.Ability( "pounce", 999, lambda ablty, caster, target: ability. damage(ablty, caster, target, 14, 20)), 999 ], [ ability.Ability( "claw", 0, lambda ablty, caster, target: ability. damage(ablty, caster, target, 6, 8)), 0.8 ], [ ability.Ability( "tense", 2, lambda ablty, caster, target: caster. addEffect(effect.StrengthBuff("tense", 1, 0.5))), 0.2 ] ])
def item(self, entryid=None, sourcekey=None): """ Return :class:`Item` with given entryid or sourcekey :param entryid: item entryid :param sourcekey: item sourcekey """ # resolve sourcekey to entryid if sourcekey is not None: restriction = SPropertyRestriction(RELOP_EQ, PR_SOURCE_KEY, SPropValue(PR_SOURCE_KEY, _bdec(sourcekey))) table = self.mapiobj.GetContentsTable(MAPI_DEFERRED_ERRORS) table.SetColumns([PR_ENTRYID, PR_SOURCE_KEY], 0) table.Restrict(restriction, 0) rows = list(table.QueryRows(-1, 0)) if not rows: raise NotFoundError("no item with sourcekey '%s'" % sourcekey) entryid = _benc(rows[0][0].Value) # open message with entryid try: mapiobj = _utils.openentry_raw(self.store.mapiobj, _bdec(entryid), self.content_flag) except MAPIErrorNotFound: raise NotFoundError("no item with entryid '%s'" % entryid) item = _item.Item(self, mapiobj=mapiobj) return item
def __init__(self): monster.Monster.__init__( self, "skeleton scout", 60, loot.Loot( "the skeleton scout", 8, 140, [[item.Nothing(), 0.4], [ item.Item("cracked bone", "dirty gray with a scratch along its middle", 3, 9), 0.6 ]]), [ # [name, cooldown, caster (always self), cast logic (takes ablty, which means ability but can't be confused with the module, and target)], probability [ ability.Ability( "charge", 999, lambda ablty, caster, target: ability. damage(ablty, caster, target, 9, 16)), 999 ], [ ability.Ability( "slash", 0, lambda ablty, caster, target: ability. damage(ablty, caster, target, 6, 15)), 0.8 ], [ ability.Ability( "fuse bone", 4, lambda ablty, caster, target: ability. heal(ablty, caster, target, 18, 30)), 0.2 ] ])