1. mcc
  2. evo

Commits

mcc  committed 2fb20ac

Multiple tanks

  • Participants
  • Parent commits 68ccec9
  • Branches default

Comments (0)

Files changed (2)

File media/overlay/play/onLoad.lua

View file
  • Ignore whitespace
 		local safeline = top and 22 or 0
 		gm.won = true
 		fill(dos, 0,safeline,40,2,"#")
-		dos:set_centered(0,safeline,40,   "SUCCESS!#YOU#ARE#A#SUPER#PLAYER", false)
+		dos:set_centered(0,safeline,40,   "YOU#ARE#CONGRATULATIONS!!!", false)
 		dos:set_centered(0,safeline+1,40, "PRESS#\010#TO#CONTINUE", false)
 	else
 		local safeline = top and 21 or 0

File server/server.py

View file
  • Ignore whitespace
 
 define("port", default=8888, help="run on the given port", type=int)
 define("history", default='history.log', help="history log filename", type=str)
+define("database", default='database.db', help="database filename", type=str)
+define("tanks", default=5, help="number of tanks", type=int)
 define("debug", default=0, help="debug runlevel", type=int)
 define("debug_delay", default=0, help="debug: fake response delay", type=float)
 define("debug_failure", default=0, help="debug: fake request failure", type=int)
 		return r
 	
 class Spec:
-	def __init__(self):
+	def __init__(self, gid, sid):
+		self.gid = gid
+		self.sid = sid
 		self.board = Board()
+		
+	def xml(self, doc, r):
+		r.setAttribute("gid", str(self.gid))
+		r.setAttribute("sid", str(self.sid))
+		self.board.xml(doc,r)
 	
 class Genome:
-	pass
+	def __init__(self, id):
+		self.id = id
+		self.specs = [Spec(id, 0)]
+	def any(self):
+		return self.specs[0]
 
 class Manager:
 	def __init__(self):
-		self.only = Board()
+		self.tanks = []
+		for i in range(options.tanks):
+			print("Generating tank %d" % i)
+			self.tanks.append(Genome(i))
 	
 	def any(self):
-		return self.only
+		return self.tanks[randint(0,len(self.tanks)-1)]
 
 m = Manager()
 
 class LevelHandler(LuaHandler):
 	def result(self, doc, post_obj):
 		r = doc.createElement("level")
-		m.any().xml(doc, r)
+		m.any().any().xml(doc, r)
 		return r
 
 class UnUpdateHandler(tornado.web.RequestHandler):
 		global history_file
 		print("Logging to %s" % (options.history))
 		history_file = open(options.history, AIR)
+	if options.database:
+		global database
+		print("Will save to %s" % (options.database))
 	application = tornado.web.Application([
 		(r"/", MainHandler),
 		(r"/welcome", WelcomeHandler),