Пример #1
0
def init_puzzle_match(request, puzzle):

    deck = puzzle.player_cards 

    if request.user.is_authenticated():
        player = request.user
    else:
        player = None

    match = Match(type="puzzle",
            player=player,
            puzzle=puzzle,
            goal=puzzle.goal,
            session_key=request.session.session_key,
            friendly_deck_cards=puzzle.player_cards.card_ids,
            ai_deck_cards=[],
            ai_life=puzzle.ai_life,
            friendly_life=puzzle.player_life)
    match.save()

    return match 
Пример #2
0
def init_match(request):

    deck = get_deck_from(request)

    ai_deck = deckgenerator.create_deck(40)

    if request.user.is_authenticated():
        player = request.user
    else:
        player = None

    match = Match(friendly_deck_cards=deck.card_ids,
            ai_deck_cards=ai_deck.card_ids,
            player=player,
            type="ai")
    match.save()
    logging.info("QQQ init_match() %s" % match.id)
    import traceback

    # boo = match['error_plz']

    return match