Exemple #1
0
	def build_IDs(self):
		tmp = {
			'self' : self,
			'opponent' : [x for x in select('> Mage', self.context) if not x is self][0]
		}
		tmp.update(self.IDs)
		return tmp
Exemple #2
0
Fichier : ui.py Projet : keis/game
	def select(self, q , c=None):
		from xselect import select
		if c is None:
			c = self.player.context

		tmp = self.player.build_IDs()
		
		return select(q, c, IDs = tmp)
Exemple #3
0
	def sacrifice(self, count, desc=None):
		pool = self.build_pool()
		if desc is not None:
			pool = select(desc, pool)

		if len(pool) < count:
			return False

		for x in pool[:count]:
			x.sacrifice()

		return True
Exemple #4
0
	def discard(self, count, desc=None):
		# TODO: Make it possible to choose which focusables to discard
		focused = self.focused
		if desc:
			focused = select(desc, focused)

		if len(focused) < count:
			return False

		for x in focused[:count]:
			x.discard()

		return True
Exemple #5
0
Fichier : act.py Projet : keis/game
def cast_spell(player, spell, targets):
	if spell not in player.focused:
		raise GameError("Spell not focused")

	tmp = {
		'self' : player,
		'opponent' : None
	}
	tmp.update(ids)

	for k,v in targets.items():
		try:
			help, dv = spell._desc[k]
		except KeyError:
			raise GameError("Unknown target name (%s)" % k)

		if v not in select(dv, context, IDs = tmp):
			raise GameError("Illegal target %s" % v)

	player.cast_spell(spell, targets)