def get(self): user = users.get_current_user() if not user: raise Exception("Anonymous not allowed") game = Game.get_by_key_name(user.user_id()) if not game: raise Exception("No game for user %s" % user.user_id()) s = scenario.get_scenario(game.scenario) self.response.out.write(json.dumps(s.starting_pieces()))
def post(self): user = users.get_current_user() if not user: self.redirect("/") else: game = Game.get_by_key_name(user.user_id()) if game: self.redirect("/play") else: scenario_name = self.request.get("scenario") historical = self.request.get("historical") game = Game( key_name=user.user_id(), player=user, scenario=scenario_name, historical=(historical == "on") ) s = scenario.get_scenario(scenario_name) s.setup(game) game.put() self.redirect("/play")
def new_game(): scenario = get_scenario() background = scenario.get_background() hud = HUD() game_layer = GameLayer(hud, scenario) return cocos.scene.Scene(background, game_layer, hud)
def new_game(): scenario = get_scenario() #從scenario.py取得所有腳本 background = scenario.get_background() #取得磚塊地圖圖層作為背景 hud = HUD() #HUD圖層,顯示分數、點數 game_layer = GameLayer(hud, scenario) return cocos.scene.Scene(background, game_layer, hud)