Esempio n. 1
0
	def pedir_pais_propio(self, tablero, mensaje):
		"""Recibe una cadena de texto y lo escribe en el titulo.
		Pide al jugador que seleccione un pais que sea suyo.
		Si clickea un pais suyo con click izquierdo, devuelve el pais.
		Si hace click derecho, devuelve None."""
		Interfaz.setear_titulo(mensaje)
		origen, boton = Interfaz.seleccionar_pais()
		while boton == Interfaz.BOTON_IZQUIERDO and tablero.color_pais(origen) != self.color:
			origen, boton = Interfaz.seleccionar_pais()
		if boton != Interfaz.BOTON_IZQUIERDO:
			return None
		return origen
Esempio n. 2
0
	def atacar(self, tablero):
		"""Le pide al usuario que ingrese un par de paises para
		realizar un ataque. Devuelve None si el jugador no quiere
		atacar y un par (atacante, atacado) en caso contrario."""
		while True:
			Interfaz.setear_titulo('%s ataca. Seleccionar atacante' % self)

			atacante, boton = Interfaz.seleccionar_pais()
			while boton == Interfaz.BOTON_IZQUIERDO and (tablero.color_pais(atacante) != self.color or tablero.ejercitos_pais(atacante) == 1):
				atacante, boton = Interfaz.seleccionar_pais()
			if boton != Interfaz.BOTON_IZQUIERDO:
				return None

			Interfaz.setear_titulo('%s ataca. Seleccionar pais atacado por %s' % (self, atacante))

			atacado, boton = Interfaz.seleccionar_pais()
			while boton == Interfaz.BOTON_IZQUIERDO and (tablero.color_pais(atacado) == self.color or not tablero.es_limitrofe(atacante, atacado)):
				atacado, boton = Interfaz.seleccionar_pais()
			if boton != Interfaz.BOTON_IZQUIERDO:
				continue
			return (atacante, atacado)