def select_color(request): data = parse_body_json_or_400(request, required_keys=["room", "color"]) room = Room.get_for_encoded_uuid_or_404(data["room"]) player = _get_session_player(request.session, room) color = Color.for_name(data["color"]) color_event = player.update_color(color) publish_color_event(color_event) return HttpResponse("Received data: ", str(data))
def goal_selected(request): data = parse_body_json_or_400(request, required_keys=["room", "slot", "color", "remove_color"]) room = Room.get_for_encoded_uuid_or_404(data["room"]) player = _get_session_player(request.session, room) game = room.current_game slot = int(data["slot"]) color = Color.for_name(data["color"]) remove_color = data["remove_color"] goal_event = game.update_goal(player, slot, color, remove_color) if not goal_event: return HttpResponseBadRequest("Blocked by Lockout") publish_goal_event(goal_event) return HttpResponse("Recieved data: " + str(data))