/// <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); }
private void MainPageInit(DialogPage page) { var player = GetPC(); var playerId = GetObjectUUID(player); var dbPlayerTripleTriad = DB.Get <PlayerTripleTriad>(playerId); var model = GetDataModel <Model>(); var deckSelected = ColorToken.Yellow("[NO DECK SELECTED]"); if (model.SelectedDeckId > 0) { var deck = dbPlayerTripleTriad.Decks[model.SelectedDeckId]; deckSelected = string.IsNullOrWhiteSpace(deck.Name) ? $"Deck #{model.SelectedDeckId}" : deck.Name; } page.Header = "You can create or join Triple Triad games here. You can customize your decks and view your cards from the rest menu (press 'R') or by clicking 'View Cards' here.\n\n" + ColorToken.Green("Deck: ") + deckSelected; page.AddResponse(ColorToken.Green("Refresh"), () => { }); page.AddResponse("View Cards", () => SwitchConversation(nameof(TripleTriadPlayerDialog))); // Player has a game reservation. Give them the option to close it. if (TripleTriad.DoesPlayerHavePendingGame(player)) { if (model.IsConfirming) { page.AddResponse("CONFIRM CANCEL RESERVATION", () => { model.IsConfirming = false; if (TripleTriad.DoesPlayerHavePendingGame(player)) { TripleTriad.RemovePlayerPendingGame(player); } FloatingTextStringOnCreature("Game reservation has been cancelled.", player, false); }); } else { page.AddResponse("Cancel Game Reservation", () => { model.IsConfirming = true; }); } } // Otherwise let them create a new game or join someone else's game. else { page.AddResponse("Select Deck", () => { ChangePage(SelectDeckPageId); }); if (model.SelectedDeckId > 0) { var deck = dbPlayerTripleTriad.Decks[model.SelectedDeckId]; page.AddResponse("Create New Game", () => { TripleTriad.CreatePendingGame(player, new CardPendingGame { Player1Deck = deck }); EndConversation(); FloatingTextStringOnCreature("Game has been created. Please wait for another player to join. Leaving the area or server will remove your game reservation.", player, false); }); foreach (var(gameOwner, pendingGame) in TripleTriad.GetAllPendingGames()) { page.AddResponse($"Join Game: {GetName(gameOwner)}", () => { if (!TripleTriad.DoesPlayerHavePendingGame(gameOwner) || // Game no longer exists !GetIsObjectValid(gameOwner) || // Game owner is no longer valid GetTag(GetArea(gameOwner)) == "tt_arena") // Game owner has entered a game { FloatingTextStringOnCreature("This game is no longer available.", player, false); return; } EndConversation(); TripleTriad.StartGame(gameOwner, pendingGame.Player1Deck, player, deck); // todo: rule config }); } } } }