コード例 #1
0
        public void GameType_Format()
        {
            var game = new MockGame
            {
                CurrentGameType = GameType.GT_RANKED,
                CurrentFormat   = Format.Wild
            };

            var settings       = new MockArenaSettings();
            var secretsManager = new SecretsManager(game, settings);

            var paladinEntity = new Entity(0);

            paladinEntity.SetTag(GameTag.SECRET, 1);
            paladinEntity.SetTag(GameTag.CLASS, (int)CardClass.PALADIN);
            secretsManager.NewSecret(paladinEntity);
            Assert.AreEqual(1, secretsManager.Secrets.Count);

            var mageEntity = new Entity(1);

            mageEntity.SetTag(GameTag.SECRET, 1);
            mageEntity.SetTag(GameTag.CLASS, (int)CardClass.MAGE);
            secretsManager.NewSecret(mageEntity);
            Assert.AreEqual(2, secretsManager.Secrets.Count);

            var hunterEntity = new Entity(2);

            hunterEntity.SetTag(GameTag.SECRET, 1);
            hunterEntity.SetTag(GameTag.CLASS, (int)CardClass.HUNTER);
            secretsManager.NewSecret(hunterEntity);
            Assert.AreEqual(3, secretsManager.Secrets.Count);

            var allSecrets = Paladin.All.Where(x => x != Paladin.HandOfSalvation)
                             .Concat(Mage.All).Concat(Hunter.All).ToList();
            var cards = secretsManager.GetSecretList();

            Assert.AreEqual(allSecrets.Count, cards.Count);
            foreach (var secret in allSecrets)
            {
                Assert.IsNotNull(cards.SingleOrDefault(c => secret == c.Id));
            }

            game.CurrentFormat = Format.Standard;
            cards = secretsManager.GetSecretList();
            var standardSecrets = allSecrets.Where(x => x.IsStandard).ToList();

            Assert.AreEqual(standardSecrets.Count(), cards.Count);
            foreach (var secret in standardSecrets)
            {
                Assert.IsNotNull(cards.SingleOrDefault(c => secret == c.Id));
            }

            game.CurrentGameType = GameType.GT_ARENA;
            game.CurrentFormat   = Format.Wild;           // Arena format is Wild
            cards = secretsManager.GetSecretList();
            var bannedSecrets = settings.BannedSecrets.Select(x => new MultiIdCard(x));
            var arenaSecrets  = allSecrets.Concat(settings.ExclusiveSecrets.Select(x => new MultiIdCard(x))).Where(x =>
                                                                                                                   settings.CurrentSets.Any(x.HasSet) && !bannedSecrets.Contains(x)
                                                                                                                   ).ToList();

            Assert.AreEqual(arenaSecrets.Count, cards.Count);
            foreach (var secret in arenaSecrets)
            {
                Assert.IsNotNull(cards.SingleOrDefault(c => secret == c.Id));
            }
        }
コード例 #2
0
ファイル: SecretsManagerTest.cs プロジェクト: ikjin2/hdt
        public void GameType_Format()
        {
            var game = new MockGame
            {
                CurrentGameType = GameType.GT_RANKED,
                CurrentFormat   = Format.Wild
            };

            var arenaSettings  = new MockArenaSettings();
            var pvpdrSettings  = new MockPVPDRSettings();
            var secretsManager = new SecretsManager(game, arenaSettings, pvpdrSettings);

            var paladinEntity = new Entity(0);

            paladinEntity.SetTag(GameTag.SECRET, 1);
            paladinEntity.SetTag(GameTag.CLASS, (int)CardClass.PALADIN);
            secretsManager.NewSecret(paladinEntity);
            Assert.AreEqual(1, secretsManager.Secrets.Count);

            var mageEntity = new Entity(1);

            mageEntity.SetTag(GameTag.SECRET, 1);
            mageEntity.SetTag(GameTag.CLASS, (int)CardClass.MAGE);
            secretsManager.NewSecret(mageEntity);
            Assert.AreEqual(2, secretsManager.Secrets.Count);

            var hunterEntity = new Entity(2);

            hunterEntity.SetTag(GameTag.SECRET, 1);
            hunterEntity.SetTag(GameTag.CLASS, (int)CardClass.HUNTER);
            secretsManager.NewSecret(hunterEntity);
            Assert.AreEqual(3, secretsManager.Secrets.Count);

            var wildSecrets = Paladin.All.Where(x => x != Paladin.HandOfSalvation)
                              .Concat(Mage.All).Concat(Hunter.All).ToList();
            var cards = secretsManager.GetSecretList();

            Assert.AreEqual(wildSecrets.Count, cards.Count);
            foreach (var secret in wildSecrets)
            {
                Assert.IsNotNull(cards.SingleOrDefault(c => c.Id == secret));
            }

            game.CurrentFormat = Format.Standard;
            cards = secretsManager.GetSecretList();
            var wildSets        = Helper.WildOnlySets;
            var standardSecrets = wildSecrets.Where(x => !wildSets.Contains(Database.GetCardFromId(x).Set)).ToList();

            Assert.AreEqual(standardSecrets.Count, cards.Count);
            foreach (var secret in standardSecrets)
            {
                Assert.IsNotNull(cards.SingleOrDefault(c => c.Id == secret));
            }

            game.CurrentGameType = GameType.GT_ARENA;
            game.CurrentFormat   = Format.Wild;           // Arena format is Wild
            cards = secretsManager.GetSecretList();
            var arenaSecrets = wildSecrets.Concat(arenaSettings.ExclusiveSecrets).Where(x =>
                                                                                        arenaSettings.CurrentSets.Contains(Database.GetCardFromId(x).CardSet ?? CardSet.BLANK) &&
                                                                                        !arenaSettings.BannedSecrets.Contains(x)
                                                                                        ).ToList();

            Assert.AreEqual(arenaSecrets.Count, cards.Count);
            foreach (var secret in arenaSecrets)
            {
                Assert.IsNotNull(cards.SingleOrDefault(c => c.Id == secret));
            }
        }