public void Reset(bool resetStats = true) { Logger.WriteLine(">>>>>>>>>>> Reset <<<<<<<<<<<", "Game"); ReplayMaker.Reset(); PlayerDrawn.Clear(); PlayerDrawnIdsTotal.Clear(); Entities.Clear(); PlayerId = -1; OpponentId = -1; SavedReplay = false; PlayerHandCount = 0; PlayerFatigueCount = 0; OpponentSecretCount = 0; OpponentCards.Clear(); OpponentHandCount = 0; OpponentFatigueCount = 0; OpponentDeckCount = 30; PlayerDeckSize = 30; SecondToLastUsedId = null; OpponentHandAge = new int[MaxHandSize]; OpponentHandMarks = new CardMark[MaxHandSize]; OpponentStolenCardsInformation = new Card[MaxHandSize]; OpponentSecrets.ClearSecrets(); NoMatchingDeck = false; _playingAs = null; for (var i = 0; i < MaxHandSize; i++) { OpponentHandAge[i] = -1; OpponentHandMarks[i] = CardMark.None; } // Assuming opponent has coin, corrected if we draw it OpponentHandMarks[DefaultCoinPosition] = CardMark.Coin; OpponentHandAge[DefaultCoinPosition] = 0; OpponentHasCoin = true; SetAsideCards.Clear(); OpponentReturnedToDeck.Clear(); //if(CurrentGameMode == GameMode.Ranked) //otherwise switching from playing ranked to casual causes problems // CurrentGameMode = GameMode.Casual; if (!IsInMenu && resetStats) { if (CurrentGameMode != GameMode.Spectator) { CurrentGameMode = GameMode.None; } CurrentGameStats = new GameStats(GameResult.None, PlayingAgainst, PlayingAs) { PlayerName = PlayerName, OpponentName = OpponentName, Region = CurrentRegion }; } hsLogLines = new List <string>(); }
//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); }
public 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)); PlayerDrawnIdsTotal.Add(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); }