コード例 #1
0
ファイル: building.py プロジェクト: keis/game
	def heal(self, source, amount):
		#source, amount = self.run_hook('pre-heal', source, amount)
		if source and amount:
			for x in self.units:
				if friendly(self, x):
					x.heal(source, amount)
		#	self.run_hook('post-heal', source, amount)
		return source, amount
コード例 #2
0
ファイル: act.py プロジェクト: keis/game
def move_creatures(player, creatures, building):
	""" Move all of @creatures to @building."""

	if any(getattr(c, 'owner', None) != player):
		raise IllegalMovement("Player does control all creatues")

	is_attack = not friendly(building, creatures[0])

	# To move to a opposing building a free pad is required
	if is_attack and not len(building.free_pads()) > 0:
		raise IllegalMovement("No free pads")

	# Should the entire movement be aborted if one creature fails its pre-move check?
	creatures = [x for x in creatures if x.run_hook('pre-move', building)[0]]
	creatures = filter(None, map(lambda x: x.position.remove_creature(x), creatures))
	creatures = filter(None, map(lambda x: building.add_creature(x), creatures))

	for x in creatures:
		x.position = building
コード例 #3
0
ファイル: building.py プロジェクト: keis/game
	def is_battle_zone(self):
		return any(not friendly(self, x) for x in self.units)
コード例 #4
0
ファイル: building.py プロジェクト: keis/game
	def get_attackers(self):
		attackers = [x for x in self.units if not friendly(self, x)]
		(attackers,) = self.run_hook('pre-attackers', attackers)
		self.run_hook('post-attackers', attackers)
		return attackers
コード例 #5
0
ファイル: building.py プロジェクト: keis/game
	def get_defenders(self):
		# Maybe allow some teleport dude to defend at all buildings..
		defenders = [x for x in self.units if friendly(self, x)]
		(defenders,) = self.run_hook('pre-defenders', defenders)
		self.run_hook('post-defenders', defenders)
		return defenders