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");
                }
            }
        }
        /// <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);
                });
            }
        }
        /// <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));
            });
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
        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();
            });
        }
Exemple #7
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();
                    });
                }
            }
        }
Exemple #9
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;
                });
            }
        }
        /// <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);
            });
        }
Exemple #11
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);
                });
            }
        }
Exemple #12
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);
        }
        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);
            }
        }
        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));
        }
Exemple #15
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);
                });
            }
        }
        /// <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}";
        }
        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;
        }
Exemple #18
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;
            });
        }
        /// <summary>
        /// Handles the card selection logic for deck building.
        /// This differs from the card viewer in that cards show based on which cards the player owns.
        /// </summary>
        /// <param name="page">The page to build.</param>
        private void DeckCardSelectionListPageInit(DialogPage page)
        {
            var player              = GetPC();
            var playerId            = GetObjectUUID(player);
            var dbPlayerTripleTriad = DB.Get <PlayerTripleTriad>(playerId);
            var model        = GetDataModel <Model>();
            var cardsAtLevel = TripleTriad.GetAllCardsAtLevel(model.SelectedCardLevel);

            page.Header = $"{ColorToken.Green("Level: ")} {model.SelectedCardLevel}\n\n" +
                          "Please select cards to add to this deck.";

            if (model.CurrentCardNumber > 1)
            {
                page.AddResponse(ColorToken.Red("Remove Card"), RemoveTopMostCard);
            }

            foreach (var(cardType, card) in cardsAtLevel)
            {
                if (!card.IsVisibleInMenu)
                {
                    continue;
                }

                // Only one of each card type can be added to decks.
                if (IsInActiveDeck(cardType))
                {
                    continue;
                }

                if (dbPlayerTripleTriad.AvailableCards.ContainsKey(cardType))
                {
                    page.AddResponse($"Add: {card.Name}", () =>
                    {
                        SetLocalInt(player, $"CARD_MENU_DECK_CARD_{model.CurrentCardNumber}", (int)cardType);
                        model.CurrentCardNumber++;

                        // This was the last card.
                        if (model.CurrentCardNumber > 5)
                        {
                            ChangePage(DeckCardSelectionConfirmDeckPageId);
                        }
                    });
                }
            }
        }
        private void MovePageInit(DialogPage page)
        {
            var player = GetPC();
            var model  = GetDataModel <Model>();

            void Move(float x, float y, float z)
            {
                var position = GetPosition(model.Placeable);

                position.X += x;
                position.Y += y;
                position.Z += z;

                if (position.Z > 10f)
                {
                    position.Z = 10f;
                }
                else if (position.Z < -10f)
                {
                    position.Z = -10f;
                }

                Object.SetPosition(model.Placeable, position);

                var furnitureId = GetLocalString(model.Placeable, "HOUSING_FURNITURE_ID");
                var dbHouse     = DB.Get <PlayerHouse>(model.OwnerUUID);

                dbHouse.Furnitures[furnitureId].X = position.X;
                dbHouse.Furnitures[furnitureId].Y = position.Y;
                dbHouse.Furnitures[furnitureId].Z = position.Z;

                DB.Set(model.OwnerUUID, dbHouse);
            }

            page.Header = ColorToken.Green("Move Furniture") + "\n\n";

            page.AddResponse("Move North", () => Move(0f, 0.2f, 0f));
            page.AddResponse("Move South", () => Move(0f, -0.2f, 0f));
            page.AddResponse("Move East", () => Move(0.2f, 0f, 0f));
            page.AddResponse("Move West", () => Move(-0.2f, 0f, 0f));
            page.AddResponse("Move Up", () => Move(0f, 0f, 0.1f));
            page.AddResponse("Move Down", () => Move(0f, 0f, -0.1f));
        }
        private void RotatePageInit(DialogPage page)
        {
            var model = GetDataModel <Model>();

            void Rotate(float degrees, bool set = false)
            {
                var facing = GetFacing(model.Placeable);

                if (set)
                {
                    facing = degrees;
                    AssignCommand(model.Placeable, () => SetFacing(facing));
                }
                else
                {
                    facing += degrees;
                    AssignCommand(model.Placeable, () => SetFacing(facing));
                }

                var dbHouse     = DB.Get <PlayerHouse>(model.OwnerUUID);
                var furnitureId = GetLocalString(model.Placeable, "HOUSING_FURNITURE_ID");

                dbHouse.Furnitures[furnitureId].Orientation = facing;
                DB.Set(model.OwnerUUID, dbHouse);
            }

            page.Header = ColorToken.Green("Rotate Furniture") + "\n\n" +
                          ColorToken.Green("Current Facing: ") + GetFacing(model.Placeable) + " degrees";

            page.AddResponse("Face North", () => Rotate(90f, true));
            page.AddResponse("Face South", () => Rotate(270f, true));
            page.AddResponse("Face East", () => Rotate(0f, true));
            page.AddResponse("Face West", () => Rotate(180f, true));

            page.AddResponse("20 degrees", () => Rotate(20f));
            page.AddResponse("30 degrees", () => Rotate(30f));
            page.AddResponse("45 degrees", () => Rotate(45f));
            page.AddResponse("60 degrees", () => Rotate(60f));
            page.AddResponse("75 degrees", () => Rotate(75f));
            page.AddResponse("90 degrees", () => Rotate(90f));
            page.AddResponse("180 degrees", () => Rotate(180f));
        }
Exemple #22
0
        private void SongDetailInit(DialogPage page)
        {
            var model                = GetDataModel <Model>();
            var player               = GetPC();
            var playerId             = GetObjectUUID(player);
            var dbPlayer             = DB.Get <Player>(playerId);
            var currentBattleThemeId = dbPlayer.Settings.BattleThemeId;
            var battleSongs          = Music.GetBattleSongs();
            var header               = ColorToken.Green("Current Battle Theme: ");

            if (currentBattleThemeId == null)
            {
                header += "(Area determines theme)";
            }
            else
            {
                var song = battleSongs[(int)currentBattleThemeId];
                header += song.DisplayName;
            }

            page.Header = header + "\n\n" +
                          ColorToken.Green("Selecting Theme: ") + battleSongs[model.SelectedBattleThemeId].DisplayName;

            page.AddResponse("Preview Song", () =>
            {
                var area = GetArea(player);
                model.CurrentDayTimeTheme   = MusicBackgroundGetDayTrack(area);
                model.CurrentNightTimeTheme = MusicBackgroundGetNightTrack(area);

                Core.NWNX.Player.MusicBackgroundChangeTimeToggle(player, model.SelectedBattleThemeId, false);
                Core.NWNX.Player.MusicBackgroundChangeTimeToggle(player, model.SelectedBattleThemeId, true);
            });

            page.AddResponse("Select Song", () =>
            {
                dbPlayer.Settings.BattleThemeId = model.SelectedBattleThemeId;
                DB.Set(playerId, dbPlayer);

                Core.NWNX.Player.MusicBattleChange(player, model.SelectedBattleThemeId);
            });
        }
        /// <summary>
        /// Handles the card selection level logic for deck building.
        /// This differs from the card viewer in that levels show based on which cards the player owns.
        /// </summary>
        /// <param name="page">The page to build.</param>
        private void DeckCardSelectionLevelsPageInit(DialogPage page)
        {
            var player              = GetPC();
            var playerId            = GetObjectUUID(player);
            var dbPlayerTripleTriad = DB.Get <PlayerTripleTriad>(playerId);
            var model  = GetDataModel <Model>();
            var levels = new HashSet <int>();

            page.Header = "Please select cards to add to this deck.";

            if (model.CurrentCardNumber > 1)
            {
                page.AddResponse(ColorToken.Red("Remove Card"), RemoveTopMostCard);
            }

            foreach (var(cardType, _) in dbPlayerTripleTriad.AvailableCards)
            {
                var card = TripleTriad.GetCardByType(cardType);

                if (!card.IsVisibleInMenu)
                {
                    continue;
                }

                if (!levels.Contains(card.Level))
                {
                    levels.Add(card.Level);
                }
            }

            page.Header = $"{ColorToken.Green("Select card #")} {model.CurrentCardNumber}";

            foreach (var level in levels)
            {
                page.AddResponse($"Level {level}", () =>
                {
                    model.SelectedCardLevel = level;
                    ChangePage(DeckCardSelectionListPageId);
                });
            }
        }
        private void MainPageInit(DialogPage page)
        {
            var player             = GetPC();
            var cdKey              = GetPCPublicCDKey(player);
            var account            = DB.Get <Account>(cdKey) ?? new Account();
            var achievements       = account.Achievements;
            var activeAchievements = Achievement.GetActiveAchievements();
            var model              = GetDataModel <Model>();

            foreach (var achievement in activeAchievements)
            {
                var text = achievements.ContainsKey(achievement.Key) ?
                           ColorToken.Green(achievement.Value.Name) :
                           ColorToken.Red(achievement.Value.Name);
                page.AddResponse(text, () =>
                {
                    model.Type = achievement.Key;
                    ChangePage(AchievementDetailId);
                });
            }
        }
Exemple #25
0
        /// <summary>
        /// Loads the main page header and response options.
        /// </summary>
        /// <param name="page">The dialog page to adjust.</param>
        private void MainPageInit(DialogPage page)
        {
            var player   = GetPC();
            var playerId = GetObjectUUID(player);
            var hasHouse = DB.Exists <PlayerHouse>(playerId);

            // Player currently owns a house.
            // Provide options to adjust existing house.
            if (hasHouse)
            {
                var house  = DB.Get <PlayerHouse>(playerId);
                var detail = Housing.GetHouseTypeDetail(house.HouseType);

                page.Header = ColorToken.Green("Layout Type: ") + detail.Name + "\n" +
                              ColorToken.Green("Furniture Limit: ") + house.Furnitures.Count + " / " + detail.FurnitureLimit + "\n\n" +
                              "What would you like to do?";

                page.AddResponse("Enter", () =>
                {
                    var instance         = Housing.LoadPlayerHouse(playerId);
                    var entrancePosition = Housing.GetEntrancePosition(house.HouseType);
                    var location         = Location(instance, entrancePosition, 0.0f);
                    Housing.StoreOriginalLocation(player);

                    AssignCommand(player, () => ActionJumpToLocation(location));
                });

                page.AddResponse("Sell Home", () =>
                {
                    ChangePage(SellHousePageId);
                });
            }
            // Player doesn't own a house.
            // Provide options to buy one.
            else
            {
                PurchaseHouseLayoutListPageInit(page);
            }
        }
        private void AchievementDetailInit(DialogPage page)
        {
            var player             = GetPC();
            var cdKey              = GetPCPublicCDKey(player);
            var account            = DB.Get <Account>(cdKey) ?? new Account();
            var activeAchievements = Achievement.GetActiveAchievements();
            var model              = GetDataModel <Model>();
            var achievement        = activeAchievements[model.Type];

            page.Header = ColorToken.Green("Name: ") + achievement.Name + "\n" +
                          ColorToken.Green("Description: ") + achievement.Description + "\n\n";

            if (account.Achievements.ContainsKey(model.Type))
            {
                var pcAchievement = account.Achievements[model.Type];
                page.Header += ColorToken.Green("Unlocked: ") + pcAchievement.ToString("yyyy-MM-dd hh:mm:ss");
            }
            else
            {
                page.Header += ColorToken.Red("Not yet acquired.");
            }
        }
        /// <summary>
        /// Handles main page logic.
        /// </summary>
        /// <param name="page">The page to build</param>
        private void MainPageInit(DialogPage page)
        {
            var player = GetPC();

            page.Header = ColorToken.Green("Triple Triad Menu");

            page.AddResponse("View Cards", () =>
            {
                SetLocalInt(player, "CARD_MENU_CURRENT_MODE", (int)Mode.CardViewer);
                ChangePage(ViewCardLevelsPageId);
            });
            page.AddResponse("Manage Decks", () =>
            {
                if (TripleTriad.DoesPlayerHavePendingGame(player))
                {
                    FloatingTextStringOnCreature("Decks cannot be managed while you have a game reservation pending. Cancel the reservation to manage your decks.", player, false);
                    return;
                }

                ChangePage(DeckListPageId);
            });
        }
Exemple #28
0
        private void ChangeBattleThemeInit(DialogPage page)
        {
            var model                = GetDataModel <Model>();
            var player               = GetPC();
            var playerId             = GetObjectUUID(player);
            var dbPlayer             = DB.Get <Player>(playerId);
            var currentBattleThemeId = dbPlayer.Settings.BattleThemeId;
            var battleSongs          = Music.GetBattleSongs();
            var header               = ColorToken.Green("Current Battle Theme: ");

            if (currentBattleThemeId == null)
            {
                header += "(Area determines theme)";
            }
            else
            {
                var song = battleSongs[(int)currentBattleThemeId];
                header += song.DisplayName;
            }

            page.Header = header;

            page.AddResponse(ColorToken.Green("Use Area Theme"), () =>
            {
                dbPlayer.Settings.BattleThemeId = null;
                Core.NWNX.Player.MusicBattleChange(player, 0);
                DB.Set(playerId, dbPlayer);
            });

            foreach (var song in battleSongs)
            {
                page.AddResponse(song.Value.DisplayName, () =>
                {
                    model.SelectedBattleThemeId = song.Key;
                    ChangePage(SongDetailId);
                });
            }
        }
Exemple #29
0
        /// <summary>
        /// Builds text used by the /help command for each authorization level.
        /// This must be called after LoadChatCommands or there will be nothing to process.
        /// </summary>
        private static void BuildHelpText()
        {
            foreach (var command in ChatCommands)
            {
                var text       = command.Key;
                var definition = command.Value;

                if (definition.Permissions.HasFlag(CommandPermissionType.Player))
                {
                    HelpTextPlayer += ColorToken.Green("/" + text) + ColorToken.White(": " + definition.Description) + "\n";
                }

                if (definition.Permissions.HasFlag(CommandPermissionType.Player))
                {
                    HelpTextDM += ColorToken.Green("/" + text) + ColorToken.White(": " + definition.Description) + "\n";
                }

                if (definition.Permissions.HasFlag(CommandPermissionType.Player))
                {
                    HelpTextAdmin += ColorToken.Green("/" + text) + ColorToken.White(": " + definition.Description) + "\n";
                }
            }
        }
        /// <summary>
        /// Handles the deck name change logic.
        /// </summary>
        /// <param name="page">The page to build</param>
        private void ChangeDeckNamePageInit(DialogPage page)
        {
            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();
            var deckName         = string.IsNullOrWhiteSpace(deck.Name) ? "[None]" : deck.Name;
            var selectedDeckName = GetLocalString(player, "CARD_MENU_DECK_NAME");
            var newDeckName      = selectedDeckName;

            if (string.IsNullOrWhiteSpace(newDeckName))
            {
                newDeckName = ColorToken.Yellow("[NO CHANGE]");
            }

            page.Header = $"{ColorToken.Green("Current Deck Name: ")} {deckName}\n" +
                          $"{ColorToken.Green("New Deck Name: ")} {newDeckName}\n\n" +
                          $"Please type the new name of your deck into the chat bar. Note that deck names may be no longer than {MaxDeckNameLength} characters. Use 'Refresh' to see the changes. Use 'Set Name' to confirm the change.";

            page.AddResponse(ColorToken.Green("Refresh"), () => { });

            if (!string.IsNullOrWhiteSpace(selectedDeckName))
            {
                page.AddResponse("Set Name", () =>
                {
                    deck.Name = selectedDeckName;
                    DeleteLocalString(player, "CARD_MENU_DECK_NAME");

                    DB.Set(playerId, dbPlayerTripleTriad);
                });
            }

            SetLocalBool(player, "CARD_MENU_LISTENING_FOR_NAME_CHANGE", true);
        }