コード例 #1
0
ファイル: views.py プロジェクト: clach04/tabu
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)
コード例 #2
0
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)
コード例 #3
0
ファイル: views.py プロジェクト: clach04/tabu
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')
コード例 #4
0
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')