예제 #1
0
        public GameScene(CCWindow window) : base(window)
        {
            var backgroundLayer = new BackgroundLayer();
            var hudLayer        = new HudLayer();
            var gameplayLayer   = new GameplayLayer(hudLayer.ScoreBox);
            var foregraundLayer = new ForegroundLayer();

            AddChild(backgroundLayer);
            AddChild(gameplayLayer);
            AddChild(foregraundLayer);
            AddChild(hudLayer);
        }
예제 #2
0
        public void GetNextPlayer_ExpiredSession_ReturnsNull()
        {
            var key = Guid.NewGuid();
            var fakeSession = new Session();
            fakeSession.Key = key;
            fakeSession.StartDate = DateTime.MinValue;
            fakeSession.ExpirationDate = DateTime.MinValue;

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession);
            var logic = new GameplayLayer(fakeContext.Object, fakeSession.Key);

            var player = logic.GetNextPlayerKey();

            Assert.IsNull(player);
        }
예제 #3
0
        public void GetNextPlayer_NewSession_ReturnsFirstPlayer()
        {
            var key = Guid.NewGuid();
            var firstPlayer = new PlayerEntity() { Key = Guid.NewGuid() };
            var fakeSession = new Session();
            fakeSession.Key = key;
            fakeSession.StartDate = DateTime.MinValue;
            fakeSession.ExpirationDate = DateTime.MaxValue;
            fakeSession.Players = new List<PlayerEntity>() { firstPlayer };

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession);
            var logic = new GameplayLayer(fakeContext.Object, fakeSession.Key);

            Guid? playerKey = logic.GetNextPlayerKey();

            Assert.AreEqual(firstPlayer.Key, playerKey.Value);
        }
예제 #4
0
        public void GetNextPlayer_SinglePlayedSetPlayed_ReturnsFirstPlayer()
        {
            var sessionKey = Guid.NewGuid();
            var firstPlayer = new PlayerEntity()
            {
                Key = Guid.NewGuid(),
                Id = 1,
            };
            var secondPlayer = new PlayerEntity() { Key = Guid.NewGuid(), Id = 2 };
            var firstSet = new PlayedSet() { PlayedBy = firstPlayer, PlayedById = firstPlayer.Id };

            var fakeSession = new Session();
            fakeSession.Key = sessionKey;
            fakeSession.StartDate = DateTime.MinValue;
            fakeSession.ExpirationDate = DateTime.MaxValue;
            fakeSession.Players = new List<PlayerEntity>() { firstPlayer, secondPlayer };
            fakeSession.PlayedSet = new List<PlayedSet>() { firstSet };

            fakeSession.PlayerOrder = new List<PlayerOrder>() { new PlayerOrder() { Player = firstPlayer, Value = 0, PlayerId = firstPlayer.Id },
                new PlayerOrder{ Player = secondPlayer, Value = 1, PlayerId = secondPlayer.Id }
            };

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(fakeSession);
            var logic = new GameplayLayer(fakeContext.Object, fakeSession.Key);

            Guid? nextPlayerKey = logic.GetNextPlayerKey();

            Assert.AreEqual(secondPlayer.Key, nextPlayerKey.Value);
        }
예제 #5
0
        public void IsValidCardSet_SecondSetSecondRoundMatching_ReturnsTrue()
        {
            var sessionKey = Guid.NewGuid();
            var dummySession = new Session()
            {
                Key = sessionKey,
                PlayedSet = new List<PlayedSet>()
                {
                    new PlayedSet()
                    {
                        PresumedType = CardType.Heart,
                        PresumedTypeId = CardType.HeartId,
                        PlayedHand = "D8",
                        SetNumber = 1,
                        RoundNumber = 1,
                    },
                    new PlayedSet()
                    {
                        PresumedType = CardType.Spade,
                        PresumedTypeId = CardType.SpadeId,
                        PlayedHand = "D7;S8",
                        SetNumber = 1,
                        RoundNumber = 2,
                    },
                },
                SetNumber = 2,
                RoundNumber = 2,
            };

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(dummySession);
            var layer = new GameplayLayer(fakeContext.Object, sessionKey);
            var result = layer.IsValidCardSet(new PlayedSet()
            {
                PresumedType = CardType.Spade,
                PresumedTypeId = CardType.SpadeId,
                PlayedHand = "H1",
            });

            Assert.IsTrue(result);
        }
예제 #6
0
 public void IsValidCardSet_Null_ThrowsException()
 {
     var sessionKey = Guid.NewGuid();
     var fakeContext = new Mock<IBullshitContext>();
     var layer = new GameplayLayer(fakeContext.Object, sessionKey);
     Assert.IsFalse(layer.IsValidCardSet(null));
 }
예제 #7
0
        public void IsValidCardSet_FirstSetFirstRound_ReturnsTrue()
        {
            var sessionKey = Guid.NewGuid();
            var dummySession = new Session()
            {
                Key = sessionKey,
                RoundNumber = 1,
                SetNumber = 1
            };

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(dummySession);
            var layer = new GameplayLayer(fakeContext.Object, sessionKey);
            var result = layer.IsValidCardSet(new PlayedSet()
            {
                PresumedType = CardType.Club,
                PresumedTypeId = CardType.ClubId,
                PlayedHand = "H8",
            });
            Assert.IsTrue(result);
        }
예제 #8
0
        public void IsValidCardSet_BadSet_ReturnsFalse()
        {
            var sessionKey = Guid.NewGuid();
            var dummySession = new Session()
            {
                Key = sessionKey,
            };

            var fakeContext = LogicalHelpers.GetSimpleSessionContext(dummySession);
            var layer = new GameplayLayer(fakeContext.Object, sessionKey);
            var result = layer.IsValidCardSet(new PlayedSet()
            {
            });

            Assert.IsFalse(result);
        }
예제 #9
0
 public GameScene(CCWindow window) : base(window)
 {
     gameplayLayer = new GameplayLayer();
     this.AddChild(gameplayLayer);
 }