Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Variables.py
diff options
context:
space:
mode:
Diffstat (limited to 'Variables.py')
-rw-r--r--Variables.py84
1 files changed, 84 insertions, 0 deletions
diff --git a/Variables.py b/Variables.py
new file mode 100644
index 0000000..7858e6f
--- /dev/null
+++ b/Variables.py
@@ -0,0 +1,84 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Variables.py por:
+# Flavio Danesse <fdanesse@gmail.com>
+# CeibalJAM! - Uruguay - Plan Ceibal
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+TERMINATOR = "\r\n\r\n"
+Tanques={}
+CARGA = 0
+
+class Tanque():
+ def __init__(self, nombre):
+
+ # Datos del Tanque
+ self.nombre = nombre
+ self.angulo, self.x, self.y = 0, 0, 0
+ self.ultimo_angulo, self.ultima_x, self.ultima_y = 0, 0, 0
+
+ # persistencia balas
+ self.jugadores_por_informar_disparo = None
+ self.bala = None
+
+ # persistencia puntos y energía
+ self.puntos = None
+ self.jugadores_por_informar_puntaje = None
+
+ # Cuando un jugador se desconecta, se debe avisar a todos
+ self.desconectados = ""
+
+# ---------------- inicio DATOS POSICION TANQUE ---------------------------
+ def get_datos_tanque(self):
+ # devuelve los datos de posición del tanque. (Se llama desde enviar_datos() en class UDPServer_thread)
+ self.angulo, self.x, self.y = self.ultimo_angulo, self.ultima_x, self.ultima_y
+ mensaje_posicion = "%s %s %s %s %s%s" % (self.nombre, "T", self.angulo, self.x, self.y, TERMINATOR)
+ return mensaje_posicion
+
+ def set_datos_tanque(self, nombre=None, angulo=0, x=0, y=0):
+ # guarda los datos de posición del tanque. (Se llama desde recibir_datos() en class UDPServer_thread)
+ self.ultimo_angulo, self.ultima_x, self.ultima_y = int(angulo), int(x), int(y)
+# ---------------- fin DATOS POSICION TANQUE ------------------------------
+
+ def set_puntos(self, energia=100, puntaje=0):
+ # establece los datos iniciales de la bala
+ self.puntos = "%s %s %s %s%s" % (self.nombre, "D", energia, puntaje, TERMINATOR)
+ #print "Nuevo puntaje en Espejo: ", self.puntos
+
+ def get_puntos(self):
+ # devuelve los datos de la bala
+ return self.puntos
+
+ def set_jugadores_por_informar_puntaje(self, jugadores_por_informar_puntaje):
+ # Lista de jugadores a los que hay que informar sobre un disparo
+ self.jugadores_por_informar_puntaje = jugadores_por_informar_puntaje
+
+# ---------------- inicio DATOS BALAS -------------------------------------
+ def set_bala(self, angulo=0, x=0, y=0):
+ # establece los datos iniciales de la bala
+ self.bala = "%s %s %s %s %s%s" % (self.nombre, "B", angulo, x, y, TERMINATOR)
+
+ def get_bala(self):
+ # devuelve los datos de la bala
+ return self.bala
+
+ def set_jugadores_por_informar_disparo(self, jugadores_por_informar_disparo):
+ # Lista de jugadores a los que hay que informar sobre un disparo
+ self.jugadores_por_informar_disparo = jugadores_por_informar_disparo
+
+# ---------------- FIN DATOS BALAS -------------------------------------
+