コード例 #1
0
ファイル: PathHandler.cs プロジェクト: sergeev/NexusForever
        public static void HandlePathUnlock(WorldSession session, ClientPathUnlock clientPathUnlock)
        {
            uint unlockCost = GameTableManager.Instance.GameFormula.GetEntry(2365).Dataint0;

            GenericError CanUnlockPath()
            {
                bool hasEnoughTokens = session.AccountCurrencyManager.CanAfford(AccountCurrencyType.ServiceToken, unlockCost);

                if (!hasEnoughTokens)
                {
                    return(GenericError.PathInsufficientFunds);
                }

                if (session.Player.PathManager.IsPathUnlocked(clientPathUnlock.Path))
                {
                    return(GenericError.PathAlreadyUnlocked);
                }

                return(GenericError.Ok);
            }

            GenericError result = CanUnlockPath();

            if (result != GenericError.Ok)
            {
                session.Player.PathManager.SendServerPathUnlockResult(result);
                return;
            }

            session.Player.PathManager.UnlockPath(clientPathUnlock.Path);
            session.AccountCurrencyManager.CurrencySubtractAmount(AccountCurrencyType.ServiceToken, unlockCost);
        }
コード例 #2
0
ファイル: PathHandler.cs プロジェクト: zeaf/NexusForever
        public static void HandlePathUnlock(WorldSession session, ClientPathUnlock clientPathUnlock)
        {
            log.Debug($"ClientPathUnlock: Path: {clientPathUnlock.Path}");

            Player player = session.Player;
            // TODO: Handle removing service tokens
            // TODO: Return proper error codes


            // TODO: HasEnoughTokens should be a request to a currency manager of somesort
            bool HasEnoughTokens = true;

            if (HasEnoughTokens)
            {
                player.PathManager.UnlockPath(clientPathUnlock.Path);
            }
        }