def startgame(request, num): context = RequestContext(request, {}) session_id = request.session._get_or_create_session_key() game = create_and_start_game(int(num)) data = game.get_game_state() store_game(session_id, game) response = render_to_response('asg/game.html', {'sid':session_id, 'data': data }, context) response.set_cookie('gid',session_id) return response
def startgame(request, num): context = RequestContext(request, {}) session_id = request.session._get_or_create_session_key() game = create_and_start_game(int(num)) global gameId gameId = int(num) global access_limit access_limit = 10 nextTreasureNo = 10 - access_limit data = game.get_game_state() store_game(session_id, game) # gems coating here gain_list = [] round = game.current_round for i in range(len(round)): r = round[i] gain_list.append(str(r['gain'])) global treasure_display_list treasure_display_list = [] global current_display_list current_display_list = gems_coating(gameId, gain_list) global access_display_list access_display_list = current_display_list rounds_list = data['round'] zipped_data = zip(current_display_list, rounds_list) log_move_event(request.user.id, game, current_display_list, True, False) # ------------------------------------------ global noise noise = 3 response = render_to_response( 'asg/game.html', { 'sid': session_id, 'data': data, 'zipped_data': zipped_data, 'gameId': gameId, 'next': nextTreasureNo, 'noise': noise }, context) response.set_cookie('gid', session_id) return response
def startgame(request, num): context = RequestContext(request, {}) session_id = request.session._get_or_create_session_key() game = create_and_start_game(int(num)) global gameId gameId = int(num) global access_limit access_limit = 10 nextTreasureNo = 10 - access_limit data = game.get_game_state() store_game(session_id, game) # gems coating here gain_list = [] round = game.current_round for i in range(len(round)): r = round[i] gain_list.append(str(r['gain'])) global treasure_display_list treasure_display_list = [] global current_display_list current_display_list = gems_coating(gameId, gain_list) global access_display_list access_display_list = current_display_list rounds_list = data['round'] zipped_data = zip(current_display_list, rounds_list) log_move_event(request.user.id, game, current_display_list, True, False) # ------------------------------------------ global noise noise = 3 response = render_to_response('asg/game.html', {'sid': session_id, 'data': data, 'zipped_data': zipped_data, 'gameId': gameId, 'next': nextTreasureNo, 'noise': noise}, context) response.set_cookie('gid', session_id) return response
def query(request): context = RequestContext(request, {}) gid = '' data = {} if request.COOKIES.has_key('gid'): gid = request.COOKIES['gid'] game = retrieve_game(gid) if game: game.issue_query() store_game(gid, game) data = game.get_game_state() new_high = False if game.is_game_over(): # check if this is a high score # update userprofile stats new_high = end_game(request.user, game) return render_to_response('asg/game.html', {'sid':gid, 'data': data, 'new_high':new_high}, context)
def endGame(request): context = RequestContext(request, {}) gid = '' star_info = [0, 0, 0] star_thisGame = 0 data = {} global access_limit access_limit = 10 nextTreasureNo = 10 - access_limit if request.COOKIES.has_key('gid'): gid = request.COOKIES['gid'] game = retrieve_game(gid) if game: # # check if query success or not # if query_msg == True: # log_move_event(request.user.id, game, False, False) # gems coating here gain_list = [] round = game.current_round for i in range(len(round)): r = round[i] gain_list.append(str(r['gain'])) global treasure_display_list treasure_display_list = [] # global current_display_list # current_display_list = gems_coating(gameId, gain_list) log_move_event(request.user.id, game, current_display_list, False, True) store_game(gid, game) data = game.get_game_state() data['gameover'] = True rounds_list = data['round'] zipped_data = zip(current_display_list, rounds_list) if game.id != 6: star_info = star_game(game.id) star_thisGame = star_calculate(data['points'], unlockScore[game.id]) new_high = False # check if this is a high score # update userprofile stats log_move_event(request.user.id, game, current_display_list, False, True) new_high = end_game(request.user, game) global noise noise = 4 if game.id == 6: return render_to_response( 'asg/game.html', { 'sid': gid, 'data': data, 'zipped_data': zipped_data, 'new_high': new_high, 'gameId': gameId, 'next': nextTreasureNo, 'noise': noise }, context) return render_to_response( 'asg/game.html', { 'sid': gid, 'data': data, 'zipped_data': zipped_data, 'new_high': new_high, 'gameId': gameId, 'starInfo': star_info, 'star': star_thisGame, 'next': nextTreasureNo, 'noise': noise }, context)
def assess(request): context = RequestContext(request, {}) gid = '' star_info = [0, 0, 0] star_thisGame = 0 if request.COOKIES.has_key('gid'): gid = request.COOKIES['gid'] data = {} access_msg = True game = retrieve_game(gid) if game: global access_limit if access_limit > 0: game.examine_document() access_limit -= 1 else: access_msg = False nextTreasureNo = 10 - access_limit store_game(gid, game) data = game.get_game_state() rounds_list = data['round'] zipped_data = zip(access_display_list, rounds_list) # ----------------------------------------- if game.id != 6: star_info = star_game(game.id) star_thisGame = star_calculate(data['points'], unlockScore[game.id]) global noise noise = 1 new_high = False if game.is_game_over(): # check if this is a high score # update userprofile stats log_move_event(request.user.id, game, current_display_list, False, True) new_high = end_game(request.user, game) global noise noise = 4 if game.id == 6: return render_to_response( 'asg/game.html', { 'sid': gid, 'data': data, 'zipped_data': zipped_data, 'gameId': gameId, 'new_high': new_high, 'access_msg': access_msg, 'gameId': gameId, 'next': nextTreasureNo, 'noise': noise }, context) if data['tokens'] == 1 and access_msg == False: special_msg = True return render_to_response( 'asg/game.html', { 'sid': gid, 'data': data, 'zipped_data': zipped_data, 'gameId': gameId, 'new_high': new_high, 'special_msg': special_msg, 'gameId': gameId, 'next': nextTreasureNo, 'noise': noise }, context) return render_to_response( 'asg/game.html', { 'sid': gid, 'data': data, 'zipped_data': zipped_data, 'new_high': new_high, 'access_msg': access_msg, 'gameId': gameId, 'starInfo': star_info, 'star': star_thisGame, 'next': nextTreasureNo, 'noise': noise }, context)
def endGame(request): context = RequestContext(request, {}) gid = '' star_info = [0, 0, 0] star_thisGame = 0 data = {} global access_limit access_limit = 10 nextTreasureNo = 10 - access_limit if request.COOKIES.has_key('gid'): gid = request.COOKIES['gid'] game = retrieve_game(gid) if game: # # check if query success or not # if query_msg == True: # log_move_event(request.user.id, game, False, False) # gems coating here gain_list = [] round = game.current_round for i in range(len(round)): r = round[i] gain_list.append(str(r['gain'])) global treasure_display_list treasure_display_list = [] # global current_display_list # current_display_list = gems_coating(gameId, gain_list) log_move_event(request.user.id, game, current_display_list, False, True) store_game(gid, game) data = game.get_game_state() data['gameover'] = True rounds_list = data['round'] zipped_data = zip(current_display_list, rounds_list) if game.id != 6: star_info = star_game(game.id) star_thisGame = star_calculate(data['points'], unlockScore[game.id]) new_high = False # check if this is a high score # update userprofile stats log_move_event(request.user.id, game, current_display_list, False, True) new_high = end_game(request.user, game) global noise noise = 4 if game.id == 6: return render_to_response('asg/game.html', {'sid': gid, 'data': data, 'zipped_data': zipped_data, 'new_high': new_high, 'gameId': gameId, 'next': nextTreasureNo, 'noise': noise}, context) return render_to_response('asg/game.html', {'sid': gid, 'data': data, 'zipped_data': zipped_data, 'new_high': new_high, 'gameId': gameId, 'starInfo': star_info, 'star': star_thisGame, 'next': nextTreasureNo, 'noise': noise}, context)
def assess(request): context = RequestContext(request, {}) gid = '' star_info = [0, 0, 0] star_thisGame = 0 if request.COOKIES.has_key('gid'): gid = request.COOKIES['gid'] data = {} access_msg = True game = retrieve_game(gid) if game: global access_limit if access_limit > 0: game.examine_document() access_limit -= 1 else: access_msg = False nextTreasureNo = 10 - access_limit store_game(gid, game) data = game.get_game_state() rounds_list = data['round'] zipped_data = zip(access_display_list, rounds_list) # ----------------------------------------- if game.id != 6: star_info = star_game(game.id) star_thisGame = star_calculate(data['points'], unlockScore[game.id]) global noise noise = 1 new_high = False if game.is_game_over(): # check if this is a high score # update userprofile stats log_move_event(request.user.id, game, current_display_list, False, True) new_high = end_game(request.user, game) global noise noise = 4 if game.id == 6: return render_to_response('asg/game.html', {'sid': gid, 'data': data, 'zipped_data': zipped_data, 'gameId': gameId, 'new_high': new_high, 'access_msg': access_msg, 'gameId': gameId, 'next': nextTreasureNo, 'noise': noise}, context) if data['tokens'] == 1 and access_msg == False: special_msg = True return render_to_response('asg/game.html', {'sid': gid, 'data': data, 'zipped_data': zipped_data, 'gameId': gameId, 'new_high': new_high, 'special_msg': special_msg, 'gameId': gameId, 'next': nextTreasureNo, 'noise': noise}, context) return render_to_response('asg/game.html', {'sid': gid, 'data': data, 'zipped_data': zipped_data, 'new_high': new_high, 'access_msg': access_msg, 'gameId': gameId, 'starInfo': star_info, 'star': star_thisGame, 'next': nextTreasureNo, 'noise': noise}, context)