def game(request): """Game Page.""" if request.method == 'POST': try: lang = request.POST['selCombo'] team1 = request.POST['first_team'] team2 = request.POST['second_team'] players = int(request.POST['players']) rounds = int(request.POST['rounds']) if not team1 or not team2 or players < 2 or rounds < 1: raise Exception() cards = list(models.get_cards(lang)) random.shuffle(cards) data = {"team1": team1, "team2": team2, "players": players, "rounds": rounds, "cards": cards} return render_response(request, 'tabu/game_page.html', data) except: langs = models.get_languages() data = {"langs": langs, 'error': "Missing or Invalid data."} return render_response(request, 'tabu/setup_page.html', data) else: langs = models.get_languages() data = {"langs": langs} return render_response(request, 'tabu/setup_page.html', data)
def game(request): """Game Page.""" if request.method == 'POST': try: lang = request.POST['selCombo'] team1 = request.POST['first_team'] team2 = request.POST['second_team'] players = int(request.POST['players']) rounds = int(request.POST['rounds']) if not team1 or not team2 or players < 2 or rounds < 1: raise Exception() cards = list(models.get_cards(lang)) random.shuffle(cards) data = { "team1": team1, "team2": team2, "players": players, "rounds": rounds, "cards": cards } return render_response(request, 'tabu/game_page.html', data) except: langs = models.get_languages() data = {"langs": langs, 'error': "Missing or Invalid data."} return render_response(request, 'tabu/setup_page.html', data) else: langs = models.get_languages() data = {"langs": langs} return render_response(request, 'tabu/setup_page.html', data)
def get_cards(request): cards = list(models.get_cards(request.GET['language'])) random.shuffle(cards) data = simplejson.dumps(cards) return HttpResponse(data, mimetype='application/json')