/// <summary>
        /// Handles the card selection 'confirm deck' logic.
        /// </summary>
        /// <param name="page">The page to build.</param>
        private void DeckCardSelectionConfirmDeckPageInit(DialogPage page)
        {
            page.Header = "Is this deck okay?";

            page.AddResponse($"{ColorToken.Green("Confirm Deck")}", () =>
            {
                var player              = GetPC();
                var playerId            = GetObjectUUID(player);
                var dbPlayerTripleTriad = DB.Get <PlayerTripleTriad>(playerId);
                var model = GetDataModel <Model>();
                var deck  = dbPlayerTripleTriad.Decks.ContainsKey(model.SelectedDeckId)
                    ? dbPlayerTripleTriad.Decks[model.SelectedDeckId]
                    : new CardDeck {
                    Name = "New Deck"
                };

                deck.Card1 = (CardType)GetLocalInt(player, "CARD_MENU_DECK_CARD_1");
                deck.Card2 = (CardType)GetLocalInt(player, "CARD_MENU_DECK_CARD_2");
                deck.Card3 = (CardType)GetLocalInt(player, "CARD_MENU_DECK_CARD_3");
                deck.Card4 = (CardType)GetLocalInt(player, "CARD_MENU_DECK_CARD_4");
                deck.Card5 = (CardType)GetLocalInt(player, "CARD_MENU_DECK_CARD_5");

                dbPlayerTripleTriad.Decks[model.SelectedDeckId] = deck;
                DB.Set(playerId, dbPlayerTripleTriad);

                DeleteLocalInt(player, "CARD_MENU_CURRENT_MODE");

                NavigationStack = model.NavigationStackBeforeDeckBuilding;
                ChangePage(DeckListPageId, false);
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Builds the Main Page.
        /// </summary>
        /// <param name="page">The page to build.</param>
        private void MainPageInit(DialogPage page)
        {
            var player   = GetPC();
            var playerId = GetObjectUUID(player);
            var dbPlayer = DB.Get <Player>(playerId);

            // Get all player skills and then sum them up by the rank.
            var totalSkillCount = dbPlayer.TotalSPAcquired;

            var    playerName = GetName(player);
            string header     = ColorToken.Green("Name: ") + playerName + "\n";

            header += ColorToken.Green("Skill Points: ") + totalSkillCount + " / " + Skill.SkillCap + "\n";
            header += ColorToken.Green("Unallocated SP: ") + dbPlayer.UnallocatedSP + "\n";
            header += ColorToken.Green("Unallocated XP: ") + dbPlayer.UnallocatedXP + "\n";

            page.Header = header;

            page.AddResponse("View Skills", () => SwitchConversation("ViewSkillsDialog"));
            page.AddResponse("View Perks", () => SwitchConversation("ViewPerksDialog"));
            page.AddResponse("View Achievements", () => SwitchConversation("ViewAchievementsDialog"));
            page.AddResponse("View Blueprints", () => SwitchConversation("ViewBlueprintsDialog"));
            page.AddResponse("Modify Item Appearance", () => SwitchConversation("ModifyItemAppearanceDialog"));
            page.AddResponse("Player Settings", () => SwitchConversation("PlayerSettingsDialog"));
            page.AddResponse("Open Trash Can (Destroy Items)", () =>
            {
                EndConversation();
                var location = GetLocation(player);
                var trashCan = CreateObject(ObjectType.Placeable, "trash_can", location);

                AssignCommand(player, () => ActionInteractObject(trashCan));
                DelayCommand(0.2f, () => SetUseableFlag(trashCan, false));
            });
        }
        /// <summary>
        /// Handles the card list logic.
        /// </summary>
        /// <param name="page">The page to build</param>
        private void ViewCardsPageInit(DialogPage page)
        {
            var model               = GetDataModel <Model>();
            var player              = GetPC();
            var playerId            = GetObjectUUID(player);
            var dbPlayerTripleTriad = DB.Get <PlayerTripleTriad>(playerId) ?? new PlayerTripleTriad();
            var availableCards      = TripleTriad.GetAllCardsAtLevel(model.SelectedCardLevel);

            page.Header = $"{ColorToken.Green("Level: ")} {model.SelectedCardLevel}\n\n" +
                          $"The following is the list of cards available at this level. Cards in {ColorToken.Green("GREEN")} have been acquired. Those in {ColorToken.Red("RED")} have not. Only one card per type can be collected.\n\n" +
                          "Please select a card.";

            foreach (var(type, card) in availableCards)
            {
                if (!card.IsVisibleInMenu)
                {
                    continue;
                }

                var option = dbPlayerTripleTriad.AvailableCards.ContainsKey(type)
                    ? ColorToken.Green(card.Name)
                    : ColorToken.Red(card.Name);

                page.AddResponse(option, () =>
                {
                    model.SelectedCardType = type;
                    SetLocalInt(player, "CARD_MENU_SELECTED_CARD_ID", (int)model.SelectedCardType);
                    ChangePage(ViewCardDetailsPageId);
                });
            }
        }
Exemplo n.º 4
0
        private void MainPageInit(DialogPage page)
        {
            var player = GetPC();

            page.Header = ColorToken.Green("Home Point") + "\n\n" +
                          "You can set your home point to this location. If you should die, you will return to your last home point.";

            page.AddResponse("Set Home Point", () =>
            {
                if (!GetIsPC(player) || GetIsDM(player))
                {
                    return;
                }

                var playerId = GetObjectUUID(player);
                var dbPlayer = DB.Get <Player>(playerId);

                var position    = GetPosition(OBJECT_SELF);
                var area        = GetArea(OBJECT_SELF);
                var areaResref  = GetResRef(area);
                var orientation = GetFacing(OBJECT_SELF);

                dbPlayer.RespawnLocationX           = position.X;
                dbPlayer.RespawnLocationY           = position.Y;
                dbPlayer.RespawnLocationZ           = position.Z;
                dbPlayer.RespawnAreaResref          = areaResref;
                dbPlayer.RespawnLocationOrientation = orientation;

                FloatingTextStringOnCreature("Home point set!", player, false);

                EndConversation();
            });
        }
Exemplo n.º 5
0
        private void ChangeStoreNameInit(DialogPage page)
        {
            var player        = GetPC();
            var playerId      = GetObjectUUID(player);
            var dbPlayerStore = DB.Get <PlayerStore>(playerId) ?? new PlayerStore();
            var newStoreName  = GetLocalString(player, "NEW_STORE_NAME");

            if (string.IsNullOrWhiteSpace(newStoreName))
            {
                newStoreName = dbPlayerStore.StoreName;
            }

            page.Header = ColorToken.Green("Store Name: ") + dbPlayerStore.StoreName + "\n" +
                          ColorToken.Green("New Name: ") + newStoreName + "\n\n" +
                          "Set your store's name by entering it in the chat bar. Press 'Refresh' to see changes.";

            page.AddResponse(ColorToken.Green("Refresh"), () => { });
            page.AddResponse("Set Name", () =>
            {
                dbPlayerStore.StoreName = newStoreName;
                DB.Set(playerId, dbPlayerStore);
                PlayerMarket.UpdateCacheEntry(playerId, dbPlayerStore);
            });

            SetLocalBool(player, "IS_SETTING_STORE_NAME", true);
        }
Exemplo n.º 6
0
        public void Advance(uint player, string questId)
        {
            var playerId = GetObjectUUID(player);
            var dbPlayer = DB.Get <Player>(playerId);
            var quest    = dbPlayer.Quests.ContainsKey(questId) ? dbPlayer.Quests[questId] : null;

            if (quest == null)
            {
                return;
            }
            if (!quest.ItemProgresses.ContainsKey(_resref))
            {
                return;
            }
            if (quest.ItemProgresses[_resref] <= 0)
            {
                return;
            }

            quest.ItemProgresses[_resref]--;
            DB.Set(playerId, dbPlayer);

            var questDetail = Quest.GetQuestById(questId);
            var itemName    = Cache.GetItemNameByResref(_resref);

            var statusMessage = $"[{questDetail.Name}] {itemName} remaining: {quest.ItemProgresses[_resref]}";

            if (quest.ItemProgresses[_resref] <= 0)
            {
                statusMessage += $" {ColorToken.Green("{COMPLETE}")}";
            }

            SendMessageToPC(player, statusMessage);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Processes and runs the specific chat command entered by the user.
        /// </summary>
        /// <param name="commandName">Name of the command</param>
        /// <param name="sender">The sender object</param>
        /// <param name="target">The target of the command. OBJECT_INVALID if no target is necessary.</param>
        /// <param name="targetLocation">The target location of the command. null if no target is necessary.</param>
        /// <param name="args">User-entered arguments</param>
        private static void ProcessChatCommand(string commandName, uint sender, uint target, Location targetLocation, string args)
        {
            var command = ChatCommands[commandName];

            if (targetLocation == null)
            {
                targetLocation = new Location(IntPtr.Zero);
            }

            var authorization = Authorization.GetAuthorizationLevel(sender);

            if (command.Permissions.HasFlag(CommandPermissionType.Player) && authorization == AuthorizationLevel.Player ||
                command.Permissions.HasFlag(CommandPermissionType.DM) && authorization == AuthorizationLevel.DM ||
                command.Permissions.HasFlag(CommandPermissionType.Admin) && authorization == AuthorizationLevel.Admin)
            {
                string[] argsArr = string.IsNullOrWhiteSpace(args) ? new string[0] : args.Split(' ').ToArray();
                string   error   = command.ValidateArguments(sender, argsArr);

                if (!string.IsNullOrWhiteSpace(error))
                {
                    SendMessageToPC(sender, error);
                }
                else
                {
                    command.DoAction(sender, target, targetLocation, argsArr);
                }
            }
            else
            {
                SendMessageToPC(sender, ColorToken.Red("Invalid chat command. Use '/help' to get a list of available commands."));
            }
        }
Exemplo n.º 8
0
        public void Advance(uint player, string questId)
        {
            var playerId = GetObjectUUID(player);
            var dbPlayer = DB.Get <Player>(playerId);
            var quest    = dbPlayer.Quests.ContainsKey(questId) ? dbPlayer.Quests[questId] : null;

            if (quest == null)
            {
                return;
            }
            if (!quest.KillProgresses.ContainsKey(Group))
            {
                return;
            }
            if (quest.KillProgresses[Group] <= 0)
            {
                return;
            }

            quest.KillProgresses[Group]--;
            DB.Set(playerId, dbPlayer);

            var npcGroup    = Quest.GetNPCGroup(Group);
            var questDetail = Quest.GetQuestById(questId);

            var statusMessage = $"[{questDetail.Name}] {npcGroup.Name} remaining: {quest.KillProgresses[Group]}";

            if (quest.KillProgresses[Group] <= 0)
            {
                statusMessage += $" {ColorToken.Green("{COMPLETE}")}";
            }

            SendMessageToPC(player, statusMessage);
        }
        private void MainPageInit(DialogPage page)
        {
            var player              = GetPC();
            var playerId            = GetObjectUUID(player);
            var dbPlayerTripleTriad = DB.Get <PlayerTripleTriad>(playerId) ?? new PlayerTripleTriad();
            var model = GetDataModel <Model>();

            page.Header = "Which deck would you like to use?";

            page.AddResponse(ColorToken.Green("View Cards"), () => SwitchConversation(nameof(TripleTriadPlayerDialog)));

            foreach (var(_, deck) in dbPlayerTripleTriad.Decks)
            {
                if (deck.Card1 != CardType.Invalid &&
                    deck.Card2 != CardType.Invalid &&
                    deck.Card3 != CardType.Invalid &&
                    deck.Card4 != CardType.Invalid &&
                    deck.Card5 != CardType.Invalid)
                {
                    page.AddResponse($"Choose Deck: {deck.Name}", () =>
                    {
                        TripleTriad.StartGame(player, deck, OBJECT_SELF, model.NPCDeck);
                        EndConversation();
                    });
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        /// Handles the "Sell House Page" header and responses.
        /// </summary>
        /// <param name="page">The page we're building.</param>
        private void SellHousePageInit(DialogPage page)
        {
            var player   = GetPC();
            var playerId = GetObjectUUID(player);
            var dbHouse  = DB.Get <PlayerHouse>(playerId);
            var model    = GetDataModel <Model>();

            var houseDetail = Housing.GetHouseTypeDetail(dbHouse.HouseType);
            var gil         = houseDetail.Price / 2;

            page.Header = ColorToken.Red("WARNING: ") + "You are about to sell your property. All items contained inside will be permanently lost!\n\n" +
                          "It is highly recommended you pick up all items and furniture inside before selling the property.\n\n" +
                          ColorToken.Green($"You will receive {gil} gil for the sale of this property. Are you sure you wish to sell it?");

            if (model.IsConfirmingSell)
            {
                page.AddResponse(ColorToken.Red($"CONFIRM SELL PROPERTY"), () =>
                {
                    DB.Delete <PlayerHouse>(playerId);

                    GiveGoldToCreature(player, gil);
                    FloatingTextStringOnCreature($"Property sold successfully for {gil} gil.", player, false);
                    EndConversation();

                    Log.Write(LogGroup.PlayerHousing, $"Player {GetName(player)} (ID = '{playerId}') sold their property for {gil} gil.");
                });
            }
            else
            {
                page.AddResponse(ColorToken.Red("Sell Property"), () =>
                {
                    model.IsConfirmingSell = true;
                });
            }
        }
        private static void BuildHelpText()
        {
            foreach (var command in _chatCommands.Values)
            {
                var type      = command.GetType();
                var attribute = type.GetCustomAttribute <CommandDetailsAttribute>();
                if (attribute == null)
                {
                    continue;
                }

                if (attribute.Permissions.HasFlag(CommandPermissionType.Player))
                {
                    HelpTextPlayer += ColorToken.Green("/" + type.Name.ToLower()) + ColorToken.White(": " + attribute.Description) + "\n";
                }

                if (attribute.Permissions.HasFlag(CommandPermissionType.DM))
                {
                    HelpTextDM += ColorToken.Green("/" + type.Name.ToLower()) + ColorToken.White(": " + attribute.Description) + "\n";
                }

                if (attribute.Permissions.HasFlag(CommandPermissionType.Admin))
                {
                    HelpTextAdmin += ColorToken.Green("/" + type.Name.ToLower() + ColorToken.White(": " + attribute.Description) + "\n");
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Handles the "Purchase List Page" header and responses.
        /// </summary>
        /// <param name="page">The page we're building.</param>
        private void PurchaseHouseLayoutListPageInit(DialogPage page)
        {
            var player           = GetPC();
            var playerId         = GetObjectUUID(player);
            var dbPlayer         = DB.Get <Player>(playerId);
            var seedRank         = dbPlayer.SeedProgress.Rank;
            var availableLayouts = Housing.GetActiveHouseTypes();
            var model            = GetDataModel <Model>();

            page.Header = "You can purchase any of the following layouts. Please note that this list is restricted based on your current SeeD rank. Complete missions to raise your SeeD rank and unlock new layouts.\n\n" +
                          ColorToken.Green("Your SeeD Rank: ") + seedRank;

            foreach (var layout in availableLayouts)
            {
                // Player's SeeD rank isn't high enough to purchase this layout.
                if (seedRank < layout.Value.RequiredSeedRank)
                {
                    continue;
                }

                page.AddResponse(layout.Value.Name, () =>
                {
                    model.SelectedHouseType = layout.Key;
                    ChangePage(PurchaseHouseLayoutDetailPageId);
                });
            }
        }
Exemplo n.º 13
0
 public string ValidateArguments(NWGameObject user, params string[] args)
 {
     if (args.Length <= 0)
     {
         return(ColorToken.Red("Please specify a quantity. Example: /" + nameof(SpawnGold) + " 34"));
     }
     return(string.Empty);
 }
Exemplo n.º 14
0
        private void EditMyShopInit(DialogPage page)
        {
            var player        = GetPC();
            var playerId      = GetObjectUUID(player);
            var dbPlayerStore = DB.Get <PlayerStore>(playerId) ?? new PlayerStore
            {
                StoreName = $"{GetName(player)}'s Store"
            };

            page.Header = ColorToken.Green("Store Name: ") + dbPlayerStore.StoreName + "\n" +
                          ColorToken.Green("Lease Expires: ") + GetLeaseStatus() + "\n" +
                          ColorToken.Green("Tax Rate: ") + (int)(dbPlayerStore.TaxRate * 100) + "%\n" +
                          ColorToken.Green("Status: ") + (dbPlayerStore.IsOpen ? "OPEN" : "CLOSED") + "\n\n" +
                          "Please select an option.";

            // The Till will be filled only if the player sold an item.
            if (dbPlayerStore.Till > 0)
            {
                page.AddResponse(ColorToken.Green($"Retrieve {dbPlayerStore.Till} Gil"), () =>
                {
                    GiveGoldToCreature(player, dbPlayerStore.Till);
                    dbPlayerStore.Till = 0;
                    DB.Set(playerId, dbPlayerStore);
                    PlayerMarket.UpdateCacheEntry(playerId, dbPlayerStore);
                });
            }

            page.AddResponse("Change Store Name", () =>
            {
                ChangePage(ChangeStoreNamePageId);
            });

            page.AddResponse("Edit Item List", () =>
            {
                if (PlayerMarket.IsStoreBeingAccessed(playerId))
                {
                    FloatingTextStringOnCreature("Your store is currently being accessed by another player. Close your store and wait until they finish to try this action again.", player, false);
                    return;
                }

                ChangePage(EditItemListPageId);
            });

            page.AddResponse(dbPlayerStore.IsOpen ? "Close Store" : "Open Store", () =>
            {
                dbPlayerStore.IsOpen = !dbPlayerStore.IsOpen;
                DB.Set(playerId, dbPlayerStore);
                PlayerMarket.UpdateCacheEntry(playerId, dbPlayerStore);
            });

            page.AddResponse("Extend Lease", () =>
            {
                ChangePage(ExtendLeasePageId);
            });

            DB.Set(playerId, dbPlayerStore);
            PlayerMarket.UpdateCacheEntry(playerId, dbPlayerStore);
        }
Exemplo n.º 15
0
        public string ValidateArguments(NWGameObject user, params string[] args)
        {
            if (args.Length <= 0)
            {
                return(ColorToken.Red("Please specify a resref and optionally a quantity. Example: /" + nameof(SpawnItem) + " my_resref 20"));
            }

            return(string.Empty);
        }
Exemplo n.º 16
0
        private static string HandleArgumentValidation(uint user, params string[] args)
        {
            if (args.Length <= 0)
            {
                return(ColorToken.Red("Please specify a resref and optionally a quantity. Example: /spawnitem my_resref 20"));
            }

            return(string.Empty);
        }
Exemplo n.º 17
0
 /// <summary>
 /// Constructs a Choice object with default configuration values
 /// </summary>
 /// <param name="console"><see cref="IConsole"/> used to output</param>
 /// <param name="text">Text to show as question</param>
 /// <param name="choices">List of possible choices. See remarks for choices rules</param>
 /// <remarks>
 /// Each char of <paramref name="choices"/> is a possible response.
 /// If the char is upper letter is considered as the default response.
 /// If <paramref name="choices"/> has more than one upper letter, only the latest is considered the default response
 /// <para>If no choices is specified, [Y/n] are the default</para>
 /// </remarks>
 public Choice(IConsole console, ColorToken text, string choices = null)
 {
     Options      = new ChoiceOptions();
     Options.Text = text ?? String.Empty;
     if (choices != null)
     {
         Options.SetChoices(choices);
     }
     Console = console ?? PowerConsole.Console.Instance;
 }
        private void MainPageInit(DialogPage page)
        {
            var player          = GetPC();
            var playerId        = GetObjectUUID(player);
            var area            = GetArea(player);
            var ownerPlayerUUID = GetLocalString(area, "HOUSING_OWNER_PLAYER_UUID");
            var dbHouse         = DB.Get <PlayerHouse>(ownerPlayerUUID);
            var permission      = dbHouse.PlayerPermissions.ContainsKey(playerId)
                ? dbHouse.PlayerPermissions[playerId]
                : new PlayerHousePermission();
            var layoutDetail = Housing.GetHouseTypeDetail(dbHouse.HouseType);
            var model        = GetDataModel <Model>();

            page.Header = ColorToken.Green("Property Management Menu") + "\n" +
                          ColorToken.Green("Furniture Limit: ") + dbHouse.Furnitures.Count + " / " + layoutDetail.FurnitureLimit + "\n\n" +
                          "Please select from the options below.";

            if (permission.CanAdjustPermissions)
            {
                // todo: Currently disabled. Plan to introduce permission management at a later date.
                //page.AddResponse(ColorToken.Green("Manage Permissions"), () => ChangePage(ManagePermissionsPageId));
            }

            // Load nearby furniture.

            if (GetIsObjectValid(model.TargetObject))
            {
                LoadFurniture(dbHouse, model.TargetObject, page);
            }

            const int MaxNumberOfFurniture = 10;
            var       nth    = 1;
            var       nearby = GetNearestObjectToLocation(model.TargetLocation, ObjectType.Placeable, nth);

            while (GetIsObjectValid(nearby))
            {
                // Reached the max.
                if (nth > MaxNumberOfFurniture)
                {
                    break;
                }

                // This placeable is the same as the targeted placeable. We don't want it to show up twice.
                if (nearby == model.TargetObject)
                {
                    continue;
                }

                LoadFurniture(dbHouse, nearby, page);

                nth++;
                nearby = GetNearestObjectToLocation(model.TargetLocation, ObjectType.Placeable, nth);
            }
        }
Exemplo n.º 19
0
        private string GetLeaseStatus()
        {
            var player        = GetPC();
            var playerId      = GetObjectUUID(player);
            var dbPlayerStore = DB.Get <PlayerStore>(playerId);
            var leaseStatus   = DateTime.UtcNow > dbPlayerStore.DateLeaseExpires
                ? ColorToken.Red("EXPIRED")
                : dbPlayerStore.DateLeaseExpires.ToString("MM/dd/yyyy hh:mm:ss");

            return(leaseStatus);
        }
        private static void DoDiceRoll(uint user, int sides, int number)
        {
            int value;

            if (number < 1)
            {
                number = 1;
            }
            else if (number > 10)
            {
                number = 10;
            }

            switch (sides)
            {
            case 2:
                value = D2(number);
                break;

            case 4:
                value = D4(number);
                break;

            case 6:
                value = D6(number);
                break;

            case 8:
                value = D8(number);
                break;

            case 10:
                value = D10(number);
                break;

            case 20:
                value = D20(number);
                break;

            case 100:
                value = D100(number);
                break;

            default:
                value = 0;
                break;
            }

            string dieRoll = number + "d" + sides;
            string message = ColorToken.SkillCheck("Dice Roll: ") + dieRoll + ": " + value;

            AssignCommand(user, () => SpeakString(message));
        }
Exemplo n.º 21
0
        /// <summary>
        /// Validates whether all requirements to use ability are met.
        /// Returns true if successful, false otherwise.
        /// </summary>
        /// <param name="stats">The user's ability stats</param>
        /// <returns>true if successful, false otherwise</returns>
        private static bool ValidateFeatUse(UserStats stats)
        {
            var user    = stats.User;
            var ability = stats.AbilityDefinition;
            var target  = stats.Target;
            var canUse  = ability.CanUse(user, target);

            if (stats.MP < stats.MPCost)
            {
                SendMessageToPC(user, ColorToken.Red("Insufficient MP."));
                return(false);
            }

            if (!GetIsObjectValid(user))
            {
                return(false);
            }

            if (!GetIsObjectValid(target))
            {
                SendMessageToPC(user, ColorToken.Red("Target lost."));
                return(false);
            }

            if (!string.IsNullOrWhiteSpace(canUse))
            {
                SendMessageToPC(user, ColorToken.Red(canUse));
                return(false);
            }

            if (stats.Now < stats.CooldownUnlock)
            {
                var timeToWait = Time.GetTimeToWaitLongIntervals(stats.Now, stats.CooldownUnlock, false);
                SendMessageToPC(user, ColorToken.Red($"Ability available in {timeToWait}."));
                return(false);
            }

            if (!LineOfSightObject(user, target))
            {
                SendMessageToPC(user, ColorToken.Red($"You cannot see your target."));
                return(false);
            }

            if (GetIsBusy(user) || GetCurrentHitPoints(user) <= 0 || !GetCommandable(user))
            {
                SendMessageToPC(user, ColorToken.Red("You are too busy."));
                return(false);
            }

            return(true);
        }
Exemplo n.º 22
0
        public static void Show(ShowType show, string msg, ServerType svr = ServerType.ALL)
        {
            ColorToken ct = "".Cyan();

            switch (show)
            {
            case ShowType.Debug:
                ct = show.ToString().DarkCyan();
                break;

            case ShowType.Error:
                ct = show.ToString().Red();
                break;

            case ShowType.Exception:
                ct = show.ToString().Magenta();
                break;

            case ShowType.Info:
                ct = show.ToString().Gray();
                break;

            case ShowType.Status:
                ct = show.ToString().Green();
                break;

            case ShowType.Warn:
                ct = show.ToString().Yellow();
                break;
            }

            switch (svr)
            {
            case ServerType.ALL:
                ColorConsole.WriteLine("[", ct, "]: ", msg);
                break;

            case ServerType.CHAR:
                ColorConsole.WriteLine("[", "Char-Server".Magenta(), "|", ct, "]: ", msg);
                break;

            case ServerType.LOGIN:
                ColorConsole.WriteLine("[", "Login-Server".Blue(), "|", ct, "]: ", msg);
                break;

            case ServerType.MAP:
                ColorConsole.WriteLine("[", "Map-Server".Yellow(), "|", ct, "]: ", msg);
                break;
            }
        }
Exemplo n.º 23
0
        private void MainPageInit(DialogPage page)
        {
            var player    = GetPC();
            var playerId  = GetObjectUUID(player);
            var dbPlayer  = DB.Get <Player>(playerId);
            var perkCount = dbPlayer.Perks.Count;

            page.Header = ColorToken.Green("Total SP: ") + dbPlayer.TotalSPAcquired + " / " + Skill.SkillCap + "\n" +
                          ColorToken.Green("Available SP: ") + dbPlayer.UnallocatedSP + "\n" +
                          ColorToken.Green("Total Perks: ") + perkCount + "\n";

            page.AddResponse("View My Perks", () => ChangePage(ViewMyPerksPageId));
            page.AddResponse("Buy Perks", () => ChangePage(CategoryPageId));
        }
Exemplo n.º 24
0
        /// <summary>
        /// Sends a message to a player informing them of the current number of items in the container and the maximum allowed.
        /// If incrementByOne is true, the current count will be increased by one. This is to account for the fact that
        /// the OnAddItem event fires before the item is actually added to the inventory (therefore it would have an off-by-one error)
        /// </summary>
        /// <param name="player">The player receiving the message</param>
        /// <param name="incrementByOne">Increments current item count by one if true, else does nothing.</param>
        protected static void SendItemLimitMessage(NWGameObject player, bool incrementByOne)
        {
            var container = NWGameObject.OBJECT_SELF;
            var limit     = GetItemLimit();
            var count     = _.GetInventoryItemCount(container);

            // The Add event fires before the item exists in the container. Need to increment by one in this scenario.
            if (incrementByOne)
            {
                count++;
            }

            _.SendMessageToPC(player, ColorToken.White("Item Limit: " + (count > limit ? limit : count) + " / ") + ColorToken.Red("" + limit));
        }
Exemplo n.º 25
0
        private void EditItemListInit(DialogPage page)
        {
            var player        = GetPC();
            var playerId      = GetObjectUUID(player);
            var dbPlayer      = DB.Get <Player>(playerId);
            var dbPlayerStore = DB.Get <PlayerStore>(playerId);
            var model         = GetDataModel <Model>();
            var itemLimit     = 5 + dbPlayer.SeedProgress.Rank * 5;

            page.Header = ColorToken.Green("Listing Limit: ") + dbPlayerStore.ItemsForSale.Count + " / " + itemLimit + "\n" +
                          ColorToken.Green("SeeD Rank: ") + dbPlayer.SeedProgress.Rank + "\n\n" +
                          "Please select the 'List Items' option to add an item to your store. Otherwise select any other option to edit that listing.";

            page.AddResponse($"{ColorToken.Green("List Items")}", () =>
            {
                if (dbPlayerStore.ItemsForSale.Count >= itemLimit)
                {
                    FloatingTextStringOnCreature("You have reached your listing limit. Increase your SeeD rank or remove another listing.", player, false);
                    return;
                }

                var terminal = OBJECT_SELF;

                SetEventScript(terminal, EventScript.Placeable_OnOpen, "mkt_term_open");
                SetEventScript(terminal, EventScript.Placeable_OnClosed, "mkt_term_closed");
                SetEventScript(terminal, EventScript.Placeable_OnInventoryDisturbed, "mkt_term_dist");
                SetEventScript(terminal, EventScript.Placeable_OnUsed, string.Empty);

                AssignCommand(player, () => ActionInteractObject(terminal));
            });

            foreach (var(itemId, item) in dbPlayerStore.ItemsForSale)
            {
                var responseName = $"{item.StackSize}x {item.Name} [{item.Price} gil]";

                page.AddResponse(responseName, () =>
                {
                    // Someone bought the item already. Don't let them progress.
                    if (!dbPlayerStore.ItemsForSale.ContainsKey(itemId))
                    {
                        FloatingTextStringOnCreature("This item has already been sold. Please select another.", player, false);
                        return;
                    }

                    model.SelectedItemId = itemId;
                    ChangePage(ListingPageId);
                });
            }
        }
        public static void ValidateDualWield()
        {
            var creature = OBJECT_SELF;
            var item     = StringToObject(Events.GetEventData("ITEM"));
            var slot     = (InventorySlot)Convert.ToInt32(Events.GetEventData("SLOT"));

            // Not equipping to the left hand, or there's nothing equipped in the right hand.
            if (slot != InventorySlot.LeftHand)
            {
                return;
            }
            if (!GetIsObjectValid(GetItemInSlot(InventorySlot.RightHand, creature)))
            {
                return;
            }

            var baseItem         = GetBaseItemType(item);
            var dualWieldWeapons = new[]
            {
                BaseItem.ShortSword,
                BaseItem.Longsword,
                BaseItem.BattleAxe,
                BaseItem.BastardSword,
                BaseItem.LightFlail,
                BaseItem.LightMace,
                BaseItem.Dagger,
                BaseItem.Club,
                BaseItem.HandAxe,
                BaseItem.Kama,
                BaseItem.Katana,
                BaseItem.Kukri,
                BaseItem.Rapier,
                BaseItem.Scimitar,
                BaseItem.Sickle
            };

            if (!dualWieldWeapons.Contains(baseItem))
            {
                return;
            }

            var dualWieldLevel = Perk.GetEffectivePerkLevel(creature, PerkType.DualWield);

            if (dualWieldLevel <= 0)
            {
                SendMessageToPC(creature, ColorToken.Red("Equipping two weapons requires the Dual Wield perk."));
                Events.SkipEvent();
            }
        }
Exemplo n.º 27
0
        private void ViewMyPerksPageInit(DialogPage page)
        {
            var player   = GetPC();
            var playerId = GetObjectUUID(player);
            var dbPlayer = DB.Get <Player>(playerId);
            var header   = ColorToken.Green("Perks purchased:\n\n");

            foreach (var pcPerk in dbPlayer.Perks)
            {
                var perkDetail = Perk.GetPerkDetails(pcPerk.Key);
                header += $"{perkDetail.Name} (Lvl. {pcPerk.Value})\n";
            }

            page.Header = header;
        }
        /// <summary>
        /// Handles the card details logic.
        /// </summary>
        /// <param name="page">The page to build</param>
        private void ViewCardDetailsPageInit(DialogPage page)
        {
            var player              = GetPC();
            var playerId            = GetObjectUUID(player);
            var dbPlayerTripleTriad = DB.Get <PlayerTripleTriad>(playerId);
            var model        = GetDataModel <Model>();
            var card         = TripleTriad.GetCardByType(model.SelectedCardType);
            var dateAcquired = dbPlayerTripleTriad.AvailableCards.ContainsKey(model.SelectedCardType)
                ? dbPlayerTripleTriad.AvailableCards[model.SelectedCardType].ToString("yyyy-MM-dd hh:mm:ss")
                : ColorToken.Red("Unacquired");

            page.Header = $"{ColorToken.Green("Name: ")} {card.Name}\n" +
                          $"{ColorToken.Green("Level: ")} {card.Level}\n" +
                          $"{ColorToken.Green("Date Acquired: ")} {dateAcquired}";
        }
        public static void ValidateItemEquip()
        {
            var creature = OBJECT_SELF;
            var item     = StringToObject(Events.GetEventData("ITEM"));

            var error = CanItemBeUsed(creature, item);

            if (string.IsNullOrWhiteSpace(error))
            {
                ApplyEquipTriggers();
                return;
            }

            SendMessageToPC(creature, ColorToken.Red(error));
            Events.SkipEvent();
        }
Exemplo n.º 30
0
        private void MainPageInit(DialogPage page)
        {
            var player   = GetPC();
            var playerId = GetObjectUUID(player);
            var dbPlayer = DB.Get <Player>(playerId);
            var toggleAchievementNotificationText = dbPlayer.Settings.DisplayAchievementNotification ? "Disable Achievement Notification" : "Enable Achievement Notification";

            page.Header =
                ColorToken.Green("Achievement Notifications: ") + (dbPlayer.Settings.DisplayAchievementNotification ? "ENABLED" : "DISABLED") + "\n" +
                "\nYou may adjust your personal character settings here.";

            page.AddResponse("Change Battle Theme", () => ChangePage(ChangeBattleThemeId));
            page.AddResponse(toggleAchievementNotificationText, () =>
            {
                dbPlayer.Settings.DisplayAchievementNotification = !dbPlayer.Settings.DisplayAchievementNotification;
            });
        }
Exemplo n.º 31
0
        public static IList<ColorToken> Trim(this IEnumerable<ColorToken> source, int maxWidth)
        {
            IList<ColorToken> tokens = new List<ColorToken>(source);
            while (tokens.Sum(token => token.Text.Length) > maxWidth)
            {
                tokens = tokens
                    .Reverse()
                    .SkipWhile(token => token.Text.Length == 0)
                    .Reverse()
                    .ToList();

                var oldLastToken = tokens.Last();
                var newLastToken = new ColorToken(
                    oldLastToken.Text.Substring(0, oldLastToken.Text.Length - 1),
                    oldLastToken.Color,
                    oldLastToken.BackgroundColor);

                tokens = tokens.Take(tokens.Count - 1).ToList();
                tokens.Add(newLastToken);
            }

            return tokens;
        }