Пример #1
0
    async def focus(self, ctx):
        """Reviews your deck and tells what the deck focus is"""
        me = CoachService.discord_user_to_coach(ctx.author)
        tourn = TournamentService.get_tournament_using_room(ctx.channel.name)
        deck = [ts.deck for ts in tourn.tournament_signups if ts.coach == me]
        if not deck:
            raise Exception(
                f"#{me.short_name()} is not signed into the tournament. Nice try!"
            )
        focus = DeckService.focus(deck[0])

        await ctx.send(f"Deck focus is {', '.join(focus)}")
Пример #2
0
def update_deck(deck_id):
    if current_user():
        deck = Deck.query.get(deck_id)
        if deck is None:
            abort(404)
        if locked(deck):
            raise InvalidUsage('Deck is locked!', status_code=403)

        coach = Coach.query.options(raiseload(Coach.cards),raiseload(Coach.packs)).filter_by(disc_id=current_user()['id']).one_or_none()
        if deck.tournament_signup.coach!=coach:
            raise InvalidUsage("Unauthorized access!", status_code=403)

        received_deck = request.get_json()['deck']
        deck = DeckService.update(deck,received_deck)
        result = deck_schema.dump(deck)
        return jsonify(result.data)
    else:
        raise InvalidUsage('You are not authenticated!', status_code=401)
Пример #3
0
def commit_deck(deck_id):
    if not current_user():
        raise InvalidUsage('You are not authenticated', status_code=401)
    
    deck = Deck.query.get(deck_id)
    if deck is None:
        abort(404)
    if locked(deck):
            raise InvalidUsage("Deck is locked!", status_code=403)

    coach = Coach.query.options(raiseload(Coach.cards),raiseload(Coach.packs)).filter_by(disc_id=current_user()['id']).one_or_none()
    if deck.tournament_signup.coach!=coach:
        raise InvalidUsage("Unauthorized access!!!!", status_code=403)

    try:
        deck = DeckService.commit(deck)
    except (DeckError) as e:
        raise InvalidUsage(str(e), status_code=403)

    result = deck_schema.dump(deck)
    return jsonify(result.data)
Пример #4
0
def addcard_deck(deck):
    """Adds cards to deck"""
    return DeckService.addcard(deck, request.get_json())
Пример #5
0
def reset_deck(deck):
    """Resets deck"""
    return DeckService.reset(deck)
Пример #6
0
def update_deck(deck):
    """Updates base deck info not cards"""
    return DeckService.update(deck, request.get_json()['deck'])
Пример #7
0
def removesquadcard_deck(deck):
    """Removes squad cards from deck high command"""
    return DeckService.removecard_from_squad(deck, request.get_json())
Пример #8
0
def commit_deck(deck):
    """Commits deck"""
    return DeckService.commit(deck)
Пример #9
0
def removecardextra_deck(deck):
    """Removes extra card from deck"""
    return DeckService.removeextracard(deck, request.get_json())
Пример #10
0
def removecard_deck(deck):
    """Removes cards from deck"""
    return DeckService.removecard(deck, request.get_json())
Пример #11
0
def addcardextra_to_player_deck(deck):
    """Adds extra card to deck"""
    data = request.get_json()
    return DeckService.addextracard_to_player(deck, data['name'], data['player_card'])
Пример #12
0
def addcardextra_deck(deck):
    """Adds extra card to deck"""
    return DeckService.addextracard(deck, request.get_json()['name'])
Пример #13
0
def enablecard_deck(deck):
    """Assigns card in deck"""
    return DeckService.enable_card(deck, request.get_json())
Пример #14
0
def assigncard_deck(deck):
    """Assigns card in deck"""
    return DeckService.assigncard(deck, request.get_json())
Пример #15
0
def addsquadcard_deck(deck):
    """Adds squad cards to deck high command squad"""
    return DeckService.addcard_to_squad(deck, request.get_json())