Exemplo n.º 1
0
        private void Client_OnSpendCoins(object sender, SpendCoinsArgs e)
        {
            string str = string.Format("OnSpendCoins: SpendOn({0}), Coins({1}), AuthToken({2})", e.SpendOn, e.Coins, AuthStringManager.AuthStringToAscii(e.AuthToken));

            LogThread.Log(str, LogInterface.LogMessageType.Normal, true);
            TaskProcessor.AddTask(new HTask(HTask.HTaskType.SpendCoins, (HClient)sender, e));
        }
Exemplo n.º 2
0
        void SpendCoins_Handler(Task t)
        {
            HTask task = (HTask)t;

            object[]       argsA = (object[])t.Args;
            SpendCoinsArgs args  = (SpendCoinsArgs)argsA[0];

            // Validate auth string
            AuthStringManager.AuthAccountInfo aai = _server.AuthManager.FindAccount(args.AuthToken);
            if (aai == null)
            {
                // This account isnt in the cache, need to go fetch from global server
                task.Client.PendingAuthTask = task;
                _server.GlobalServer.FetchAuthString(args.AuthToken, task.Client.SessionKey);
                return;
            }

            // Record this spend in the database
            string sql = string.Format("INSERT INTO spends SET account_id={0}, amount={1}, reason={2}, timestamp={3}; SELECT LAST_INSERT_ID();", aai.AccountID, args.Coins, args.SpendOn, DateTime.Now.Ticks);

            task.Client.AccountId = aai.AccountID;
            t.Type = (int)GSTask.GSTType.SpendCoins_Global;
            t.Args = args.Coins;
            AddDBQuery(sql, t);
        }
Exemplo n.º 3
0
        void ValidateGameInfo_GameDataProcess_Handler(Task t)
        {
            HTask task = (HTask)t;

            object[]             args = (object[])t.Args;
            ValidateGameInfoArgs gia  = (ValidateGameInfoArgs)args[0];

            if (t.Query.Rows.Count > 0)
            {
                gia.GameInfo.GameData = ReadGameData(t.Query);
            }
            else
            {
                // Put this record in the database
                string sql = string.Format("INSERT INTO game_data SET account_id={0},tower0=1;", task.Client.AccountId);
                t.Type = -1;
                AddDBQuery(sql, t);

                // Also give this user 100 coins
                SpendCoinsArgs scargs = new SpendCoinsArgs();
                scargs.AuthToken = gia.AuthString;
                scargs.Coins     = -100;
                scargs.SpendOn   = 0;
                AddTask(new HTask(HTask.HTaskType.SpendCoins, task.Client, scargs));
                AuthStringManager.AuthAccountInfo aai = _server.AuthManager.FindAccount(gia.AuthString);
                aai.HardCurrency += 100;

                // Setup the default info
                gia.GameInfo.GameData                = new GameDataArgs();
                gia.GameInfo.GameData.TowerFloors    = new int[6];
                gia.GameInfo.GameData.TowerFloors[0] = 1;
            }

            if (gia.RequestFinished)
            {
                ProcessValidateGameInfo(gia, task.Client);
            }
        }
Exemplo n.º 4
0
        void GameData_Fetched_Handler(Task t)
        {
            HTask task = (HTask)t;

            if (task.Query.Rows.Count <= 0)
            {
                // game data doesnt exist for this user yet
                string sql = string.Format("INSERT INTO game_data SET account_id={0},tower_floor_0=1;", task.Client.AccountId);
                t.Type = (int)HTask.HTaskType.GameData_Fetch;
                AddDBQuery(sql, t);

                // Also give this user 100 coins
                SpendCoinsArgs args = new SpendCoinsArgs();
                args.Coins   = -100;
                args.SpendOn = 0;
                AddTask(new HTask(HTask.HTaskType.SpendCoins, task.Client, args));
            }
            else
            {
                GameDataArgs gameData = ReadGameData(task.Query);
                task.Client.SendGameData(gameData);
            }
        }