예제 #1
0
        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>();
        }
예제 #2
0
        public static void OpponentPlay(string id, int from, int turn)
        {
            OpponentHandCount--;

            if (id == "GAME_005")
            {
                OpponentHasCoin = false;
            }
            if (!string.IsNullOrEmpty(id))
            {
                //key: cardid, value: turn when returned to deck
                var wasReturnedToDeck = OpponentReturnedToDeck.Any(p => p.Key == id && p.Value <= OpponentHandAge[from - 1]);
                var stolen            = from != -1 &&
                                        (OpponentHandMarks[from - 1] == CardMark.Stolen || OpponentHandMarks[from - 1] == CardMark.Returned ||
                                         wasReturnedToDeck);
                var card = OpponentCards.FirstOrDefault(c => c.Id == id && c.IsStolen == stolen && !c.WasDiscarded);

                //card can't be marked stolen or returned, since it was returned to the deck
                if (wasReturnedToDeck && stolen &&
                    !(OpponentHandMarks[from - 1] == CardMark.Stolen || OpponentHandMarks[from - 1] == CardMark.Returned))
                {
                    OpponentReturnedToDeck.Remove(OpponentReturnedToDeck.First(p => p.Key == id && p.Value <= OpponentHandAge[from - 1]));
                }

                if (card != null)
                {
                    card.Count++;
                }
                else
                {
                    card          = GetCardFromId(id);
                    card.IsStolen = stolen;
                    OpponentCards.Add(card);
                }

                LogDeckChange(true, card, false);

                if (card.IsStolen)
                {
                    Logger.WriteLine("Opponent played stolen card from " + from, "Game");
                }
            }

            for (var i = from - 1; i < MaxHandSize - 1; i++)
            {
                OpponentHandAge[i]   = OpponentHandAge[i + 1];
                OpponentHandMarks[i] = OpponentHandMarks[i + 1];
                OpponentStolenCardsInformation[i] = OpponentStolenCardsInformation[i + 1];
            }

            OpponentHandAge[MaxHandSize - 1]   = -1;
            OpponentHandMarks[MaxHandSize - 1] = CardMark.None;
            OpponentStolenCardsInformation[MaxHandSize - 1] = null;


            LogOpponentHand();
        }
예제 #3
0
        public static void OpponentPlayToDeck(string cardId, int turn)
        {
            OpponentDeckCount++;

            if (string.IsNullOrEmpty(cardId))
            {
                return;
            }

            OpponentReturnedToDeck.Add(new KeyValuePair <string, int>(cardId, turn));
        }