示例#1
0
        static public void CreateDeal(RequestContext request)
        {
            int userstate = UserHandler.AuthUser(request);

            if (userstate == 1 || userstate == 2)
            {
                TradeItem item = JsonConvert.DeserializeObject <TradeItem>(request.Message);
                User      user = UserHandler.GetUserDataByToken(request);
                if (UserCardsHandler.CheckValidCardToUser(item.cardToTrade, user))
                {
                    try
                    {
                        TradingDatabaseHandler.CreateTradingDeal(user, item);
                        Output.WriteConsole(Output.TradeCreationSuccess);
                    }
                    catch (Exception e)
                    {
                        Output.WriteConsole(e.Message);
                    }
                    return;
                }
                Output.WriteConsole(Output.TradeCreationInvalidCard);
                return;
            }
            Output.WriteConsole(Output.AuthError);
        }
示例#2
0
 public static void HandleByCommand(RequestContext request)
 {
     if (String.Compare(request.Ressource, RequestCalls.deck) == 0)
     {
         UserCardsHandler.ConfigureDeck(request);
     }
     if (request.Ressource.Contains(RequestCalls.specific_user))
     {
         UserHandler.UpdateExtraUserData(request);
     }
 }
示例#3
0
        static public void SellCard(RequestContext request)
        {
            int userstate = UserHandler.AuthUser(request);

            if (userstate == 1 || userstate == 2)
            {
                User   user   = UserHandler.GetUserDataByToken(request);
                string cardId = request.Message.Trim('"');
                if (UserCardsHandler.CheckValidCardToUser(cardId, user))
                {
                    UserCardsHandler.SellCard(cardId, user);
                    Output.WriteConsole(Output.CardSoldSuccess);
                    return;
                }
                Output.WriteConsole(Output.CardSoldError);
                return;
            }
            Output.WriteConsole(Output.AuthError);
        }
示例#4
0
 static public string HandleByCommand(RequestContext request)
 {
     if (String.Compare(request.Ressource, RequestCalls.cards) == 0)
     {
         return(UserCardsHandler.ShowStack(request));
     }
     if (String.Compare(request.Ressource, RequestCalls.deck_plain) == 0)
     {
         return(UserCardsHandler.ShowDeck(request, true));
     }
     if (String.Compare(request.Ressource, RequestCalls.deck) == 0)
     {
         return(UserCardsHandler.ShowDeck(request, false));
     }
     if (request.Ressource.Contains(RequestCalls.specific_user))
     {
         return(UserHandler.ShowPersonalUserData(request));
     }
     if (String.Compare(request.Ressource, RequestCalls.stats) == 0)
     {
         return(UserHandler.ShowPersonalStats(request));
     }
     if (String.Compare(request.Ressource, RequestCalls.score) == 0)
     {
         return(UserHandler.ShowScoreboard(request));
     }
     if (String.Compare(request.Ressource, RequestCalls.tradings) == 0)
     {
         return(TradingHandler.ShowTradeDeals(request));
     }
     if (String.Compare(request.Ressource, RequestCalls.friends) == 0)
     {
         return(FriendlistHandler.ShowFriendlist(request));
     }
     return("Kein passender Befehl!");
 }