def add_items(self): item1 = Items('Iphone10', 'A brand new Iphone') item2 = Items('Storagekey', 'This is a key which unlocks the storage room door') self.items.append(item1) self.items.append(item2)
class TestItems(unittest.TestCase): def setUp(self): self.items = Items(209321299, "Sour Patch Watermelon Soft & Chewy Candy - 8oz", 1.99) def test_ItemString(self): self.assertEquals( str(self.items), "Item ID : 209321299\n Item Name : Sour Patch Watermelon Soft & Chewy Candy - 8oz\n Item Price : $1.99" ) def test_GetItemName(self): self.assertEqual(self.items.getItemName(), 'Sour Patch Watermelon Soft & Chewy Candy - 8oz') def test_AddNewItem(self): self.items.addNewItem( 209321300, "Chips Ahoy! Original Chocolate Chip Cookies -13oz", 2.59) self.assertEqual(self.items.getItemName(), "Chips Ahoy! Original Chocolate Chip Cookies -13oz") def test_GetItemPrice(self): self.assertEqual(self.items.getItemPrice(), 1.99)
def add_items(self): item1 = Items('Tube of water','A tube filled with dirty water! Do not drink it') item2 = Items('Key','This is a key you can use it to open your way to the roof ') item3 = Items('Parachute','This is a very reliable military parachute') self.items.append(item1) self.items.append(item2) self.items.append(item3)
def add_items(self): item1 = Items('Military bag', 'A big bag used by the military forces in WWII') item2 = Items('Sunglases', 'A big travelling suitcase') item3 = Items('Wire rope', 'A very durable and reliable rope') self.items.append(item1) self.items.append(item2) self.items.append(item3)
def add_items(self): item1 = Items('Machete','This is a big and sharp machete you can use it to free yourself') item2 = Items('Basementkey','This is a key use it to open the door') item3 = Items('Lighter','This is a lighter use it to see where you are') item4 = Items('Axe','This is an axe use it to cut and break things') self.items.append(item1) self.items.append(item2) self.items.append(item3) self.items.append(item4)
def add_items(self): from Items import Items item1 = Items('Nice warm jacket', 'A very warm jacket') item2 = Items( 'Hammer', 'A legit heavy hummer used as a weapon in the 18th century! The kids can not lift it obviously, but you can!' ) item3 = Items('Gun(toy)', 'Just a toy gun loaded with rubber arrows') self.items.append(item1) self.items.append(item2) self.items.append(item3)
def add_items(self): item1 = Items('Finalroomkey', 'A key for the Finalroom door') item2 = Items('Bottle', 'Empty bottle') item3 = Items('Granade', 'This is a lighter use it to see where you are') item4 = Items( 'AK-47', 'The AK-47 is a gas-operated, 7.62×39mm assault rifle, developed in the Soviet Union by Mikhail Kalashnikov. It is the originating firearm of the Kalashnikov rifle (or "AK") family.' ) self.items.append(item1) self.items.append(item2) self.items.append(item3) self.items.append(item4)
def insertar_items(): while True: item = Items(input("Nombre: "), input("Tipo: "), input("Costo: "), input("Activa: "), input("Pasiva: ")) if (not (procesamiento.existe_nombre(path_items, item.nombre, 0))): break else: print("El item ya está registrado, ingrese otro por favor.") return procesamiento.insertar(path_items, str(item))
def _calc_src_dest(path): items = Items() for step in path: for (item, item_cardinality) in step.recipe.src.items(): items.add(-step.cardinality * item_cardinality, item) for (item, item_cardinality) in step.recipe.dest.items(): items.add(step.cardinality * item_cardinality, item) return items.src_dest()
def actualizar_items(): while True: item = Items(input("Nombre: "), input("Tipo: "), input("Costo: "), input("Activa: "), input("Pasiva: ")) if (procesamiento.existe_nombre(path_items, item.nombre, 0)): break else: print( "El item no se encuentra registrado, ingrese otro por favor." ) return procesamiento.actualizar(path_items, str(item))
def post(self): poster = users.get_current_user() what = self.request.get('what').strip() where = self.request.get('where').strip() when = self.request.get('when').strip() name = self.request.get('name').strip() desc = self.request.get('desc').strip() notes = self.request.get('notes').strip() lost = self.request.get('lost').strip() found = self.request.get('found').strip() image = self.request.get('image').strip() print what, where, when, name, desc, notes, lost, found if poster: if what and where and when and name and desc and (lost or found): when = time.strptime(when, "%Y-%m-%d") when = datetime.fromtimestamp(time.mktime(when)) if image: u = Items(user = poster, what = what, when = when, where = where, name = name, description = desc, notes = notes, is_lost = bool(lost), image=db.Blob(str(image))) else: u = Items(user = poster, what = what, when = when, where = where, name = name, description = desc, notes = notes, is_lost = bool(lost)) u.put() if found: res = "Found" else: res = "Lost" document = search.Document( fields=[ search.TextField(name="item_id", value=str(u.key())), search.TextField(name='what', value=what), search.TextField(name='where', value=where), search.TextField(name='name', value=name), search.TextField(name='description', value=desc), search.TextField(name='foundlost', value=res)]) index = search.Index(name="itemsIndex") index.put(document) self.redirect("/items/" + str(u.key())) else: self.error("504") else: self.redirect(users.create_login_url(self.request.uri))
def actualizar(self): if self.muriendo == True: self.ani_num += 1 if self.ani_num == 2: self.sonido_al_morir.play() if self.ani_num == self.ani_max: self.muerto = True self.muriendo = False self.items.append( Items("imagenes/item", self.getPosicion(), self.camara)) self.setPosicion([-100, -100]) self.ani_num = 0 if self.muerto == False: self.mover()
def __init__(self, p, args={}): self.info = args self.items = Items() self.player = p s_width = args['sidebar_width'] b_height = args['button_height'] width = args['width'] height = args['height'] self.submenu = "player" #create all the little subsections of the menu self.menu_back = pygame.Surface((width, height)) self.sidebar = self.menu_back.subsurface( pygame.Rect(0, 0, s_width, height)) self.buttons = self.menu_back.subsurface( pygame.Rect(s_width, 0, width - s_width, b_height)) self.action_items = self.menu_back.subsurface( pygame.Rect(s_width, b_height, (width / 2) - s_width, height - b_height)) self.menu_area = self.menu_back.subsurface( pygame.Rect(s_width, b_height, width - s_width, height - b_height)) #print self.action_items.get_rect() #print self.menu_back.get_rect() #print self.sidebar.get_rect() #print self.buttons.get_rect() self.options = self.menu_back.subsurface( pygame.Rect( (self.sidebar.get_width() + self.action_items.get_width()), b_height, width - (self.sidebar.get_width() + self.action_items.get_width()), height - b_height)) #initialize sprite box self.sprites = pygame.sprite.RenderUpdates() #build buttons to click #self.sidebar.fill((255, 0, 0)) #self.buttons.fill((0, 255, 0)) #self.action_items.fill((0, 0, 255)) #self.options.fill((255, 255, 0)) items = self.make_button("Items", self.buttons, 0, 0) equip = self.make_button("Equipment", self.buttons, items.rect.width + 2, 0) skill = self.make_button("Skills", self.buttons, items.rect.width + equip.rect.width + 6, 0) play = self.make_button( "Player", self.buttons, items.rect.width + equip.rect.width + skill.rect.width + 10, 0) #build submenu that defaults to - Player Info self.run_play()
def loadPlayer(self, jsonPath): with open(jsonPath, "r") as data_file: data = json.load(data_file) level = data["Player"][0]["level"] self.level = int(level) health = data["Player"][0]["totalHealth"] self.totalHealth = int(health) health = data["Player"][0]["currentHealth"] self.currentHealth = int(health) experiencePoints = data["Player"][0]["experiencePoints"] self.experiencePoints = int(experiencePoints) damage = data["Player"][0]["damage"] self.damage = int(damage) item = data["Player"][0]["item"] self.item = Items(item) lastID = data["Player"][0]["lastID"] self.lastID = int(lastID)
def setUp(self): self.item = Items(1, '12.95', 'Beer', 'Coors', 'Molson')
def __init__(self, itemID, taxID, taxAmount): Items.__init__(self, itemID, taxID, taxAmount) self.taxID = taxID self.taxAmount = taxAmount
catalog_format_type_dao = dao_session.getCatalogFormatTypeDao() catalog_status_type_dao = dao_session.getCatalogStatusTypeDao() users_dao = dao_session.getUsersDao() list_it_types = catalog_item_type_dao.readAll() format_type = catalog_format_type_dao.readRandom() list_catalog_status_type = catalog_status_type_dao.readAll() list_users = users_dao.readAll() list_items = [] number_items = 10000 for j in range(number_items): time.sleep(0.001) item_item = Items() # item_item.setId(i) item_item.setClass(0) item_item.setName('Item_' + str(j)) item_item.setPath('Path_' + str(j)) item_item.setDateTime(datetime.datetime.now()) item_item.setType(list_it_types[randint(0, len(list_it_types) - 1)].getId()) item_item.setFormat(randint(0, len(format_type.getField(list_it_types[item_item.getType()].getItemType())) - 1)) item_item.setStatus(list_catalog_status_type[randint(0, len(list_catalog_status_type) - 1)].getId()) item_item.setVersion(0.1) item_item.setPrevVersion('') item_item.setNextVersion('') for i in range(0, randint(0, len(list_users) - 1)): item_item.addUserSubscription(randint(0, len(list_users) - 1)) list_items.append(item_item)
catalog_format_type_dao = dao_session.getCatalogFormatTypeDao() catalog_status_type_dao = dao_session.getCatalogStatusTypeDao() users_dao = dao_session.getUsersDao() list_it_types = catalog_item_type_dao.readAll() format_type = catalog_format_type_dao.readRandom() list_catalog_status_type = catalog_status_type_dao.readAll() list_users = users_dao.readAll() list_items = [] number_items = 10000 number_assets = 1000 for j in range(number_assets): time.sleep(.001) item_item = Items() # item_item.setId(i) item_item.setClass(1) item_item.setName('Asset_' + str(j)) item_item.setPath('Path_' + str(j)) item_item.setDateTime(datetime.datetime.now()) item_item.setType(list_it_types[randint(0, len(list_it_types) - 1)].getId()) item_item.setFormat(randint(0, len(format_type.getField(list_it_types[item_item.getType()].getItemType())) - 1)) item_item.setStatus(list_catalog_status_type[randint(0, len(list_catalog_status_type) - 1)].getId()) item_item.setVersion(0.1) item_item.setPrevVersion('') item_item.setNextVersion('') for i in range(0, randint(0, len(list_users) - 1)): item_item.addUserSubscription(randint(0, len(list_users) - 1)) list_items.append(item_item)
def __init__(self, itemID, discountID, discountAmount): Items.__init__(self, itemID, discountID, discountAmount) self.discountID = discountID self.discountAmount = discountAmount
class Player: level = 0 totalHealth = 0 currentHealth = 0 experiencePoints = 0 damage = 0 lastID = 1 item = None def __init__(self, jsonPath): self.loadPlayer(jsonPath) """ "Loads save data from json file. """ def loadPlayer(self, jsonPath): with open(jsonPath, "r") as data_file: data = json.load(data_file) level = data["Player"][0]["level"] self.level = int(level) health = data["Player"][0]["totalHealth"] self.totalHealth = int(health) health = data["Player"][0]["currentHealth"] self.currentHealth = int(health) experiencePoints = data["Player"][0]["experiencePoints"] self.experiencePoints = int(experiencePoints) damage = data["Player"][0]["damage"] self.damage = int(damage) item = data["Player"][0]["item"] self.item = Items(item) lastID = data["Player"][0]["lastID"] self.lastID = int(lastID) """ "Writes player data to json file. """ def savePlayer(self): with open(jsonPath, "r") as data_file: data = json.load(data_file) tmp = data["Player"][0]["level"] data["Player"][0]["level"] = str(self.level) tmp = data["Player"][0]["totalHealth"] data["Player"][0]["totalHealth"] = str(self.totalHealth) tmp = data["Player"][0]["currentHealth"] data["Player"][0]["currentHealth"] = str(self.currentHealth) tmp = data["Player"][0]["experiencePoints"] data["Player"][0]["experiencePoints"] = str(self.experiencePoints) tmp = data["Player"][0]["damage"] data["Player"][0]["damage"] = str(self.damage) tmp = data["Player"][0]["item"] data["Player"][0]["item"] = self.item.toJSON() tmp = data["Player"][0]["lastID"] data["Player"][0]["lastID"] = str(self.lastID) with open(jsonPath, "w") as data_file: data_file.write(json.dumps(data, indent=4, separators=(', ', ': '))) """ "Returns the health of the player. """ def getHealth(self): return self.currentHealth """ "Removes a supplied number of health "points. " "@param pointsToRemove: number of points "removed. """ def removeHealth(self, pointsToRemove): self.currentHealth -= pointsToRemove if self.currentHealth <= 0: self.currentHealth = 0 """ "Give a supplied number of health "points. " "@param: pointsToGive: number of points "given. """ def giveHealth(self, pointsToGive): self.currentHealth += pointsToGive if self.currentHealth >= self.totalHealth: self.currentHealth = self.totalHealth """ "Returns the damage amount of the player. """ def getDamage(self): if item == 0: return self.damage else: return item.damage * self.damage """ "Gives the player a supplied number of "experience points. " "@param pointsToGive: number of points "given. """ def giveExperiencePoints(self, pointsToGive): self.experiencePoints += pointsToGive if self.experiencePoints / 100 > 0: self.levelUp() """ "Levels up the player. """ def levelUp(self): self.level += 1 self.totalHealth += 1 self.giveHealth(self.totalHealth) self.experiencePoints = 0 """ "Returns the player's level. """ def getLevel(self): return self.level """ "Returns true if the player is dead. """ def isDead(self): if self.currentHealth <= 0: return True else: return False
def listinv(self): return Items.listinv(self.inv[0], self.inv[1], self.inv[2])
def setUp(self): self.items = Items(209321299, "Sour Patch Watermelon Soft & Chewy Candy - 8oz", 1.99)
def makeWebhookResult(req, menu): ''' Returns a dictionary based on individual intent action ''' # Deal with the intent - showMenu if req['queryResult']['action'] == 'showMenuAction': speech = "The details you asked are : \n\n " + "\n".join( [str(i) for i in list(menu.extractMenu())]) return makeSpeech(speech) # Deal with the intent - showCategory elif req['queryResult']['action'] == 'expandMenuAction': result = req['queryResult'] parameters = result.get('parameters') category = parameters.get('categoryEntity') cat = Category() cat.extractCatergoryId(category) speech = "The details you asked are : \n\n " + "\n".join( [str(i) for i in list(cat.getdata())]) return makeSpeech(speech) # Deal with the intent - exploreItem elif req['queryResult']['action'] == 'exploreItemAction': result = req['queryResult'] parameters = result.get('parameters') item = parameters.get('items') it = Items() plateDetails = it.exploreItem(item) speech = "Price for " + str( item) + "\n\n" + "for half plate: " + plateDetails[ 0] + "\nfull plate: " + plateDetails[1] return makeSpeech(speech) # Deal with the intent - addThisToCart # Used when user is exploring a specific item and then says to add the item which is being explored to the cart. elif req['queryResult']['action'] == 'addThisToCartAction': result = req['queryResult'] parameters = result.get('parameters') quantity = parameters.get('quantity') platesize = parameters.get("plateSize") if quantity and platesize: item_name = req['queryResult']['outputContexts'][0]['parameters'][ 'items'] email_id = fetchMail(req) it1 = Items() price_both = it1.exploreItem( item_name) # item plate size and menuID if platesize == "full": price = price_both[1] elif platesize == "half" and price_both[0] != "Not Available": price = price_both[0] else: price = price_both[1] platesize = "full (Half-not available)" temp_dict = { 'item_name': item_name, 'quantity': quantity, 'price': int(quantity) * int(price[1:]), 'plate_size': platesize } email_dict[email_id].append(temp_dict) paymentPOST[email_id]['cart'] = [{ 'name': item_name, 'id': price_both[2], 'quantity': int(quantity), 'type': "ANY", 'price': int(price[1:]) }] speech = "Cart Updated Successfully !" return makeSpeech(speech) # Deal with the intent - clearCart elif req['queryResult']['action'] == 'clearCartAction': email_id = fetchMail(req) if email_id in email_dict: del email_dict[email_id] # Deal with the intent - addItemToCart # Used when user says add @ITEM_NAME to cart directly. elif req['queryResult']['action'] == 'addItemToCartAction': result = req['queryResult'] parameters = result.get('parameters') quantity = parameters.get('quantity') platesize = parameters.get("plateSize") if quantity and platesize: item_name = req['queryResult']['outputContexts'][0]['parameters'][ 'items'] email_id = fetchMail(req) it2 = Items() price_both = it2.exploreItem(item_name) if platesize == "full": price = price_both[1] elif platesize == "half" and price_both[0] != "Not Available": price = price_both[0] else: price = price_both[1] platesize = "full (Half-not available)" # Cart updation to show user temp_dict = { 'item_name': item_name, 'quantity': quantity, 'price': int(quantity) * int(price[1:]), 'plate_size': platesize } email_dict[email_id].append(temp_dict) paymentPOST[email_id]['cart'] = [{ 'name': item_name, 'id': price_both[2], 'quantity': int(quantity), 'type': "ANY", 'price': int(price[1:]) }] speech = "Cart Updated Successfully !" return makeSpeech(speech) # Deal with the intent - placeOrder elif req['queryResult']['action'] == 'placeOrderAction': result = req['queryResult'] parameters = result.get('parameters') name = parameters.get("name") mobile = parameters.get("mobile") address = parameters.get("address") landmark = parameters.get('landmark') city = parameters.get('city') pincode = parameters.get('pincode') if name and mobile and address and city and pincode: email_id = fetchMail(req) # Updating Payment Api format for POST request paymentPOST[email_id]['customer'] = [{ 'name': name, 'number': mobile, 'email': email_id, 'address': address, 'landmark': landmark, 'city': city, 'pincode': int(pincode) }] makeSpeech("Redirecting to payment gateway...") # Post request to payment API linkRequest = requests.post(url=menu.paymentAPI, data=json.dumps(paymentPOST[email_id])) return makeSpeech( "This is your payment link click on the link and complete your payment. Thankyou for ordering !\n\n" + str(linkRequest.text)) # Deal with the intent - shoeCart elif req['queryResult']['action'] == 'showCartAction': result = req['queryResult'] email_id = fetchMail(req) no = 1 speech = "" for i in email_dict[email_id]: speech += "Item: " + str(no) + "\n" for k in i: speech += str(k) + "-" + str(i[k]) + "\n" no += 1 return makeSpeech(speech)
def identify_lootscreen_items(search_region, dungeon_name, party): loot = [] thumbnail_directories = [ f'{sfr.game_install_location()}/panels/icons_equip/gem', f'{sfr.game_install_location()}/panels/icons_equip/gold', f'{sfr.game_install_location()}/panels/icons_equip/heirloom', f'{sfr.game_install_location()}/panels/icons_equip/journal_page', f'{sfr.game_install_location()}/panels/icons_equip/provision', f'{sfr.game_install_location()}/panels/icons_equip/supply', f'{sfr.game_install_location()}/dlc/580100_crimson_court/features/' f'districts/panels/icons_equip/heirloom', f'{sfr.game_install_location()}/dlc/580100_crimson_court/features/' f'flagellant/panels/icons_equip/trinket', f'{sfr.game_install_location()}/dlc/580100_crimson_court/features/' f'crimson_court/panels/icons_equip/estate', f'{sfr.game_install_location()}/dlc/580100_crimson_court/features/' f'crimson_court/panels/icons_equip/estate_currency', ] if dungeon_name == 'crimson_court': thumbnail_directories.append( f'{sfr.game_install_location()}/dlc/580100_crimson_court/features' f'/crimson_court/panels/icons_equip/quest_item') thumbnail_directories.append( f'{sfr.game_install_location()}/dlc/580100_crimson_court/features' f'/crimson_court/panels/icons_equip/trinket') elif dungeon_name == 'farmstead': thumbnail_directories.append( f'{sfr.game_install_location()}/dlc/735730_color_of_madness/panels' f'/icons_equip/heirloom') thumbnail_directories.append( f'{sfr.game_install_location()}/dlc/735730_color_of_madness/panels' f'/icons_equip/shard') thumbnail_directories.append( f'{sfr.game_install_location()}/dlc/735730_color_of_madness/panels' f'/icons_equip/supply') thumbnail_directories.append( f'{sfr.game_install_location()}/dlc/735730_color_of_madness/panels' f'/icons_equip/trinket') elif any('shieldbreaker' == hero.heroClass for hero in party) and dungeon_name != 'darkest_dungeon': thumbnail_directories.append( f'{sfr.game_install_location()}/dlc/702540_shieldbreaker/panels' f'/icons_equip/estate') thumbnail_directories.append( f'{sfr.game_install_location()}/dlc/702540_shieldbreaker/panels' f'/icons_equip/trinket') for directory in thumbnail_directories: thumbnails = os.listdir(directory) for thumbnail in thumbnails: found = list( pyautogui.locateAll(rf'{directory}\{thumbnail}', search_region, confidence=.45)) if len(found) > 0: for each_coordinates in found: item_name, item_data = None, None for item, data in Items.items(): if thumbnail in data['thumb']: item_name = item item_data = data break # future - use ocr to determine amount ??? if thumbnail == 'inv_gold+_0.png': amount = 250 elif thumbnail == 'inv_gold+_1.png': amount = 750 elif thumbnail == 'inv_gold+_2.png': amount = 1250 elif thumbnail == 'inv_gold+_3.png': amount = 1750 elif thumbnail == 'inv_provision+_1.png': amount = 4 elif thumbnail == 'inv_provision+_2.png': amount = 8 elif thumbnail == 'inv_provision+_3.png': amount = 12 elif item_data['type'] == 'gem' or item_data[ 'type'] == 'heirloom': amount = math.floor(item_data['full_stack'] / 2) else: amount = 1 loot.append({ 'id': item_name, 'type': item_data['type'], 'amount': amount, 'item_slot': None, 'coords': each_coordinates }) loot.sort(key=lambda k: k['coords'][0]) # sort items from left to right for i, item in enumerate(loot): item['item_slot'] = i return loot
from World import World from Player import Player from Items import Items items = [ Items("club", "melee", 1, 0, 1), Items("dagger", "melee", 3, 0, 4), Items("greatclub", "melee", 5, 0, 12), Items("handaxe", "melee", 8, 0, 18), Items("greatsword", "melee", 12, 0, 25), Items("Maul", "melee", 9, 0, 20), Items("woodshield", "melee", 0, 2, 5), Items("metalshield", "melee", 0, 5, 13), Items("ironshield", "melee", 0, 9, 25), Items("steelshield", "melee", 0, 15, 40) ] t = Player("name", 1, 0, [5, 5]) world = World(t) world.menu()
def add_items(self): item1 = Items('Board','A big board') self.items.append(item1)