public void Draw(Entity entity, int turn) { if (IsLocalPlayer) { UpdateKnownEntitesInDeck(entity.CardId); entity.Info.Hidden = false; } if (!IsLocalPlayer) { if (_game.OpponentEntity?.GetTag(GameTag.MULLIGAN_STATE) == (int)HearthDb.Enums.Mulligan.DEALING) { entity.Info.Mulliganed = true; } else { //This looks hacky but I think this works generically (ie w/o the CthunPrefix check). //Still, I haven't tested it in all the use cases so I'm narrowing it down until Alex can take a look if ((RevealedEntities.Any(x => x.Id == entity.Id) && entity.CardId.StartsWith(CthunPrefix))) { Log("Already had card matching the ID of drawn card " + entity.CardId); } else { entity.Info.Hidden = true; } } } entity.Info.Turn = turn; LastDrawnCardId = entity.CardId; Log(entity); }
private DeckState GetDeckState() { var createdCardsInDeck = Deck.Where(x => x.HasCardId && (x.Info.Created || x.Info.Stolen) && !x.Info.Hidden) .GroupBy(ce => new { ce.CardId, Created = (ce.Info.Created || ce.Info.Stolen), ce.Info.Discarded }) .Select(g => { var card = Database.GetCardFromId(g.Key.CardId); card.Count = g.Count(); card.IsCreated = g.Key.Created; card.HighlightInHand = Hand.Any(ce => ce.CardId == g.Key.CardId); return(card); }); var originalCardsInDeck = DeckList.Instance.ActiveDeckVersion.Cards .Where(x => x.Count > 0) .Select(x => Enumerable.Repeat(x.Id, x.Count)) .SelectMany(x => x).ToList(); var revealedNotInDeck = RevealedEntities.Where(x => (!x.Info.Created || x.Info.OriginalEntityWasCreated == false) && x.IsPlayableCard && (!x.IsInDeck || x.Info.Stolen) && x.Info.OriginalController == Id && !(x.Info.Hidden && (x.IsInDeck || x.IsInHand))).ToList(); var removedFromDeck = new List <string>(); foreach (var e in revealedNotInDeck) { originalCardsInDeck.Remove(e.CardId); if (!e.Info.Stolen || e.Info.OriginalController == Id) { removedFromDeck.Add(e.CardId); } } return(new DeckState(createdCardsInDeck.Concat(originalCardsInDeck.GroupBy(x => x).Select(x => { var card = Database.GetCardFromId(x.Key); card.Count = x.Count(); if (Hand.Any(e => e.CardId == x.Key)) { card.HighlightInHand = true; } return card; })), removedFromDeck.GroupBy(x => x).Select(c => { var card = Database.GetCardFromId(c.Key); card.Count = 0; if (Hand.Any(e => e.CardId == c.Key)) { card.HighlightInHand = true; } return card; }))); }
public List <Card> GetOpponentCardList(bool removeNotInDeck, bool highlightCardsInHand, bool includeCreatedInHand) { if (KnownOpponentDeck == null) { return(RevealedEntities.Where(x => !(x.Info.GuessedCardState == GuessedCardState.None && x.Info.Hidden && (x.IsInDeck || x.IsInHand)) && (x.IsPlayableCard || !x.HasTag(GameTag.CARDTYPE)) && (x.GetTag(GameTag.CREATOR) == 1 || ((!x.Info.Created || (Config.Instance.OpponentIncludeCreated && (x.Info.CreatedInDeck || x.Info.CreatedInHand))) && x.Info.OriginalController == Id) || x.IsInHand || x.IsInDeck) && !CardIds.HiddenCardidPrefixes.Any(y => x.CardId.StartsWith(y)) && !EntityIsRemovedFromGamePassive(x) && !(x.Info.Created && x.IsInSetAside && x.Info.GuessedCardState != GuessedCardState.Guessed)) .GroupBy(e => new { CardId = e.Info.WasTransformed ? e.Info.OriginalCardId : e.CardId, Hidden = (e.IsInHand || e.IsInDeck || (e.IsInSetAside && e.Info.GuessedCardState == GuessedCardState.Guessed)) && e.IsControlledBy(Id), Created = e.Info.Created || (e.Info.Stolen && e.Info.OriginalController != Id), Discarded = e.Info.Discarded && Config.Instance.HighlightDiscarded }) .Select(g => { var card = Database.GetCardFromId(g.Key.CardId); card.Count = g.Count(); card.Jousted = g.Key.Hidden; card.IsCreated = g.Key.Created; card.WasDiscarded = g.Key.Discarded; return card; }).Concat(GetPredictedCardsInDeck(true)).ToSortedCardList()); } var createdInHand = includeCreatedInHand ? CreatedCardsInHand : new List <Card>(); var deckState = GetOpponentDeckState(); var inDeck = deckState.RemainingInDeck.ToList(); var notInDeck = deckState.RemovedFromDeck.Where(x => inDeck.All(c => x.Id != c.Id)).ToList(); var predictedInDeck = GetPredictedCardsInDeck(false).Where(x => inDeck.All(c => x.Id != c.Id)).ToList(); if (!removeNotInDeck) { return(inDeck.Concat(predictedInDeck).Concat(notInDeck).Concat(createdInHand).ToSortedCardList()); } if (highlightCardsInHand) { return(inDeck.Concat(predictedInDeck).Concat(GetHighlightedCardsInHand(inDeck)).Concat(createdInHand).ToSortedCardList()); } return(inDeck.Concat(predictedInDeck).Concat(createdInHand).ToSortedCardList()); }