Exemplo n.º 1
0
	def load_from_xml(self, node):
		PlanetBase.load_from_xml(self, node)
		self.geo = map_tuple(('o','e','m','t','s'), get_attrs(node, 'o','e','m','t','s'))
		self.owner_id = get_attr(node, 'owner-id')
		self.age = get_attr(node, 'age')
		self.turn = get_attr(node, 'turn')
		self.is_open = get_attr(node, 'open', bool)
Exemplo n.º 2
0
	def load_user_info(self, general_info):
		'load race and basic player info, and id'
		player = general_info.getElementsByTagName('this-player')[0]
		self.id = get_attr(player, 'player-id')
		self.race_id = get_attr(player, 'race-id')
		self.name = get_attr(player, 'player-name', unicode)
		self.login = get_attr(player, 'login', unicode)
		self.hw_pos = get_attrs(player, 'homeworldx','homeworldy')
		
		self.race = race.Race(general_info.getElementsByTagName('this-player-race')[0])
Exemplo n.º 3
0
	def load_from_xml(self, node):
		self.id = get_attr(node, 'fleet-id')
		self.weight = get_attr(node, 'sum-weight')
		self.owner_id = get_attr(node, 'player-id')
		self.tta = get_attr(node, 'turns-till-arrival')
		if self.tta > 0:
			self.flying = True
		FleetBase.load_from_xml(self, node)

		for unit_node in node.getElementsByTagName('allien-ship'):
			self.units.append( unit.AlienUnit(unit_node) )
Exemplo n.º 4
0
	def load_from_xml(self, node):
		self.id = get_attr(node, 'id')
		self.tta = get_attr(node, 'tta')
		if self.tta > 0:
			self.flying = True		
		
		# load some flight specific info
		FleetBase.load_from_xml(self, node)
		
		for unit_node in node.getElementsByTagName('u'):
			u = unit.Unit(unit_node)
			u.fleet_id = self.id
			u.fleet = self
			self.units.append( u )
Exemplo n.º 5
0
	def load_from_file(self, file):
		xmldoc = minidom.parse(file)
		node = xmldoc.firstChild
		self.id = get_attr(node, 'id')
		
		if self.load_errors(node.getElementsByTagName("errors")):
			return
		
		main = node.getElementsByTagName("iframe")[0]
		
		gen_info = main.getElementsByTagName('general-info')
		if gen_info:
			#print 'loading user info from %s'%(file,)
			self.load_user_info(gen_info[0])
			#load them first, to be able to assign protopes to garrison and fleet units
			self.load_prototypes(main.getElementsByTagName('building-types')[0])
			self.load_planets(main.getElementsByTagName('user-planets')[0])
			self.load_garrisons(main.getElementsByTagName('harrisons')[0])
			self.load_fleets(main.getElementsByTagName('fleets')[0])
			self.load_alien_fleets(main.getElementsByTagName('allien-fleets')[0])
			self.load_known_players(main.getElementsByTagName('diplomacy')[0])
			return
			
		known_planets_node = main.getElementsByTagName('known-planets')
		if known_planets_node:
			#print 'loading known planets from %s'%(file,)
			for planet_node in known_planets_node[0].getElementsByTagName('planet'):
				pl = planet.KnownPlanet(planet_node)
				self.known_planets[ pl.pos ] = pl
			return
		
		log.error('nothing to load from %s'%(file,))
Exemplo n.º 6
0
	def load_from_xml(self, node):
		self.id = get_attr(node, 'race-id')
		self.t_opt = get_attr(node, 't-optimal', float)
		self.t_delta = get_attr(node, 't-delta', float)
		self.nature = get_attr(node, 'race-nature', str)
		self.main = get_attr(node, 'industry-nature', str)
		self.second = get_attr(node, 'unused-resource', str)
		self.name = get_attr(node, 'race-name', unicode)
Exemplo n.º 7
0
	def load_from_xml(self, node):
		self.name = get_attr(node, 'name', unicode)
		self.pos = get_attrs(node, 'x','y')
		# don't really need this
		#self.flying = get_attr(node, 'in-transit', bool)
		
		if self.flying:
			self.from_pos = get_attrs(node,'from-x', 'from-y')
			if not self.from_pos:
				log.error('unable to get start pos for flying fleet %s - %s, %s'%(self.pos, self.name))
Exemplo n.º 8
0
	def load_from_xml(self, node):
		self.laser_damange = get_attr(node, 'laser-damage', float)
		self.laser_aim = get_attr(node, 'laser-ar', float)
		self.laser_count = get_attr(node, 'laser-number')
		
		self.bomb_damange = get_attr(node, 'bomb-damage', float)
		self.bomb_aim = get_attr(node, 'bomb-ar', float)
		self.bomb_count = get_attr(node, 'bomb-number')
Exemplo n.º 9
0
	def load_errors(self, err):
		if not err:
			return False
		hasAny = False
		for e in err[0].getElementsByTagName("error"):
			txt = ''
			if e.firstChild:
				txt = e.firstChild.data
			id = get_attr(e, 'id')
			
			#str = 'error %s %s'%(id, txt)
			#if 'user' in e.attributes.keys():
			#	str = '%s %s'%(node.attributes['user'].value,str)
				
			log.error('Error %d: %s'%(id, txt))
			#wx.PostEvent(self.callback, Report(attr1=False, attr2=str))
			hasAny = True
		return hasAny
Exemplo n.º 10
0
	def load_from_xml(self, node):
		self.main = get_attr(node, 'cost-main', float)
		self.second = get_attr(node, 'cost-second', float)
		self.money = get_attr(node, 'cost-money', float)
		self.people = get_attr(node, 'cost-pepl')
Exemplo n.º 11
0
	def load_from_xml(self, node):
		self.name = get_attr(node, 'name', unicode)
		self.pos = get_attrs(node, 'x','y')
Exemplo n.º 12
0
	def load_from_xml(self, node):
		self.transport_capacity = get_attr(node, 'transport-capacity')
		self.fly_range = get_attr(node, 'fly-range', float)
		self.fly_speed = get_attr(node, 'fly-speed', float)
		self.carrier_capacity = get_attr(node, 'carrier-capacity')
Exemplo n.º 13
0
	def load_from_xml(self, node):
		self.stealth_level = get_attr(node, 'stealth-lvl', float)
		self.scan_strength = get_attr(node, 'scan-strength', float)
		self.detect_range = get_attr(node, 'detect-range', float)
Exemplo n.º 14
0
	def load_from_xml(self, node):
		self.id = get_attr(node, 'building-id')
		self.building_class = get_attr(node, 'class')
		self.carapace = get_attr(node, 'carapace')
		self.serial = get_attr(node, 'serial')
		self.color = get_attr(node, 'color')
		
		self.name = get_attr(node, 'name', unicode)
		self.description = get_attr(node, 'description', unicode)
		
		self.is_war = get_attr(node, 'is-war', bool)
		self.is_transportable = get_attr(node, 'is-transportable', bool)
		self.is_ground = get_attr(node, 'is-ground-unit', bool)
		self.is_offensive = get_attr(node, 'offensive', bool)
		self.is_building = get_attr(node, 'is-building', bool)
		self.is_space_ship = get_attr(node, 'is-space-ship', bool)
		
		self.hp = get_attr(node, 'hit-points')
		self.requires_people = get_attr(node, 'requires-pepl')
		
		self.support_main = get_attr(node, 'support-main', float)
		self.support_second = get_attr(node, 'support-second', float)
		
		self.damage_resistance_bomb = get_attr(node, 'bomb-dr', float)
		self.damage_resistance_laser = get_attr(node, 'laser-dr', float)
		
		self.fly = FlyAttr(node)
		self.bonus = BonusAttr(node)
		self.build = BuildAttr(node)
		self.price =  PriceAttr(node)
		self.stealth = StealthAttr(node)
		
		actions = node.getElementsByTagName('actions')
		if actions:
			for action_node in actions[0].getElementsByTagName('act'):
				action = UnitAction(action_node)
				#print 'loading actin %d of bc %d'%(action.id, self.id)
				self.actions[action.id] = action
Exemplo n.º 15
0
	def load_from_xml(self, node):
		self.carapace = get_attr(node, 'carapace')
		self.bc = get_attr(node, 'class-id')
		self.id = get_attr(node, 'id')
		self.weight = get_attr(node, 'weight')
		self.color = get_attr(node, 'color')
Exemplo n.º 16
0
	def load_from_xml(self, node):
		PlanetBase.load_from_xml(self, node)
		self.geo = map_tuple(('o','e','m','t','s') , get_attrs(node, 'o','e','m','temperature','surface'))		
		self.corruption = get_attr(node, 'corruption')
		self.population = get_attr(node, 'population')
		self.is_open = 0==get_attr(node, 'hidden')
Exemplo n.º 17
0
	def load_from_xml(self, node):
		self.o = get_attr(node, 'bonus-o')
		self.e = get_attr(node, 'bonus-e')
		self.m = get_attr(node, 'bonus-m')
		self.surface = get_attr(node, 'bonus-surface')
		self.production = get_attr(node, 'bonus-production')
Exemplo n.º 18
0
	def load_from_xml(self, node):
		self.id = get_attr(node, 'player')
		self.name = get_attr(node, 'name', unicode)
		self.dip_status = get_attr(node, 'type')
Exemplo n.º 19
0
	def load_from_xml(self, node):
		self.hp = get_attr(node, 'hp')
		self.bc = get_attr(node, 'bc')
		self.id = get_attr(node, 'id')
Exemplo n.º 20
0
	def load_from_xml(self, node):
		self.max_count = get_attr(node, 'maxcount')
		self.require_tech_level = get_attr(node, 'req-tehn-level')
		self.build_speed = get_attr(node, 'build-speed')
Exemplo n.º 21
0
	def load_from_xml(self, node):
		self.done = get_attr(node, 'done')
		self.order = get_attr(node, 'inproc-order')
		self.unit = Unit(node)
Exemplo n.º 22
0
	def load_from_xml(self, node):
		self.id = get_attr(node, 'action')
		self.max_count = get_attr(node, 'maxcount')
		self.price = PriceAttr(node)
		self.possible_planet = get_attr(node, 'planet-can-be', str)