/// <summary> /// Draws a single card at a location on the player's screen. /// </summary> /// <param name="player">The player to draw for.</param> /// <param name="cardType">The type of card to draw on screen.</param> /// <param name="x">The X coordinate to draw at.</param> /// <param name="y">The Y coordinate to draw at.</param> /// <param name="deckSlot">The deck card slot to draw at (between 1 and 5)</param> private static void DrawCard(uint player, CardType cardType, int x, int y, int deckSlot) { var card = TripleTriad.GetCardByType(cardType); var elementTexture = TripleTriad.GetElementTexture(card.Element); var startId = _idReservation.StartId + (deckSlot * CardParts); var topPower = card.TopPower > 9 ? "A" : card.TopPower.ToString(); var bottomPower = card.BottomPower > 9 ? "A" : card.BottomPower.ToString(); var leftPower = card.LeftPower > 9 ? "A" : card.LeftPower.ToString(); var rightPower = card.RightPower > 9 ? "A" : card.RightPower.ToString(); // Display the power ranks if all of them are greater than zero. if (card.TopPower > 0 && card.BottomPower > 0 && card.LeftPower > 0 && card.RightPower > 0) { PostString(player, topPower, x + 3, y + 1, ScreenAnchor.TopLeft, 1.1f, Gui.ColorWhite, Gui.ColorWhite, startId, Gui.TextName); PostString(player, leftPower + " " + rightPower, x + 2, y + 2, ScreenAnchor.TopLeft, 1.1f, Gui.ColorWhite, Gui.ColorWhite, startId + 1, Gui.TextName); PostString(player, bottomPower, x + 3, y + 3, ScreenAnchor.TopLeft, 1.1f, Gui.ColorWhite, Gui.ColorWhite, startId + 2, Gui.TextName); } // Otherwise assume a card isn't selected. Only display the card deck slot in this case. else { PostString(player, $"Card #{deckSlot}", x + 3, y + 1, ScreenAnchor.TopLeft, 1.1f, Gui.ColorWhite, Gui.ColorWhite, startId, Gui.TextName); } PostString(player, TextureGlyph, x + 10, y + 1, ScreenAnchor.TopLeft, 1.1f, Gui.ColorWhite, Gui.ColorWhite, startId + 3, elementTexture); PostString(player, TextureGlyph, x, y, ScreenAnchor.TopLeft, 1.1f, Gui.ColorWhite, Gui.ColorWhite, startId + 4, card.Texture); PostString(player, TextureGlyph, x, y, ScreenAnchor.TopLeft, 1.1f, Gui.ColorWhite, Gui.ColorWhite, startId + 5, "fnt_card_back"); }
/// <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}"; }
/// <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); }); } }