Пример #1
0
	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 drawSystemMap(player, civilization, system):
	player = dbfunctions.getCurrentPlayer()
	planet_list = player.getCivilization().getPlanetList(system)
	planet_list_xys = []
	for planet in planet_list:
		x = planet.x
		y = planet.y
		planet_list_xys.append((x, y))
	
	navmap = '<div id="navmap">'
	for y in range(0,10):
		navmap += '<div class="navmap_row">'
		for x in range(0,10):
			if system.planet_matrix[getListNumFromXY(x, y, dim=10)] == 1:
				planet = system.getPlanetWithXY(x, y)
				planet_image_file = '/static/images/' + planet.planet_type + '_small.jpg'
				if (x, y) in planet_list_xys:
					planet_text = '*'
				else:
					planet_text = ''
				navmap += '<div class="system_map_square" style="background:url(%s) no-repeat; background-position:center center;" onclick="processPlanetDashboard(\'%s\', \'%s\', \'%s\')">%s</div>' % (planet_image_file, system.key(), x, y, planet_text)
			else:
				navmap = navmap + '<div class="system_map_square" id="'+str(x)+'-'+str(y)+'"></div>'
		navmap = navmap + '</div>' # end navmap_row
	navmap += '</div>' #end navmap
	return navmap
Пример #3
0
	def addPlanetBookmark(self):
		try:
			planet_key = self.request.get('planet_key')
			player = dbfunctions.getCurrentPlayer()
			civilization = player.getCivilization()
			civilization.addBookmark(planet_key)
			
			return dashboard.buildBottombar(player, civilization)
		except Exception, e:
			import traceback
			traceback.print_exc()
			
			return '<p>Crud.... That didn\'t go quite as I had planned.</p>'
Пример #4
0
def drawSectorMap(player, civilization, sector):
	player = dbfunctions.getCurrentPlayer()
	system_list = player.getCivilization().getSystemList(sector)
	system_list_xys = []
	for system in system_list:
		x = system.x
		y = system.y
		system_list_xys.append((x, y))
	
	navmap = '<div id="navmap">'
	for y in range(0,20):
		navmap += '<div class="navmap_row">'
		for x in range(0,20):
			if sector.system_matrix[getListNumFromXY(x, y)] == 1:
				if (x, y) in system_list_xys:
					image_file = '/static/images/star_special.jpg'
				else:
					image_file = '/static/images/star.jpg'
				navmap += '<div class="map_square" style="background:url(%s) no-repeat; background-position:center center;" onclick="processSystemDashboard(\'%s\', \'%s\', \'%s\')"></div>' % (image_file, sector.key(), x, y)
			else:
				navmap = navmap + '<div class="map_square" id="'+str(x)+'-'+str(y)+'"></div>'
		navmap = navmap + '</div>' # end navmap_row
	navmap += '</div>' #end navmap
	return navmap
Пример #5
0
	def post(self):
		user = users.get_current_user()
		if not user:
			self.redirect("/")
		
		player = dbfunctions.getCurrentPlayer()
		civilization = player.getCivilization()
		return_stuff = ''
		
		if self.request.get('new_planet_name') is not '':
			return_stuff = self.changePlanetName()
		
		if self.request.get('planet_key') != '' and self.request.get('bookmark') == '1':
			return_stuff = self.addPlanetBookmark()
			
		if self.request.get('planet_key') != '' and self.request.get('bookmark') == '0':
			return_stuff = self.removePlanetBookmark()
				
		if self.request.get('player_stream') == 'update':
			return_stuff = self.updateStream(player)
			
		if self.request.get('planet_dashboard') == 'update': 
			return_stuff = self.updatePlanetDashboard(player, civilization, self.request.get('system_key'), self.request.get('x'), self.request.get('y'))
		
		if self.request.get('system_dashboard') == 'update': 
			return_stuff = self.updateSystemDashboard(player, civilization, self.request.get('sector_key'), self.request.get('x'), self.request.get('y'))
		
		if self.request.get('sector_dashboard') == 'update': 
			return_stuff = self.updateSectorDashboard(player, civilization, self.request.get('galaxy_key'), self.request.get('x'), self.request.get('y'))
		
		if self.request.get('galaxy_dashboard') == 'update': 
			return_stuff = self.updateGalaxyDashboard(player, civilization, self.request.get('universe_key'), self.request.get('x'), self.request.get('y'))
	
		if self.request.get('chat_text') != '':
			return_stuff = self.processChatText(player, civilization, self.request.get('chat_text'))
			
		if self.request.get('bottombar') == 'update':
			return_stuff = self.refreshBottombar(player, civilization)
			
		if self.request.get('turn') == 'go':
			return_stuff = self.goTurn(player, civilization)
			
		if self.request.get('dashboard') == 'update':
			return_stuff = self.updateDashboard(player, civilization)
			
		if self.request.get('sidebar') == 'update':
			return_stuff = self.refreshSidebar(player, civilization);
	
		if self.request.get('hivesoutposts') == 'update':
			return_stuff = self.updateHivesOutposts(player, civilization, self.request.get('hiveoutpost_key'))
			
		if self.request.get('modules') == 'update':
			return_stuff = self.updateModules(player, civilization, self.request.get('hiveoutpost_key'))

		if self.request.get('build_module') == 'dialog':
			return_stuff = self.buildModuleDialog(self.request.get('hiveoutpost_key'), self.request.get('module_type_name'))
			
		if self.request.get('build_module') == 'go':
			return_stuff = self.buildModule(player, civilization, self.request.get('hiveoutpost_key'), self.request.get('module_type_name'))
		
		if self.request.get('module_build_queue') == 'update':
			return_stuff = self.updateModuleBuildQueue(self.request.get('hiveoutpost_key'))
		
		if self.request.get('current_modules') == 'update':
			return_stuff = self.updateCurrentModules(self.request.get('hiveoutpost_key'))
	
		if self.request.get('civilization_age') == 'update':
			return_stuff = self.updateCivilizationAge(civilization)
	
		if self.request.get('transfer_workers') == 'update':
			return_stuff = self.transferWorkers()
		
		if self.request.get('transfer_workers_dialog') == 'update':
			return_stuff = self.updateTransferWorkersDialog(self.request.get('hiveoutpost_key'))
		
		if self.request.get('go_turn') == 'update':
			return_stuff = self.goTurn(player, civilization)
			
		template_values = {
			'return_stuff': return_stuff
		}

		path = os.path.join(os.path.dirname(__file__), 'process-utilities.html')
		self.response.out.write(template.render(path, template_values))