public void DefunctStrike_WillDecreaseBlackCoins_FromBoard()
        {
            Player player = new Player("Player 1");

            Utility.ResetBoard();
            Utility.StrikeForNTimes(player, DefunctStrike, 1);

            InterLocked.GetBlackCoins().Should().Be(8);
        }
        public void SingleStrike_WillAddOnePoint_ForPlayer()
        {
            Player player = new Player("Player 1");

            Utility.ResetBoard();
            Utility.StrikeForNTimes(player, SingleStrike, 1);

            player.Points.Should().Be(1);
            InterLocked.GetBlackCoins().Should().Be(8);
        }
        public void Strike(Player player)
        {
            if (InterLocked.GetBlackCoins() == 0)
            {
                throw new NoCoinException(Constants.Exceptions.Messages.NoCoins);
            }

            InterLocked.DecrementBlackCoins();
            player.Fouls++;
            player.Points -= 2;

            if (player.Fouls == 3)
            {
                player.Points--;
                player.Fouls = 0;
            }
        }
示例#4
0
 internal static void ResetBoard()
 {
     InterLocked.SetBlackCoins(9);
     InterLocked.SetRedCoins(1);
 }
 public void Stop()
 {
     // safely communicate between threads.
     InterLocked.Exchange(ref _active, 0);
 }