public static bool PlayerDeckDiscard(string cardId) { if (string.IsNullOrEmpty(cardId)) { return(true); } var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId); if (drawnCard == null) { PlayerDrawn.Add(GetCardFromId(cardId)); } else { drawnCard.Count++; } var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0 && c.IsStolen) ?? PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0); if (deckCard == null) { return(false); } deckCard.Count--; LogDeckChange(false, deckCard, true); if (CanRemoveCard(deckCard)) { PlayerDeck.Remove(deckCard); } return(true); }
public static void PlayerMulligan(string cardId) { PlayerHandCount--; if (string.IsNullOrEmpty(cardId)) { return; } var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId); if (drawnCard != null) { drawnCard.Count--; if (drawnCard.Count < 1) { PlayerDrawn.Remove(drawnCard); } } var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId); if (deckCard != null) { deckCard.Count++; deckCard.InHandCount--; LogDeckChange(false, deckCard, false); } else if (Config.Instance.RemoveCardsFromDeck) { deckCard = GetCardFromId(cardId); PlayerDeck.Add(deckCard); Logger.WriteLine("Added " + deckCard.Name + " to deck (count was 0)", "Game"); } }
//public Dictionary<string, int> PlayerIds; #endregion #region Player #pragma warning disable 4014 public async Task <bool> PlayerDraw(string cardId) { if (string.IsNullOrEmpty(_playingAs)) { //Make sure the value get's cached as early as possible to avoid problems //at the end of a game, in case the hero changes - e.g. to Jaraxxus. PlayingAs.GetType(); } PlayerHandCount++; if (string.IsNullOrEmpty(cardId)) { return(true); } var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId); if (drawnCard != null) { drawnCard.Count++; } else { drawnCard = GetCardFromId(cardId); PlayerDrawn.Add(drawnCard); PlayerDrawnIdsTotal.Add(cardId); } drawnCard.InHandCount++; drawnCard.JustDrawn(); var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0 && c.IsStolen) ?? PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0); if (deckCard == null) { return(false); } deckCard.Count--; deckCard.InHandCount++; LogDeckChange(false, deckCard, true); if (deckCard.Count == 0 && Config.Instance.RemoveCardsFromDeck && !Config.Instance.HighlightCardsInHand) { //wait for just-drawn highlight to be over, then doublecheck (coule be back in deck after e.g.) -> remove await deckCard.JustDrawn(); if (deckCard.Count == 0) { PlayerDeck.Remove(deckCard); Logger.WriteLine("Removed " + deckCard.Name + " from deck (count 0)", "Game"); } } else { deckCard.JustDrawn(); } return(true); }
//public Dictionary<string, int> PlayerIds; #endregion #region Player #pragma warning disable 4014 public async Task <bool> PlayerDraw(string cardId) { PlayerHandCount++; if (string.IsNullOrEmpty(cardId)) { return(true); } var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId); if (drawnCard != null) { drawnCard.Count++; } else { drawnCard = GetCardFromId(cardId); PlayerDrawn.Add(drawnCard); PlayerDrawnIdsTotal.Add(cardId); } drawnCard.InHandCount++; drawnCard.JustDrawn(); var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0 && c.IsStolen) ?? PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.Count > 0); if (deckCard == null) { return(false); } deckCard.Count--; deckCard.InHandCount++; LogDeckChange(false, deckCard, true); if (deckCard.Count == 0 && Config.Instance.RemoveCardsFromDeck && !Config.Instance.HighlightCardsInHand) { //wait for just-drawn highlight to be over, then doublecheck (coule be back in deck after e.g.) -> remove await deckCard.JustDrawn(); if (deckCard.Count == 0) { PlayerDeck.Remove(deckCard); Logger.WriteLine("Removed " + deckCard.Name + " from deck (count 0)", "Game"); } } else { deckCard.JustDrawn(); } return(true); }
#pragma warning restore 4014 public static void PlayerPlayed(string cardId) { PlayerHandCount--; var card = PlayerDeck.FirstOrDefault(c => c.Id == cardId); if (card != null) { card.InHandCount--; if (Config.Instance.HighlightCardsInHand && CanRemoveCard(card)) { PlayerDeck.Remove(card); } } var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId); if (drawnCard != null) { drawnCard.InHandCount--; } }
public static void PlayerGetToDeck(string cardId, int turn) { if (string.IsNullOrEmpty(cardId)) { return; } PlayerDeckSize++; var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.IsStolen); if (deckCard != null) { deckCard.Count++; LogDeckChange(false, deckCard, false); } else { deckCard = GetCardFromId(cardId); deckCard.IsStolen = true; PlayerDeck.Add(deckCard); Logger.WriteLine("Added " + deckCard.Name + " to deck (count was 0)", "Game"); } }
#pragma warning restore 4014 #pragma warning disable 4014 public static void PlayerGet(string cardId, bool fromPlay, int turn) { PlayerHandCount++; if (cardId == "GAME_005" && turn == 0) { OpponentHasCoin = false; OpponentHandMarks[DefaultCoinPosition] = CardMark.None; OpponentHandAge[DefaultCoinPosition] = -1; OpponentStolenCardsInformation[DefaultCoinPosition] = null; Logger.WriteLine("Player got the coin", "Hearthstone"); } var fromSetAside = SetAsideCards.Any(id => cardId == id); if (fromSetAside) { Logger.WriteLine("Got card from setaside: " + cardId, "Game"); foreach (var c in SetAsideCards) { PlayerDeckDiscard(c); } SetAsideCards.Clear(); } var card = PlayerDeck.FirstOrDefault(c => c.Id == cardId && (!c.IsStolen || fromSetAside)); if (card != null) { card.InHandCount++; card.JustDrawn(); } else if (Config.Instance.ShowPlayerGet && !fromPlay) { var drawnCard = PlayerDrawn.FirstOrDefault(c => c.Id == cardId && c.IsStolen); if (drawnCard != null) { drawnCard.Count++; } else { drawnCard = GetCardFromId(cardId); drawnCard.IsStolen = true; PlayerDrawn.Add(drawnCard); } drawnCard.InHandCount++; drawnCard.JustDrawn(); var deckCard = PlayerDeck.FirstOrDefault(c => c.Id == cardId && c.IsStolen); if (deckCard != null) { deckCard.Count++; deckCard.InHandCount++; LogDeckChange(false, deckCard, false); } else { deckCard = GetCardFromId(cardId); deckCard.InHandCount++; deckCard.IsStolen = true; PlayerDeck.Add(deckCard); deckCard.JustDrawn(); } } }