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); }
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); } }