def __init__(self): self.display = Display() self.map_player = Map() self.needle = Item("needle", 4, self.map_player) self.map_player.put_item_on_map(self.needle) self.ether = Item("ether", 5, self.map_player) self.map_player.put_item_on_map(self.ether) self.tube = Item("tube", 6, self.map_player) self.map_player.put_item_on_map(self.tube) self.mac_gyver = Player(self.map_player) self.display.load_wall() self.display.load_ground() self.display.load_player_display() self.display.load_jailer() self.display.load_items() self.display.load_font() self.display.refresh(self.map_player, self.mac_gyver) self.display.show_inventory(self.mac_gyver) self.items_in_game = [self.needle, self.ether, self.tube] self.keyboard_list_movements = [ pygame.K_UP, pygame.K_DOWN, pygame.K_LEFT, pygame.K_RIGHT ] self.keyboard_functions = [ self.mac_gyver.move_up, self.mac_gyver.move_down, self.mac_gyver.move_left, self.mac_gyver.move_right ]
def setProgressionPercent(progressBar, value): """ Set \"progressBar\" progression to a value corresponding to \"value\" in percents (0-100%) @param progressBar: object of type \"ProgressBar\" @type progressBar: dict @param value: value to set progressBar progression in percent (0-100%) @type value: int @return: - @rtype: void """ assertProgressBar(progressBar) assert type(value) is int assert value >= 0, "value parameter have to be in [0,100], current value is : %r" % ( value) assert value <= 100, "value parameter have to be in [0,100], current value is : %r" % ( value) value = int(round(value / 100. * progressBar["gutsCount"])) progressBar["progression"] = value Item.setSprite(progressBar, value) return
def main(): #Four items with call functions item1 = Item.Item(9.99, 5, "Cloth Masks Packet") item2 = Item.Item(11.49, 27, "Hand Sanitizer") item3 = Item.Item(24.99, 15, "Head Shield") item4 = Item.Item(8.91, 7, "Eye protection Goggles") #Mutate quantity to 2 for the fourth item item4.set_quantity(2) #Create a list featuring each item itemlist = [item1, item2, item3, item4] #Create lists for price and weights to be added from each item dTotalPrice = [] iTotalWeight = [] print("Here are your shopping cart contents: ") #Make loop to print the string function and add to the lists for each item #To show details of each order for aitem in itemlist: print(aitem) dTotalPrice.append(aitem.get_order_price()) iTotalWeight.append(aitem.get_order_weight_in_ounces()) #Give the sum of the price and weight lists as further details print("The price of your order is $" + str(f"{sum(dTotalPrice):0.2f}")) print("The shipping weight is", (sum(iTotalWeight) // 16), "pounds", sum(iTotalWeight) % 16, "ounces")
def add_armor(self, Item, Hero): if not self.armory: self.armory.append(Item) # self.remove_item(Item) Item.use(Hero) else: return False
def woodYes(): log.add_event("Esto me servira para muchas cosas...") c = Item.create("madera") inv.addItem(c) removeItem(world, "madera") if not (inv.getItem(Item.getItemId("cuerda")) is None): Story.addItem(self.world, "balsa")
def huirCueva(): events.addEvent('cuerda') addItem(world, 'cuerda') events.addEvent('madera') addItem(world, 'madera') Item.addNextFood(world) Item.addNextFood(world)
def ropeYes(): log.add_event("Es una cuerda! Que suerte tengo") c = Item.create("cuerda") inv.addItem(c) removeItem(world, "cuerda") if not (inv.getItem(Item.getItemId("madera")) is None): Story.addItem(self.world, "balsa")
def get_domain_father(domain, domain_type): dict_father = {} dict_father['item_father'] = r_serv_onion.hget('{}_metadata:{}'.format(domain_type, domain), 'paste_parent') if dict_father['item_father'] != 'auto' and dict_father['item_father'] != 'manual': if Item.is_crawled(dict_father['item_father']): dict_father['domain_father'] = Item.get_domain(dict_father['item_father']) return dict_father
def update_domain_by_item(domain_obj, item_id): domain_name = domain_obj.get_domain_name() # update domain tags for tag in Tag.get_item_tags(item_id): if tag != 'infoleak:submission="crawler"' and tag != 'infoleak:submission="manual"': Tag.add_domain_tag(tag, domain_name, Item.get_item_date(item_id)) # update domain correlation item_correlation = Item.get_item_all_correlation(item_id) for correlation_name in item_correlation: for correlation_type in item_correlation[correlation_name]: if correlation_name in ('pgp', 'cryptocurrency'): for correl_value in item_correlation[correlation_name][ correlation_type]: if correlation_name == 'pgp': pgp.save_domain_correlation(domain_name, correlation_type, correl_value) if correlation_name == 'cryptocurrency': cryptocurrency.save_domain_correlation( domain_name, correlation_type, correl_value) if correlation_name == 'decoded': for decoded_item in item_correlation['decoded']: Decoded.save_domain_decoded(domain_name, decoded_item)
def save_item_correlation(self, obj_id, item_id, item_date): self.update_correlation_daterange(obj_id, item_date) # global set r_serv_metadata.sadd( 's_correl:set_item_{}:{}'.format(self.correlation_name, obj_id), item_id) # daily r_serv_metadata.zincrby( 's_correl:date:{}:{}'.format(self.correlation_name, item_date), obj_id, 1) # all correlation r_serv_metadata.zincrby( 's_correl:{}:all'.format(self.correlation_name), obj_id, 1) # item r_serv_metadata.sadd( 'item:s_correl:{}:{}'.format(self.correlation_name, item_id), obj_id) # domain if Item.is_crawled(item_id): domain = Item.get_item_domain(item_id) self.save_domain_correlation(domain, subtype, obj_id)
def __init__(self): pg.init() self.display_width = 1200 self.display_height = 600 self.game_display = pg.display.set_mode( (self.display_width, self.display_height)) pg.display.set_caption('Yeah Toast!') self.clock = pg.time.Clock() self.screen_surf = pg.display.get_surface() self.x_mid = self.screen_surf.get_rect().centerx self.y_mid = self.screen_surf.get_rect().centery self.HappyBread = NewtonianItem(game_handle=self, sprite='resources/HappyBread_wT.png', coordinates=(self.x_mid, self.y_mid)) self.Toaster = Item(game_handle=self, sprite='resources/Toaster.png', coordinates=(256, 288)) self.fleet = Fleet([self.Toaster, self.HappyBread]) self.mode = {'move': 'accelerate', 'sticky_rotate': False}
def _createRootList(self): """ Create and return the root list (all type available) Returns list and name of the list """ list = [] listTitle = _( 10 ) # List the main categorie at the root level for cat in self.racineDisplayList: item = {} #item['id'] = "" item['name'] = Item.get_type_title( cat ) #item['parent'] = self.type item['downloadurl'] = None item['type'] = 'CAT' item['xbmc_type'] = cat item['cattype'] = cat item['previewpictureurl'] = None item['description'] = Item.get_type_title( cat ) item['language'] = "" item['version'] = "" item['author'] = "" item['date'] = "" item['added'] = "" item['thumbnail'] = Item.get_thumb( cat ) item['previewpicture'] = ""#Item.get_thumb( cat ) item['image2retrieve'] = False # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download) list.append(item) print item return listTitle, list
def newlevel(level): background.blit(backimg, (0, 0)) nums.empty() ops.empty() doors.empty() global player count = 0 try: levfile = open(os.path.join("levels", "level%d.txt" % (level))) data = [line.strip() for line in levfile] Item.setlevel(data, charset) for y, row in enumerate(data[:12]): for x, cell in enumerate(row): if cell != 'w': cell = '.' background.blit(images[cell], (32 * x + 48, 32 * y + 64)) for y, row in enumerate(data[:12]): for x, cell in enumerate(row): if cell == '-' or cell == '*' or cell == '/' or cell == '2' or cell == 's': ops.add(Item.Op((x, y), cell, images[cell])) elif cell == 'p': player = Player.Player((x, y), data, images['p']) elif cell == 'd': doors.add(Item.Door((x, y), images['d'])) elif cell == '#': nums.add( Item.Num((x, y), int(data[12 + count]), images['#'])) count += 1 return 1 except IOError: return 0
def move(m, k, b): """Fait bouger un monstre dans la direction de Knil s'il est en vue. Sinon le fait érrer aléatoirement.""" mx, my = getPos(m) x, y = Knil.getPos(k) x0, y0 = Background.getOrigin(b) kx, ky = x + x0, y + y0 v = mx - kx, my - ky if is_Knil_in_room(m, k, b): if Item.exist("flashlight") and Flashlight.isActivated( Item.getFlashlight()): highlighted_case_pos = Flashlight.get_highlighted_case_pos( Item.getFlashlight(), b["map"], kx, ky) if (mx, my) in highlighted_case_pos: return None, False if is_Knil_in_sight(m, k, b): if mx != kx and my != ky and Background.isCrossable( Background.getCase(b, mx - v[0] / abs(v[0]), my - v[1] / abs(v[1]))): m['position'] = mx - v[0] / abs(v[0]), my - v[1] / abs(v[1]) elif mx == kx and my != ky: m['position'] = mx, my - v[1] / abs(v[1]) elif mx != kx and my == ky: m['position'] = mx - v[0] / abs(v[0]), my return (mx, my), m["position"] != (mx, my) else: return wander(m, k, b) else: return None, False
def main( ): #2nd main that prints the same as the given main but instead uses a for loop dTotalPrice = 0.0 #initial total price of the order iTotalWeight = 0 #initial total weight of the whole order #all the items and their descriptions item1 = Item.Item(24.99, 14, "Wireless Mouse") item2 = Item.Item(22.49, 27, "USB Keyboard") item3 = Item.Item(24.99, 12, "HDMI Cable") item4 = Item.Item(7.99, 7, "Reading Glasses") item4.set_quantity(2) itemLst = [] #empty list created to add all the items into it #all the iems getting appended to the empty list itemLst.append(item1) itemLst.append(item2) itemLst.append(item3) itemLst.append(item4) for i in itemLst: #for loop used to print the descriptions for each item as well as to calculate the total order price and weight print(i) #prints each item's description dTotalPrice += i.getOrderPrice( ) #adds the prices of each item to calculate the total item price iTotalWeight += i.getOrderWeightInOunces( ) #adds the weight of each item to calculate the total weight of the order #prints the total value of the order price and weight print("The price of your order is $" + str(dTotalPrice)) print("The shipping weight is", (int)(iTotalWeight / 16), "pounds", iTotalWeight % 16, "ounces")
def __init__(self): self.name = random.choice(NAMES) self.health = 150 self.inventory = [Item.potion(5), Item.scroll(10), Item.spice(5)] self.interactions = ["talk", "attack", "examine", "buy", "sell"] self.gold = 500 self.vendor = 1 + (random.randint(-1000, 1000) / 1000.0)
def main(): dTotalPrice = 0.0 iTotalWeight = 0 # Put the 4 items being ordered in item1 through item 4 item1 = Item.Item(24.99, 14, "Wireless Mouse") item2 = Item.Item(22.49, 27, "USB Keyboard") item3 = Item.Item(24.99, 12, "HDMI Cable") item4 = Item.Item(7.99, 7, "Reading Glasses") item4.set_quantity(2); # Show the details of the order using show() print("Here are your shopping cart contents. \n") listTotal = [item1, item2, item3, item4] # Compute the total price and total weight in this section using FOR LOOP for item in listTotal: dTotalPrice += item.getOrderPrice() iTotalWeight += item.getOrderWeightInOunces() print("The total price of your order is $" + str(dTotalPrice)); print("The total shipping weight is", (int)(iTotalWeight / 16), "pounds", iTotalWeight % 16 , "ounces"); print("\n")
def __init__(self): self.name = random.choice(NAMES) self.health = 150 self.inventory = [Item.potion(), Item.scroll()] self.interactions = ["talk", "attack", "examine", "buy", "sell"] self.gold = 200 self.vendor = 1.1
def main(): dTotalPrice = 0.0 iTotalWeight = 0 # Put the 4 items being ordered in item1 through item 4 item1 = Item.Item(24.99, 14, "Wireless Mouse") item2 = Item.Item(22.49, 27, "USB Keyboard") item3 = Item.Item(24.99, 12, "HDMI Cable") item4 = Item.Item(7.99, 7, "Reading Glasses") item4.set_quantity(2) # Show the details of the order using show() print("Here are your shopping cart contents.") print(item1) print(item2) print(item3) print(item4) # Compute the total price and total weight in this section dTotalPrice += item1.getOrderPrice() dTotalPrice += item2.getOrderPrice() dTotalPrice += item3.getOrderPrice() dTotalPrice += item4.getOrderPrice() iTotalWeight += item1.getOrderWeightInOunces() iTotalWeight += item2.getOrderWeightInOunces() iTotalWeight += item3.getOrderWeightInOunces() iTotalWeight += item4.getOrderWeightInOunces() # Here we show the order details print("The price of your order is $" + str(dTotalPrice)) print("The shipping weight is", (int)(iTotalWeight / 16), "pounds", iTotalWeight % 16, "ounces")
def __init__(self): self.name = random.choice(NAMES) self.health = 50 self.inventory = [Item.scrap(), Item.rock()] self.interactions = ["talk", "attack", "examine", "buy", "sell"] self.gold = 0 self.vendor = .7
def show(b, k): """Affiche la zone de la map à afficher à l'écran, en tenant compte des differents cas particuliers comme la luminosité, ou encore les toits des maisons""" x0, y0 = getOrigin(b) kx, ky = Knil.getPos(k) knil_case = getCase(b, kx+x0, ky+y0) ROWS, COLS = getDimension(b) special_attrib = bool("special_case" in knil_case.keys()) if special_attrib: special_ID = knil_case["special_case"]["attrib"]["id"] if Item.exist("flashlight") and Flashlight.isActivated(Item.getFlashlight()): highlighted_case_pos = Flashlight.get_highlighted_case_pos(Item.getFlashlight(), b['map'], x0+kx, y0+ky) for j in range(ROWS): goto((j+1), 1) for i in range(COLS): case = getCase(b, x0+i, y0+j) if "special_case" in case.keys(): if special_attrib: if special_ID != case["special_case"]["attrib"]["id"]: if "object" in case.keys() and case["object"]: caracs = '!!' case = case["special_case"] # Si la case à un "toit", et si Knil n'est pas sous ce "toit" # Alors la case à afficher est ce "toit" et non la case en dessous # Par contre, si Knil est sous le "toit", il faut enlever tous les "toits" correspondants else: case = case["special_case"]
def __init__(self): self.name = random.choice(NAMES) self.health = 200 self.inventory = [Item.sword(), Item.shield(), Item.knife()] self.interactions = ["talk", "attack", "examine"] self.gold = 100 self.vendor = 1.0 + (random.randint(-250, 1000) / 1000.0)
def save_item_relationship(sha1_string, item_id): estimated_type = get_decoded_item_type(sha1_string) if not estimated_type: print('error, unknow sha1_string') item_date = Item.get_item_date(item_id) r_serv_metadata.zincrby('hash_date:{}'.format(item_date), sha1_string, 1) update_decoded_daterange(sha1_string, item_date) # first time we see this hash (all encoding) on this item if r_serv_metadata.zscore('nb_seen_hash:{}'.format(sha1_string), item_id) is None: r_serv_metadata.hincrby('metadata_hash:{}'.format(sha1_string), 'nb_seen_in_all_pastes', 1) #### MOVE IT ???? # # FIXME: r_serv_metadata.zincrby('nb_seen_hash:{}'.format(sha1_string), item_id, 1) # hash - paste map r_serv_metadata.sadd('hash_paste:{}'.format(item_id), sha1_string) # item - hash map # domain if Item.is_crawled(item_id): domain = Item.get_item_domain(item_id) save_domain_relationship(domain, sha1_string)
def preview(self, filename): self.clear() item = Item(realm=self.realm) if item.load(str(filename), silent=1) == -2: return stattext = [] for slot in item.slots(): gemtype = slot.type() if not gemtype or gemtype == 'Unused': continue statstr = slot.effect() + ' ' + slot.amount() if slot.type() == 'Resist' or slot.type() == 'Focus' or slot.type( ) == 'Cap Increase': statstr += ' ' + slot.type() stattext.append(statstr) classinfo = AllBonusList[self.realm][self.charclass] listtext = [ str(item.ItemName), "Level: %s Quality: %s" % (item.Level, item.ItemQuality), "AF/DPS: %s Speed: %s" % (item.AFDPS, item.Speed), "Utility: %.1f Bonus: %s" % (item.utility(classinfo), item.Bonus) ] self.addItems(listtext) self.addItems(stattext)
def save_item_relationship(obj_id, item_id): r_serv_metadata.hset('paste_metadata:{}'.format(item_id), 'screenshot', obj_id) r_serv_onion.sadd('screenshot:{}'.format(obj_id), item_id) if Item.is_crawled(item_id): domain = Item.get_item_domain(item_id) save_domain_relationship(obj_id, domain)
def addItem(): item = main.get_inventory() createItemForm = CreateItemForm(request.form) if request.method == 'POST': filename = str(uuid.uuid4()) + createItemForm.item_id.data + '.jpg' cost = float(f'{createItemForm.item_cost.data :.2f}') if createItemForm.item_type.data == "W": item = Item.Wired(createItemForm.item_id.data, createItemForm.item_name.data, cost, filename) elif createItemForm.item_type.data == "WL": item = Item.Wireless(createItemForm.item_id.data, createItemForm.item_name.data, cost, filename) item.set_stock(createItemForm.item_quantity.data) main.product_management.update_item(item) print(request.files) print(request.files['file']) print(filename) file = request.files['file'] file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) return redirect(url_for('adminItemDashboard')) return render_template('adminCreateItem.html', form=createItemForm)
def show(m, k, b): """Affiche un monstre en effacant la case sur laquelle il était auparavant""" x0, y0 = Background.getOrigin(b) ROWS, COLS = Background.getDimension(b) kx, ky = Knil.getPos(k) x, y = getPos(m) mx, my = x - x0, y - y0 # efface la case précédente if 'previous_case' in m.keys() and m['previous_case'] is not None: px, py = m['previous_case'] if (px, py) != (mx, my): case = Background.getCase(b, px, py) if px >= x0 and px < x0 + COLS and py >= y0 and py < y0 + ROWS: bgcolor = Background.getBgcolor(case) if "brightness" in case.keys(): if Item.exist("flashlight") and Flashlight.isActivated( Item.getFlashlight()): highlighted_case_pos = Flashlight.get_highlighted_case_pos( Item.getFlashlight(), b['map'], x0 + kx, y0 + ky) if (px, py) in highlighted_case_pos: case = Background.highlight_case( case, Item.getFlashlight()) bgcolor = Background.getBgcolor(case, False) color(fontcolor=getColor(m), bgcolor=bgcolor) goto((py - y0) + 1, (px - x0) * 2 + 1) for c in case["c"]: if isinstance(c, str): w(c) else: w(Background.special_carac[c])
def newlevel(level): background.blit(backimg, (0,0)) nums.empty() ops.empty() doors.empty() global player count = 0 try: levfile = open(os.path.join("levels", "level%d.txt"%(level))) data = [line.strip() for line in levfile] Item.setlevel(data, charset) for y, row in enumerate(data[:12]): for x, cell in enumerate(row): if cell != 'w': cell = '.' background.blit(images[cell], (32*x+48, 32*y+64)) for y, row in enumerate(data[:12]): for x, cell in enumerate(row): if cell == '-' or cell == '*' or cell == '/' or cell == '2' or cell == 's': ops.add(Item.Op((x, y), cell, images[cell])) elif cell == 'p': player = Player.Player((x, y), data, images['p']) elif cell == 'd': doors.add(Item.Door((x, y), images['d'])) elif cell == '#': nums.add(Item.Num((x, y), int(data[12+count]), images['#'])) count += 1 return 1 except IOError: return 0
def chest(player_team): """ Generates a chest. """ c = random.randint(1, 2) #c = 1 # FIXME: delete when armor and weapons implemented if c == 0: print("Not here yet.") # armor elif c == 1: # FIXME: names are weird a_types = ["Chain", "Plate"] a_names = ["helmet", "torso", "leggings", "boots"] t = random.choice(a_types) p = random.choice(a_names) item = Item.Armor("{} {}".format(t, p.capitalize()), "A sturdy piece of armor.", t, p, player_team) # potion elif c == 2: potions = ["Minor", "Normal", "Major"] t = random.choice(potions) item = Item.Healing_Potion("{} Healing Potion".format(t), "Heals a character.", t) g = random.randint(100, 200) print("You found {} gold!".format(g)) player_team[0].gold += g print("You found {}!".format(item.name)) player_team[0].backpack.append(item) return
def _createScraperList(self): """ Create and return the list of scraper types Returns list and name of the list """ list = [] listTitle = Item.get_type_title(Item.TYPE_SCRAPER) # List all the type of plugins for cat in self.scraperDisplayList: item = {} item["name"] = Item.get_type_title(cat) item["downloadurl"] = None item["type"] = "CAT" item["xbmc_type"] = cat item["previewpictureurl"] = None item["description"] = Item.get_type_title(cat) item["language"] = "" item["version"] = "" item["author"] = "" item["date"] = "" item["added"] = "" item["thumbnail"] = Item.get_thumb(cat) item["previewpicture"] = "" # Item.get_thumb( cat ) item[ "image2retrieve" ] = ( False ) # Temporary patch for reseting the flag after download (would be better in the thread in charge of the download) list.append(item) print item return listTitle, list
def get_domain_items_crawled(domain, domain_type, port, epoch=None, items_link=False, item_screenshot=False, item_tag=False): ''' ''' item_crawled = {} item_root = get_domain_crawled_item_root(domain, domain_type, port, epoch=epoch) if item_root: item_crawled['port'] = port item_crawled['epoch'] = item_root['epoch'] item_crawled['date'] = time.strftime('%Y/%m/%d - %H:%M.%S', time.gmtime(item_root['epoch'])) item_crawled['items'] = [] if item_root['root_item'] != str(item_root['epoch']): for item in get_domain_items(domain, item_root['root_item']): dict_item = {"id": item} if items_link: dict_item['link'] = Item.get_item_link(item) if item_screenshot: dict_item['screenshot'] = Item.get_item_screenshot(item) if item_tag: dict_item['tags'] = Tag.get_obj_tags_minimal(item) item_crawled['items'].append(dict_item) return item_crawled
def main(): dTotalPrice = 0.0 iTotalWeight = 0 # Put the 4 items being ordered in item1 through item 4 item1 = Item.Item(9.99, 5, "Cloth Masks Packet") item2 = Item.Item(11.49, 27, "Hand Sanitizer") item3 = Item.Item(24.99, 15, "Head Shield") item4 = Item.Item(8.91, 7, "Eye protection Goggles") item4.set_quantity(2) # Show the details of the order using: print("Here are your shopping cart contents.") print(item1) print(item2) print(item3) print(item4) # Compute the total price and total weight in this section dTotalPrice += item1.get_order_price() dTotalPrice += item2.get_order_price() dTotalPrice += item3.get_order_price() dTotalPrice += item4.get_order_price() iTotalWeight += item1.get_order_weight_in_ounces() iTotalWeight += item2.get_order_weight_in_ounces() iTotalWeight += item3.get_order_weight_in_ounces() iTotalWeight += item4.get_order_weight_in_ounces() # Here we show the order details print("The price of your order is $" + str(dTotalPrice)) print("The shipping weight is", (iTotalWeight // 16), "pounds", iTotalWeight % 16, "ounces")
def get_domain_all_url(domain, domain_type, domain_ports=None): if not domain_ports: domain_ports = get_domain_all_ports(domain, domain_type) all_url = {} for port in domain_ports: for dict_history in get_domain_history_with_status(domain, domain_type, port, add_root_item=True): if dict_history['status']: # domain UP crawled_items = get_domain_items(domain, dict_history['root_item']) for item_id in crawled_items: item_url = Item.get_item_link(item_id) item_date = int(Item.get_item_date(item_id)) if item_url: if item_url not in all_url: all_url[item_url] = { 'first_seen': item_date, 'last_seen': item_date } else: # update first_seen / last_seen if item_date < all_url[item_url]['first_seen']: all_url[item_url]['first_seen'] = item_date if item_date > all_url[item_url]['last_seen']: all_url[item_url]['last_seen'] = item_date return all_url
def get_domain_item_children(domain, root_item_id): all_items = [] for item_id in Item.get_item_children(root_item_id): if Item.is_item_in_domain(domain, item_id): all_items.append(item_id) all_items.extend(get_domain_item_children(domain, item_id)) return all_items
def armor_event(player_team): """ Runs the armor event. Generates a piece of low-level armor. """ print( "You see a piece of armor lying on the ground. You pick it up and put it in your backpack." ) r = random.randint(0, 3) if r == 0: item = Item.Armor("Leather Helmet", "A leather helmet to prevent light injuries.", "Leather", "helmet", player_team) elif r == 1: item = Item.Armor("Leather Chest Piece", "Leather armor to prevent light injuries.", "Leather", "torso", player_team) elif r == 2: item = Item.Armor("Leather Pants", "Essentially leggings.", "Leather", "leggings", player_team) elif r == 3: item = Item.Armor("Leather Boots", "Stylish leather boots. Just do it.", "Leather", "boots", player_team) player_team[0].backpack.append(item) return
def balsaFunY(): log.add_event("No tengo nada mejor que hacer con estos recursos, mejor los uso") events.addEvent('final_balsa') c = Item.create('balsa') inv.addItem(c) inv.deleteItem(Item.create('madera')) inv.deleteItem(Item.create('cuerda')) inv.clean() removeItem(world, 'balsa')
def generate_items(self): global ITEMS global NUM_ITEMS ind = randint(0, NUM_ITEMS-1) newitem = Item(self, ITEMS[ind]) initial_y = randint(0, 240) initial_y -= 120 newitem.move_pos(y = initial_y) self.item_list.append(newitem)
def getChildren(self): sublist=[] for n in self.node.getSetOfInputPort(): sublist.append(Item.adapt(n)) for n in self.node.getSetOfOutputPort(): sublist.append(Item.adapt(n)) for n in self.node.getSetOfInputDataStreamPort(): sublist.append(Item.adapt(n)) for n in self.node.getSetOfOutputDataStreamPort(): sublist.append(Item.adapt(n)) return sublist
def jabaliFunY(): log.add_event("Su alimento me ayudara a sobrevivir") c = Item.create('comida') inv.addItem(c) inv.addItem(c) inv.clean() removeItem(world, 'b_jabali') Item.removeItem('b_jabali') Item.addItem('b_jabali', 78, 154, '/') addItem(world, 'b_jabali')
def jabali2FunY(): log.add_event("Mas alimento me ayudara a sobrevivir") c = Item.create('comida') inv.addItem(c) inv.addItem(c) inv.clean() events.addEvent('dead_man') addItem(world, 'dead_man') addItem(world, 'm_jabali') removeItem(world, 'b_jabali') Item.removeItem('b_jabali')
def boarYes(): if inv.getItem(Item.getItemId("cuchillo")) is None: # TODO Killed log.add_event("Esto fue demasiado para mi....", 197) self.info.gameOver() else: log.add_event("Por fin murio...") c = Item.create("comida") inv.addItem(c) inv.addItem(c) inv.addItem(c) removeItem(world, "m_jabali")
def jabaliMFunY(): if(inv.getItem(Item.getItemId('cuchillo')) is None): log.add_event("Esto fue demasiado para mi....", 197) info.gameOver() else: log.add_event("Eso fue facil... creo") c = Item.create('comida') inv.addItem(c) inv.addItem(c) inv.clean() removeItem(world, 'm_jabali') Item.removeItem('m_jabali')
def addNode(self,service): new_node=service.clone(None) ItemComposedNode.n=ItemComposedNode.n+1 name=service.getName()+"_%d" % ItemComposedNode.n new_node.setName(name) #replace the old node (if it exists) with the new one nodes=self.node.edGetDirectDescendants() if nodes: old_item=Item.adapt(nodes[0]) CONNECTOR.Emit(old_item,"remove") self.node.edSetNode(new_node) item=Item.adapt(new_node) CONNECTOR.Emit(self,"add",item) CONNECTOR.Emit(self,"changed")
def remove_weapon(self, hand, Item, Hero): if hand == "left": if self.lhand_weapon: self.lhand_weapon.remove(Item) # self.add_item(Item) Item.remove(Hero) else: return False if hand == "right": if self.rhand_weapon: self.rhand_weapon.remove(Item) self.add_item(Item) Item.remove(Hero) else: return False
def add_weapon(self, hand, Item, Hero): if hand == "left": if not self.lhand_weapon: self.lhand_weapon.append(Item) # self.remove_item(Item) Item.use(Hero) else: return False elif hand == "right": if not self.rhand_weapon: self.rhand_weapon.append(Item) self.remove_item(Item) Item.use(Hero) else: return False
def connect(self): print "ControlItem.connect",self.context print self.port item=Item.adapt(self.port) print item item.connect() self.context.connecting(item)
def _setDefaultImages(self, item): """ Set the images with default value depending on the type of the item """ print "_setDefaultImages" print item['previewpictureurl'] if item['previewpictureurl'] == '': # No picture available -> use default one item['thumbnail'] = Item.get_thumb( item['xbmc_type'] ) # icone item['previewpicture'] = ""#Item.THUMB_NOT_AVAILABLE # preview else: # Check if picture is already downloaded and available downloadImage = False thumbnail, checkPathPic = set_cache_thumb_name( item['previewpictureurl'] ) if thumbnail and os.path.isfile( thumbnail ): item['thumbnail'] = thumbnail else: item['thumbnail'] = Item.THUMB_NOT_AVAILABLE downloadImage = True if os.path.exists(checkPathPic): item['previewpicture'] = checkPathPic else: item['previewpicture'] = ""#Item.THUMB_NOT_AVAILABLE downloadImage = True if downloadImage == True: # Set flag for download (separate thread) item['image2retrieve'] = True
def __init__(self,parent,item): QVBox.__init__(self,parent) self.item=item vsplit=QSplitter(Qt.Vertical,self,"VSplitter") vbox=QVBox(vsplit) vbox.layout().setAlignment(Qt.AlignTop|Qt.AlignLeft) row0=QHBox(vbox) label=QLabel("Name: ",row0) self.lined0 = QLineEdit(item.node.getName(),row0) #row1=QVBox(self) #self.setStretchFactor(row1,10) row2=QHBox(vbox) but1=QPushButton( "Save", row2 ) but1.setFixedSize( but1.sizeHint()) but2=QPushButton( "Cancel", row2 ) but2.setFixedSize( but2.sizeHint()) self.connect( but1, SIGNAL("clicked()"), self.handleSave ) self.connect( but2, SIGNAL("clicked()"), self.handleCancel ) nodes= item.node.edGetDirectDescendants() if nodes: node=nodes[0] subitem=Item.adapt(node) panel=subitem.box(vsplit)
def _getList( self, listItem=None ): """ Retrieves list matching to a specific list Item """ # Check type of selected item list = [] curCategory = None #TODO: manage exception try: if listItem != None: listItemName = listItem['name'] if listItem['type'] == 'cat': listItemID = listItem['id'] listTitle = listItem['name'] #if listItem['xbmc_type'] == Item.TYPE_NEW: if listItem['xbmc_type'] == Item.TYPE_SKIN_NIGHTLY: curCategory = listItemName list = self._createCatList( listItemID, skipdescript=True ) list.append( self._createALLListItem( listItem['xbmc_type'] ) ) else: # List of item to download case curCategory = listItemName list = self._createCatList( listItemID ) list.append( self._createALLListItem( listItem['xbmc_type'] ) ) elif listItem['type'] == Item.TYPE_NEW: # Lastest/new items case # We look for 30 days back # TODO: set the duration in settings curCategory = listItemName # Create epoch date sincedate = mktime((date.today() - timedelta(days=30)).timetuple()) list = self._createNewItemList( sincedate, skipdescript=True ) # list = [] # # Merge list (could be optimized) # for xbmcType in validCatList: # list = list + self._createNewItemList( sincedate, xbmcType, skipdescript=True ) elif listItem['type'] == 'addon_type': curCategory = Item.get_type_title( listItem['xbmc_type'] ) list = self._createXbmcTypeList( listItem['xbmc_type'] ) else: # Return the current list #TODO: start download here? print "This is not a category but an item (download)" list = None else: # listItem == None # 1st time (init), we display root list # List the main categorie at the root level curCategory = _( 10 ) list = self._createCatList( 0 ) # Convert Fr title to En if necessary self._convertFr2EnRootTitle(list) list.append( self._createNEWListItem() ) except Exception, e: print "Exception during getNextList" print e print_exc()
def selected(self): #print "ItemComposedNode selected" root=self.node.getRootNode() rootItem=Item.adapt(root) if not self.emitting: self.emitting=1 CONNECTOR.Emit(rootItem,"selected",self) self.emitting=0
def lookup(keylist): """ key is of type list """ args = [] table = TABLE[str(keylist[0])] length = len(keylist) i = 1 while i in range(1, length): if keylist[i] == WILDCARD: # allow for wildcard rolling randomkey = random.choice(table.keys()) table = table[randomkey] keylist[i] = randomkey elif keylist[i] == ARG_BEGIN: # remove the "(" keylist.pop(i) # we are in arguments while True: if keylist[i] != ARG_END: args.append(keylist[i]) keylist.pop(i) length -= 1 if keylist[i] == ARG_END: keylist.pop(i) length -= 1 break else: table = table[keylist[i]] i += 1 # find proper item subclass lastfound = ITEMCLASS for j in range(1, len(keylist)): keylist_ = keylist[0:j] if Item.list_to_dict_key(keylist_) in ITEMSUBCLASS: lastfound = ITEMSUBCLASS[Item.list_to_dict_key(keylist_)] # if no special class, use base class return lastfound(table, keylist, args=args)
def __init__(self,node,port,canvas): QCanvasEllipse.__init__(self,6,6,canvas) self.port=port self.item=None self.item=Item.adapt(self.port) self.setPen(QPen(Qt.black)) self.setBrush(QBrush(Qt.red)) self.setZ(node.z()+1) self.node=node
def __init__(self,node,port,canvas): QCanvasRectangle.__init__(self,canvas) self.setSize(6,6) self.port=port self.setPen(QPen(Qt.black)) self.setBrush(QBrush(Qt.red)) self.setZ(node.z()+1) self.node=node self.item=Item.adapt(self.port)
def new_title(self, *args, input_f=input): title = input_f('Enter title: ') value = int(input_f('Enter value (integer): ')) item_type = input_f('Enter item type [book | av | magazine]: ') num_items = int(input_f('Number of Items to create (integer): ')) t = Item.new_title(title, value, item_type, num_items=num_items) self.data['Titles'].append(t) for item in t.items: self.data['Items'].append(item) t.display()
def addNode(self,service): print "Composed.addNode",service #add node service in the parent self which is a ComposedNode new_node=service.clone(None) ItemComposedNode.n=ItemComposedNode.n+1 name=service.getName()+"_%d" % ItemComposedNode.n new_node.setName(name) self.node.edAddChild(new_node) item=Item.adapt(new_node) CONNECTOR.Emit(self,"add",item)
def selected(self): #print "ItemNode selected" root=self.node.getRootNode() rootItem=Item.adapt(root) if not self.emitting: self.emitting=1 #for those that have subscribed to item level CONNECTOR.Emit(self,"selected",self) #for those that have subscribed to rootItem level CONNECTOR.Emit(rootItem,"selected",self) self.emitting=0
def __init__(self,port,root=None): Item.Item.__init__(self) self.port=port self.label=port.getName() if root: self.root=root elif self.port.getNode().getFather(): root=self.port.getNode().getRootNode() self.root=Item.adapt(root) else: self.root=None
def __init__(self,item,parent): self.parent=parent self.item=item self.node=item.node #initial canvas size : 1000x1000 self.canvas=MyCanvas(1000,1000) self.editor=GraphViewer(self.canvas,parent,"example",0) self.createGraph() root=self.node.getRootNode() rootItem=Item.adapt(root) CONNECTOR.Connect(rootItem,"selected",self.selectItem,()) CONNECTOR.Connect(self.item,"add",self.addItem,()) CONNECTOR.Connect(self.item.datalinks,"add",self.addLink,())