예제 #1
0
파일: game.py 프로젝트: rscottfree/oktober5
	def get(self):      		        
		user = users.get_current_user()
		if not user:
			self.redirect("/")
			
		player = dbfunctions.getCurrentPlayer()
		game = dbfunctions.getGame()
		if game == None:
			self.redirect("/")

		civilization = dbfunctions.getCivilizationByPlayer(player)
		#navmap = helpers.drawNavMap(planet = planet)

		if civilization == None:
			civilization = helpers.startNewCivilization(player = player, game = game)
			planet = (db.get(civilization.hives[0])).planet
			game_dialogs = """<div id="newname_dialog" class="dialog" title="Name Your Home Planet">
				<form id="newname_form" action="/process-utilities" method="post"> 
					<label for="new_planet_name">Name</label>
					<input id="new_planet_name" maxlength="15" minlength="3" class="inputstuff required lettersonly" type="text" name="new_planet_name" /> 
					<input type="hidden" name="planet_key" value="%s" />
					<input id="submitButton" class="button" type="submit" value="Submit" /> 
				</form>
				</div>
				
				<script>
				$(document).ready(function() {
					$("#newname_dialog").dialog({ closeOnEscape: false, autoOpen: true, draggable: true, modal: true,  position: 'top', maxHeight: 515, maxWidth: 400, width: 400 });
				});
				</script>
			""" % planet.key()
		else:
			game_dialogs = ''
			planet = (db.get(civilization.hives[0])).planet
		
		import dashboard
		navmap, zoombar, sidebar, bottombar, dialogs = dashboard.draw(player, civilization, planet)
		
		import hivesoutposts
		hivesoutposts_tab = hivesoutposts.draw(player, civilization)
		
		import modules
		modules_tab = modules.draw(player, civilization)
		
		import fleets
		fleets_tab = fleets.draw(player, civilization)
		
		template_values = {
			'navmap': navmap,
			'sidebar': sidebar,
			'zoombar': zoombar,
			'bottombar': bottombar,
			'hivesoutposts': hivesoutposts_tab,
			'modules': modules_tab,
			'fleets': fleets_tab,
			'dialogs': game_dialogs
		      }

		path = os.path.join(os.path.dirname(__file__), 'game.html')
		self.response.out.write(template.render(path, template_values))
예제 #2
0
	def updateModules(self, player, civilization, hiveoutpost_key = None):
		if hiveoutpost_key == '':
			return modules.draw(player, civilization)
		else:
			hiveoutpost = db.get(hiveoutpost_key)
			return modules.draw(player, civilization, hiveoutpost)