Ejemplo n.º 1
0
        public void AfterHumanChoosesHit_NextCardIsAddedToHisCardsAtHand()
        {
            //arrange
            var consoleOperations = new Mock <IConsoleOperations>();
            var playerHuman       = new PlayerHuman(consoleOperations.Object, "d");

            consoleOperations.Setup(s => s.Read()).Returns("1");
            var humanPlayers = new List <IPlayer>()
            {
                playerHuman
            };
            var randomChooser = new Mock <IRandomChooser>();

            randomChooser.SetupSequence(s => s.RandomNumber(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(10)
            .Returns(12)
            .Returns(13);

            var game = new Game(consoleOperations.Object, humanPlayers, randomChooser.Object);



            //act
            game.Start();


            var score = game.GetScoreFor(playerHuman);

            //assert

            Assert.AreEqual(24, score); //why its zero?
        }
Ejemplo n.º 2
0
        public void WhenHumanPlayersGoesOver21_DealerWins()
        {
            //arrange
            var consoleOperations = new Mock <IConsoleOperations>();
            var playerHuman       = new PlayerHuman(consoleOperations.Object, "d");
            var playerHumanList   = new List <IPlayer>()
            {
                playerHuman
            };
            var randomChooser = new Mock <IRandomChooser>();

            randomChooser.SetupSequence(s => s.RandomNumber(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(10)
            .Returns(12)
            .Returns(13);
            var game = new Game(consoleOperations.Object, playerHumanList, randomChooser.Object);

            consoleOperations.Setup(s => s.Read()).Returns("1");

            //act
            game.Start();


            //assert
            consoleOperations.Verify(
                m => m.Write(It.Is <string>(c => c == "Dealer wins!")));
        }
Ejemplo n.º 3
0
        public void WinnerHasTheHighestScore()
        {
            //arrange
            var consoleOperations = new Mock <IConsoleOperations>();
            var playerHuman       = new PlayerHuman(consoleOperations.Object, "1");
            var playerHuman2      = new PlayerHuman(consoleOperations.Object, "2");
            var playerComputer    = new PlayerComputer(consoleOperations.Object);
            var playerHumanList   = new List <IPlayer>()
            {
                playerHuman, playerHuman2
            };

            var mockRandomChooser = new Mock <IRandomChooser>();

            mockRandomChooser.SetupSequence(s => s.RandomNumber(It.IsAny <int>(), It.IsAny <int>()))
            .Returns(10).Returns(12).Returns(13);

            consoleOperations.SetupSequence(s => s.Read()).Returns("1").Returns("0").Returns("0");

            var game = new Game(consoleOperations.Object, playerHumanList, mockRandomChooser.Object);


            //act
            game.Start();


            //assert
            //Assert.Contains(); how to test that?
            consoleOperations.Verify(
                m => m.Write(It.Is <string>(c => c == "Dealer wins !")));
        }
        public void HavePlayerSymbolWhenNew()
        {
            string symbol = "X";
            Player player = new PlayerHuman(symbol);

            Assert.AreEqual(player.GetPlayerSymbol(false), symbol);
        }
        public void ReturnPlayerSymbolWithPadding()
        {
            string symbol = "X";
            int    length = symbol.Length;
            Player player = new PlayerHuman(symbol);

            Assert.IsTrue(player.GetPlayerSymbol().Length > length);
        }
Ejemplo n.º 6
0
        public override void Initialize()
        {
            // setup players
            var humanPlayer = new PlayerHuman();

            // setup map/board
            Globals.Instance.GameWorld.Intialize(200, 160, humanPlayer, null);

            //humanPlayer.UnitMoved += Player_UnitMoved;
            //humanPlayer.TurnEnded += Player_TurnEnded;
            //humanPlayer.AddSettlement("Margeritaville", Point2.Create(1, 1), Globals.Instance.RaceTypes[0]);
            humanPlayer.AddUnit(4, Point2.Create(2, 2)); // cavalry
            humanPlayer.AddUnit(0, Point2.Create(0, 1)); // spearman
            humanPlayer.StartTurn();

            _hud = new Hud(Game);
            _hud.Initialize();
            _gameMapView = new GameMapView(Globals.Instance.GameWorld, new Rectangle(0, 0, Game.GraphicsDevice.Viewport.Width, Game.GraphicsDevice.Viewport.Height), _hud);
            _unitsView   = new UnitsView(Globals.Instance.GameWorld);

            Globals.Instance.GameWorld.StartTurnForHumanPlayer();
        }
Ejemplo n.º 7
0
    public TicTacToeEngine(Grid2DComponent grid, Player p1, Player p2)
    {
        this.grid = grid;

        CreateGameBoard( );

        p1_X = p1 as PlayerComputer;
        p2_O = p2 as PlayerHuman;
        p1_X.IsTurnActive = false;
        p2_O.IsTurnActive = true;

        audioplayer = MonoBehaviour.FindObjectOfType <SFXMasterController> ( ).GetComponent <AudioSource> ( );
        zeroedVol   = audioplayer.volume;

        sfxvictorymusic = Resources.Load <AudioClip> (ResourcePath.onWinSoundClip);
        sfxgameover     = Resources.Load <AudioClip> (ResourcePath.sfxGameOver);
        sfxwinner       = Resources.Load <AudioClip> (ResourcePath.sfxWinner);

        sfxscribblebank = SFXMasterController.LoadScribbleSFX( );

        SFXMasterController.PlayReadyClip( );
    }