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)}")
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)
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)
def addcard_deck(deck): """Adds cards to deck""" return DeckService.addcard(deck, request.get_json())
def reset_deck(deck): """Resets deck""" return DeckService.reset(deck)
def update_deck(deck): """Updates base deck info not cards""" return DeckService.update(deck, request.get_json()['deck'])
def removesquadcard_deck(deck): """Removes squad cards from deck high command""" return DeckService.removecard_from_squad(deck, request.get_json())
def commit_deck(deck): """Commits deck""" return DeckService.commit(deck)
def removecardextra_deck(deck): """Removes extra card from deck""" return DeckService.removeextracard(deck, request.get_json())
def removecard_deck(deck): """Removes cards from deck""" return DeckService.removecard(deck, request.get_json())
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'])
def addcardextra_deck(deck): """Adds extra card to deck""" return DeckService.addextracard(deck, request.get_json()['name'])
def enablecard_deck(deck): """Assigns card in deck""" return DeckService.enable_card(deck, request.get_json())
def assigncard_deck(deck): """Assigns card in deck""" return DeckService.assigncard(deck, request.get_json())
def addsquadcard_deck(deck): """Adds squad cards to deck high command squad""" return DeckService.addcard_to_squad(deck, request.get_json())