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(); }); } } }
public static void SimulateTripleTriad() { var player1 = GetFirstPC(); var player2 = GetNextPC(); // Single player mode if (!GetIsObjectValid(player2)) { var player = GetLastUsedBy(); var deck1 = TripleTriad.BuildRandomDeck(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); var deck2 = TripleTriad.BuildRandomDeck(10, 9, 8, 7); TripleTriad.StartGame(player, deck1, player, deck2); } // Two player mode else { var deck1 = TripleTriad.BuildRandomDeck(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); var deck2 = TripleTriad.BuildRandomDeck(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); TripleTriad.StartGame(player1, deck1, player2, deck2); } }
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 }); } } } }