コード例 #1
0
 static void accountInfo()
 {
     while (true)
     {
         clearScreen();
         GrdResult <GrdAccountInfo> result = GrdManager.AccountBalance(username);
         Console.WriteLine("ACCOUNT INFORMATION");
         Console.WriteLine("-----------------------------------");
         if (result.error != 0)
         {
             printError(result);
         }
         else
         {
             Console.WriteLine("Username:"******"");
             Console.WriteLine("Wallet address:" + result.data.address + "");
             Console.WriteLine("Balance:" + result.data.balance.ToString() + "");
         }
         Console.WriteLine("-----------------------------------");
         Console.WriteLine("TO DO");
         Console.WriteLine("1.Transfer money to other address (use for user).");
         Console.WriteLine("2.Charge from this account (use for game action).");
         Console.WriteLine("3.Pay money to this account(use for game action).");
         Console.WriteLine("4.List transactions");
         Console.WriteLine("5.Refresh.");
         Console.WriteLine("10.Go back...");
         Console.WriteLine("-----------------------------------");
         Console.Write("YOUR CHOISE:");
         userSelect = Console.ReadLine();
         if (userSelect.Equals("1"))
         {
             transfer();
         }
         else if (userSelect.Equals("2"))
         {
             chargeMoney();
         }
         else if (userSelect.Equals("3"))
         {
             payMoney();
         }
         else if (userSelect.Equals("4"))
         {
             listTransactions();
         }
         else if (userSelect.Equals("10"))
         {
             return;
         }
     }
 }
コード例 #2
0
 static void ScoreApiTest()
 {
     while (true)
     {
         GrdResult <GrdLeaderBoard> result = GrdManager.GetUserScoreRank(username, scoreType);
         if (result.error == 0)
         {
             clearScreen();
             Console.WriteLine("SCORE API TEST");
             Console.WriteLine("Score type test:" + scoreType + "");
             Console.WriteLine("User score:" + result.data.score + "");
             Console.WriteLine("User rank:" + result.data.rank + "");
             Console.WriteLine("-----------------------------------");
             Console.WriteLine("1. Set score");
             Console.WriteLine("2. Increase score");
             Console.WriteLine("3. Leader board");
             Console.WriteLine("10.Exit.");
             Console.WriteLine("-----------------------------------");
             Console.Write("YOUR CHOISE:");
             userSelect = Console.ReadLine();
             if (userSelect.Equals("1"))
             {
                 setScore();
             }
             else if (userSelect.Equals("2"))
             {
                 increaseScore();
             }
             else if (userSelect.Equals("3"))
             {
                 game_leaderboard("GAME LEADER BOARD SCORETYPE:" + scoreType, scoreType);
             }
             else if (userSelect.Equals("10"))
             {
                 return;
             }
         }
         else
         {
             printError(result);
             return;
         }
     }
 }
コード例 #3
0
        static void lowhighgame_history()
        {
            clearScreen();
            Console.WriteLine("LOW-HIGH GAME HISTORY");
            Console.WriteLine("*********************************************************");
            GrdResult <GrdSessionData[]> result = GrdManager.GetUserSessionData(username, "LOWHIGHGAME", "result", 0, 20);

            if (result.error == 0)
            {
                Console.WriteLine("+-TIME-------------------------+-----CARD-----+---SELECT--+----RESULT----+-----MONEY-----+");
                foreach (GrdSessionData dt in result.data)
                {
                    //Contains the rand key
                    if (dt.values.ContainsKey("result"))
                    {
                        String value = dt.values["result"];
                        //Read the array result
                        List <object> jValue;
                        try
                        {
                            jValue = (List <object>)Json.Deserialize(value);
                            bool   islow      = jValue[0].ToString() == "1";
                            string yourNumber = jValue[1].ToString();
                            string randNumber = jValue[2].ToString();
                            double money      = double.Parse(jValue[3].ToString());
                            //
                            Console.WriteLine("|" + formatField(dt.getTime().ToString(), 30) + "|" + formatField(yourNumber + "", 14) + "|" + formatField((islow ? "LOW" : "HIGH"), 11) + "|" + formatField(randNumber + "", 14) + "|" + formatField(money + "", 15) + "|");
                            Console.WriteLine("+------------------------------+--------------+-----------+--------------+---------------+");
                        }
                        catch (Exception e)
                        {
                            // TODO Auto-generated catch block
                        }
                    }
                }
                pauseScreen();
            }
            else
            {
                printError(result);
            }
        }
コード例 #4
0
        /*END ACCOUNT TEST*/
        /*SCRIPT SERVER API*/

        static void random09_history()
        {
            clearScreen();
            Console.WriteLine("RANDOM 1-9 HISTORY");
            Console.WriteLine("*********************************************************");
            GrdResult <GrdSessionData[]> result = GrdManager.GetUserSessionData(username, "GAME-9", "rand", 0, 20);

            if (result.error == 0)
            {
                Console.WriteLine("+-TIME-------------------------+---SELECT--+----RESULT----+-----MONEY-----+");
                foreach (GrdSessionData dt in result.data)
                {
                    if (dt.values.ContainsKey("rand"))
                    {
                        String value      = dt.values["rand"];
                        String yourNumber = "";
                        String randNumber = "";
                        String money;
                        int    ipos = value.IndexOf(",");
                        if (ipos > 0)
                        {
                            yourNumber = value.Substring(0, ipos);
                            value      = value.Substring(ipos + 1);
                        }
                        ipos = value.IndexOf(",");
                        if (ipos > 0)
                        {
                            randNumber = value.Substring(0, ipos);
                            value      = value.Substring(ipos + 1);
                        }
                        money = value;
                        Console.WriteLine("|" + formatField(dt.getTime().ToString(), 30) + "|" + formatField(yourNumber, 11) + "|" + formatField(randNumber, 14) + "|" + formatField(money, 15) + "|");
                        Console.WriteLine("+------------------------------+-----------+--------------+---------------+");
                    }
                }
                pauseScreen();
            }
            else
            {
                printError(result);
            }
        }
コード例 #5
0
        /*LEADER BOARD*/

        static void game_leaderboard(String title, String scoreType)
        {
            Console.WriteLine(title);
            Console.WriteLine("*********************************************************");
            GrdResult <GrdLeaderBoard[]> result = GrdManager.GetLeaderBoard(username, scoreType, 0, 20);

            if (result.error == 0)
            {
                Console.WriteLine("+-RANK---+----NAME------------------------------------+---SCORE--+");
                foreach (GrdLeaderBoard item in result.data)
                {
                    Console.WriteLine("|" + formatField(item.rank + "", 8) + "|" + formatField(item.username, 44) + "|" + formatField(item.score + "", 10) + "|");
                    Console.WriteLine("+--------+--------------------------------------------+----------+");
                }
                pauseScreen();
            }
            else
            {
                printError(result);
            }
        }
コード例 #6
0
        static void listTransactions()
        {
            int             pageSize    = 10;
            int             pageIndex   = 0;
            GrdResult <int> countResult = GrdManager.GetTransactionCount(username);

            if (countResult.error != 0)
            {
                printError(countResult);
            }
            else
            {
                do
                {
                    clearScreen();
                    Console.WriteLine("TRANSACTIONS");
                    Console.WriteLine("*********************************************************");
                    GrdResult <GrdTransaction[]> trans = GrdManager.GetTransactions(username, pageIndex * pageSize, pageSize);
                    if (trans.error == 0)
                    {
                        foreach (GrdTransaction tran in trans.data)
                        {
                            Console.WriteLine("------------------------------------------------------------");
                            Console.WriteLine("tx:" + tran.tx + "");
                            Console.WriteLine("time:" + tran.getTime().ToString() + "");
                            Console.WriteLine("from:" + tran.from + "");
                            Console.WriteLine("to:" + tran.to + "");
                            Console.WriteLine("amount:" + tran.amount.ToString() + "");
                            Console.WriteLine("type:" + (tran.transtype == TransactionType.Internal ? "Internal" : "External") + "");
                            Console.WriteLine("status:" + (tran.status == TransactionStatus.Success ? "Success" : (tran.status == TransactionStatus.Pending ? "Pending" : "Error")) + "");
                            Console.WriteLine("------------------------------------------------------------");
                        }

                        Console.WriteLine("*********************************************************");
                        int pageCount = (int)Math.Ceiling((double)countResult.data / pageSize);
                        Console.WriteLine("Page:" + (pageIndex + 1) + "/" + pageCount + "| Next:1-Prev:2-Exit:10");
                        Console.Write("YOUR CHOISE:");
                        userSelect = Console.ReadLine();
                        if (userSelect.Equals("2"))
                        {
                            if (pageIndex > 0)
                            {
                                pageIndex--;
                            }
                        }
                        else if (userSelect.Equals("1"))
                        {
                            if (pageIndex < pageCount - 1)
                            {
                                pageIndex++;
                            }
                        }
                        else if (userSelect.Equals("10"))
                        {
                            return;
                        }
                    }
                    else
                    {
                        printError(trans);
                    }
                } while (true);
            }
        }