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
Example #2
0
    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 _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
Example #4
0
		def huirCueva():
			events.addEvent('cuerda')
			addItem(world, 'cuerda')
			events.addEvent('madera')
			addItem(world, 'madera')
			Item.addNextFood(world)
			Item.addNextFood(world)
Example #5
0
 def add_armor(self, Item, Hero):
     if not self.armory:
         self.armory.append(Item)
       #  self.remove_item(Item)
         Item.use(Hero)
     else:
         return False
Example #6
0
 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")
Example #7
0
 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")
Example #8
0
		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')
Example #9
0
    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)
Example #10
0
		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')
Example #11
0
 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
Example #12
0
		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')
Example #13
0
 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")
Example #14
0
		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')
Example #15
0
 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")
Example #16
0
 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
Example #17
0
 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
Example #18
0
  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 _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
Example #20
0
 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 _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()
Example #22
0
 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
Example #23
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)
Example #24
0
 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)
Example #25
0
 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
Example #26
0
 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)
Example #27
0
	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()
Example #28
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
Example #29
0
 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
Example #30
0
 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,())