示例#1
0
        public void RequestBuy(int accountId, int requestId, long cost, byte serverId)
        {
            long     tollPoint = DAOManager.AccountDAO.GetTollPoint(accountId);
            GameInfo gameInfo  = GameService.GameServerIndoForId(serverId);

            checked
            {
                if (Information.IsNothing(gameInfo) || !gameInfo.IsOnline() || !gameInfo.IsOnGameServer(accountId))
                {
                    log.Error((object)("#" + Conversions.ToString(serverId) + "服务器不存在,或帐号ID " + Conversions.ToString(accountId) + " 未登录当前服务器!"));
                }
                else if (cost < 0)
                {
                    long points = tollPoint + cost * -1;
                    DAOManager.AccountDAO.UpdataToll(accountId, points, 0L);
                    gameInfo.GameConnection.SendPacket(new SM_GS_PREMIUM_RESPONSE(requestId, RESULT_ADD, points));
                }
                else if (tollPoint < cost)
                {
                    gameInfo.GameConnection.SendPacket(new SM_GS_PREMIUM_RESPONSE(requestId, RESULT_LOW_POINTS, tollPoint));
                }
                else if (DAOManager.AccountDAO.UpdataToll(accountId, tollPoint, cost))
                {
                    tollPoint -= cost;
                    gameInfo.GameConnection.SendPacket(new SM_GS_PREMIUM_RESPONSE(requestId, RESULT_OK, tollPoint));
                    log.InfoFormat("#{0}服务器帐号ID为 {1} 的用户购买物品成功! 收取费用: {2}", (object)serverId, (object)accountId, (object)cost);
                }
                else
                {
                    gameInfo.GameConnection.SendPacket(new SM_GS_PREMIUM_RESPONSE(requestId, RESULT_FAIL, tollPoint));
                    log.WarnFormat("#{0}服务器帐号ID为 {1} 的用户购买物品失败! 原因: 无法正常收取费用 {2}", (object)serverId, (object)accountId, (object)cost);
                }
            }
        }
示例#2
0
        internal static void CheckAuth(SessionKey key, GameConnection client)
        {
            AionConnection value = null;

            if (Conversions.ToBoolean(accountOnLS.TryGetValue(key.AccountId, out value) && Conversions.ToBoolean(value.SessionKey.CheckSessionKey(key))))
            {
                accountOnLS.Remove(key.AccountId);
                GameInfo gameInfo = GameService.GameServerIndoForId(client.GameServerId);
                Account  account  = value.Account;
                gameInfo.AddAccount(account);
                account.LastServer = checked ((byte)gameInfo.ServerId);
                LunaInfo lunaInfo = DAOManager.LunaDAO.LoadLuna(key.AccountId);
                if (Information.IsNothing(lunaInfo))
                {
                    DateTime time = new DateTime(DateAndTime.Now.Year, DateAndTime.Now.Month, DateAndTime.Now.Day, 9, 0, 0);
                    lunaInfo = new LunaInfo(key.AccountId, 0L, 0, 0, 0, time);
                    DAOManager.LunaDAO.Store(lunaInfo);
                }
                account.LunaInfo = lunaInfo;
                client.SendPacket(new SM_GS_ACCOUNT_AUTH_RESPONSE(key.AccountId, ok: true, account));
                DAOManager.AccountDAO.UpdateLastIpAndServer(account);
                if (ExpirationConfig.EXPIRATION_ENABLE)
                {
                    ExpirationService.GetInstance().Add(account);
                }
            }
            else
            {
                client.SendPacket(new SM_GS_ACCOUNT_AUTH_RESPONSE(key.AccountId, ok: false, null));
            }
        }