예제 #1
0
	def __init__(self, game, element):
		self.g = game.g
		objects.NPC.__init__(self, game, element) #initialize our parent
		self.vision = int(data.get_xml_prop(element, "vision")) #load properties
		self.reward = int(data.get_xml_prop(element, "reward"))
		self.class_name = data.get_xml_prop(element, "class")
		self.trainer_name = data.get_xml_prop(element, "name")
		self.pre_script = data.get_node(element, "pre_script")
		self.post_script = data.get_node(element, "post_script")
		#load spotted icon
		self.spotted_pic = data.load_image("objects/spotted.png")
		self.spotted_pic.convert_alpha()
		#get whether we have been fought or not
		self.fought = self.g.save.get_prop(self.id, "fought", False)
		self.moving = True
		self.seen = False #set if we've seen somebody
		self.move_data = [0, 0, 0] #store the movement we're going to do
		self.wait_time = 0 #amount of time to display icon
		#load party data
		party = []
		for node in data.get_node(element, "party").childNodes: #loop through pokemon
			if node.localName == "pokemon": #if it's a pokemon
				t = [node.getAttribute("type"), node.getAttribute("level")] #generate data
				party.append(t) #and save it
		self.party = party
예제 #2
0
 def __init__(self, game, element):
     self.g = game.g
     objects.NPC.__init__(self, game, element)  #initialize our parent
     self.vision = int(data.get_xml_prop(element,
                                         "vision"))  #load properties
     self.reward = int(data.get_xml_prop(element, "reward"))
     self.class_name = data.get_xml_prop(element, "class")
     self.trainer_name = data.get_xml_prop(element, "name")
     self.pre_script = data.get_node(element, "pre_script")
     self.post_script = data.get_node(element, "post_script")
     #load spotted icon
     self.spotted_pic = data.load_image("trainers/spotted.png")
     self.spotted_pic.convert_alpha()
     #get whether we have been fought or not
     self.fought = self.g.save.get_prop(self.id, "fought", False)
     self.moving = True
     self.seen = False  #set if we've seen somebody
     self.move_data = [0, 0, 0]  #store the movement we're going to do
     self.wait_time = 0  #amount of time to display icon
     #load party data
     party = []
     for node in data.get_node(element,
                               "party").childNodes:  #loop through pokemon
         if node.localName == "pokemon":  #if it's a pokemon
             t = [node.getAttribute("type"),
                  node.getAttribute("level")]  #generate data
             party.append(t)  #and save it
     self.party = party
예제 #3
0
 def load_data(self, dom):  #load data from a dom
     self.dom = dom
     self.data = Container()
     d = self.data
     g = data.get_xml_prop
     d.name = g(dom, "name")  #load various root properties
     d.show_name = g(dom, "show_name")
     d.anim_front = g(dom, "anim_front")
     d.anim_back = g(dom, "anim_back")
     d.species = g(dom, "species")
     d.exp_growth = g(dom, "exp")
     d.number = int(g(dom, "num"))
     d.catch_rate = int(g(dom, "catch"))
     d.gender_ratio = int(g(dom, "gender"))
     #load type data
     d.type = [x for x in g(dom, "type").split("|")]
     #load pokedex data
     t = data.get_node(dom, "pokedex")
     d.pokedex = Container()
     d = d.pokedex
     d.height = int(g(t, "height"))
     d.weight = float(g(t, "weight"))
     d.description = g(t, "desc")
     d.color = g(t, "color")
     d.number = int(g(t, "num"))
     d.type = g(dom, "type").split("|")
     #load ability data
     self.data.ability = Container()
     self.data.ability.normal = []
     self.data.ability.hidden = []
     t = data.get_node(dom, "ability").getElementsByTagName("normal")
     for ability in t:
         self.data.ability.normal.append(data.get_node_text(ability))
     t = data.get_node(dom, "ability").getElementsByTagName("hidden")
     for ability in t:
         self.data.ability.hidden.append(data.get_node_text(ability))
     self.data.breeding = Container()
     d = self.data.breeding  #load breeding data
     d.group = g(dom, "group")
     d.cycles = int(g(dom, "cycles"))
     self.data.base = Container()  #base yield data load
     d = self.data.base
     t = data.get_node(dom, "base")
     d.exp = int(g(t, "exp"))
     d.ev = []
     d.stats = []
     for ev in g(t, "ev").split("|"):
         d.ev.append(int(ev))
     for stat in g(t, "stats").split("|"):
         d.stats.append(int(stat))
     #DOES NOT LOAD EVOLUTION DATA!!!
     self.data.learnset = Container()
     d = self.data.learnset
     t = data.get_node(dom, "learnset")
     d.level = []
     for level in data.get_node(dom, "level").getElementsByTagName("move"):
         d.level.append(
             (int(level.getAttribute("level")), data.get_node_text(level)))
     d.tm = []
     d.hm = []
     for tm in g(t, "tm").split("|"):
         d.tm.append(int(tm))
     for hm in g(t, "hm").split("|"):
         d.hm.append(int(hm))
예제 #4
0
 def load_data(self, dom): #load data from a dom
     self.dom = dom
     self.data = Container()
     d = self.data
     g = data.get_xml_prop
     d.name = g(dom, "name") #load various root properties
     d.show_name = g(dom, "show_name")
     d.anim_front = g(dom, "anim_front")
     d.anim_back = g(dom, "anim_back")
     d.species = g(dom, "species")
     d.exp_growth = g(dom, "exp")
     d.number = int(g(dom, "num"))
     d.catch_rate = int(g(dom, "catch"))
     d.gender_ratio = int(g(dom, "gender"))
     #load type data
     d.type = [x for x in g(dom, "type").split("|")]
     #load pokedex data
     t = data.get_node(dom, "pokedex")
     d.pokedex = Container()
     d = d.pokedex
     d.height = int(g(t, "height"))
     d.weight = float(g(t, "weight"))
     d.description = g(t, "desc")
     d.color = g(t, "color")
     d.number = int(g(t, "num"))
     d.type = g(dom, "type").split("|")
     #load ability data
     self.data.ability = Container()
     self.data.ability.normal = []
     self.data.ability.hidden = []
     t = data.get_node(dom, "ability").getElementsByTagName("normal")
     for ability in t:
         self.data.ability.normal.append(data.get_node_text(ability))
     t = data.get_node(dom, "ability").getElementsByTagName("hidden")
     for ability in t:
         self.data.ability.hidden.append(data.get_node_text(ability))
     self.data.breeding = Container()
     d = self.data.breeding #load breeding data
     d.group = g(dom, "group")
     d.cycles = int(g(dom, "cycles"))
     self.data.base = Container() #base yield data load
     d = self.data.base
     t = data.get_node(dom, "base")
     d.exp = int(g(t, "exp"))
     d.ev = []
     d.stats = []
     for ev in g(t, "ev").split("|"):
         d.ev.append(int(ev))
     for stat in g(t, "stats").split("|"):
         d.stats.append(int(stat))
     #DOES NOT LOAD EVOLUTION DATA!!!
     self.data.learnset = Container()
     d = self.data.learnset
     t = data.get_node(dom, "learnset")
     d.level = []
     for level in data.get_node(dom, "level").getElementsByTagName("move"):
         d.level.append((int(level.getAttribute("level")), data.get_node_text(level)))
     d.tm = []
     d.hm = []
     for tm in g(t, "tm").split("|"):
         d.tm.append(int(tm))
     for hm in g(t, "hm").split("|"):
         d.hm.append(int(hm))
예제 #5
0
				text_color=(255-color[0],255-color[1],255-color[2])
				if len(yp[i])==1:
					#add text here
					myfont=pygame.font.SysFont("Comic Sans MS", 20)
					label=myfont.render(curr_node.children[i].name, 1, text_color)
					window.blit(label, (xp[i]*xwidth,0))
				for j in range(len(yp[i])-1):
					color=(curr_node.children[i]).children[j].color
					pygame.draw.rect(window,color,(xp[i]*xwidth,yp[i][j]*ywidth,(xp[i+1]-xp[i])*xwidth,(yp[i][j+1]-yp[i][j])*ywidth))
					#add text here
					text_color=(255-color[0],255-color[1],255-color[2])
					myfont=pygame.font.SysFont("Comic Sans MS", 20)
					label=myfont.render(curr_node.children[i].children[j].name, 1, text_color)
					window.blit(label, (xp[i]*xwidth,yp[i][j]*ywidth))
		flag=0
		pygame.display.update()
	for event in pygame.event.get(): 
		if event.type==MOUSEBUTTONDOWN and event.button==1:
			mousex,mousey=pygame.mouse.get_pos()
			chld=data.get_node(mousex,xp,xwidth)
			if len(curr_node.children)!=0:
				flag=1
				stack.append(curr_node)
				curr_node=curr_node.children[chld]
		elif event.type==MOUSEBUTTONDOWN and event.button==3:
			if len(stack)!=0:
				curr_node=stack.pop()
				flag=1
		elif event.type==pygame.QUIT:
			sys.exit(0)