Пример #1
0
        public PlayerStats(Player player)
        {
            Name = player.Name;
            Chair = player.Chair;
            Color = player.Color;
            Mode = player.Mode;
            ReadyToStart = player.ReadyToStart;

            TappedTools = new List<Tool>();
            UntappedTools = new List<Tool>();

            if (player.PlayerBoard == null)
                return;
            Food = player.PlayerBoard.Food;
            FoodTrack = player.PlayerBoard.FoodTrack;
            PeopleToPlace = player.PlayerBoard.PeopleToPlace;
            TotalPeople = player.PlayerBoard.TotalPeople;
            Score = player.PlayerBoard.Score;

            Wood = player.PlayerBoard.Resources[Resource.Wood];
            Brick = player.PlayerBoard.Resources[Resource.Brick];
            Stone = player.PlayerBoard.Resources[Resource.Stone];
            Gold = player.PlayerBoard.Resources[Resource.Gold];

            AddTappedTool(player, 0);
            AddTappedTool(player, 1);
            AddTappedTool(player, 2);
        }
Пример #2
0
        public void NewPlayerStartsWithDefaults()
        {
            var player = new Player();

            Assert.AreNotEqual(default(Guid), player.Id);
            Assert.IsNotNull(player.Name);
            Assert.AreEqual(PlayerColor.NotChosenYet, player.Color);
            Assert.IsNull(player.PlayerBoard);
        }
Пример #3
0
        public void Sets_PlayerBoard_values_to_defaults()
        {
            var player = new Player();

            var stats = new PlayerStats(player);

            Assert.AreEqual(0, stats.Food);
            Assert.AreEqual(0, stats.FoodTrack);
            Assert.AreEqual(0, stats.PeopleToPlace);
            Assert.AreEqual(0, stats.TotalPeople);
            Assert.AreEqual(0, stats.Score);
            Assert.AreEqual(0, stats.Wood);
            Assert.AreEqual(0, stats.Brick);
            Assert.AreEqual(0, stats.Stone);
            Assert.AreEqual(0, stats.Gold);
            CollectionAssert.AreEquivalent(new List<Tool>(), stats.TappedTools);
            CollectionAssert.AreEquivalent(new List<Tool>(), stats.UntappedTools);
        }
Пример #4
0
        public void Tools_all_tapped()
        {
            var player = new Player
            {
                PlayerBoard = new PlayerBoard()
            };
            player.PlayerBoard.Tools[0] = Tool.Plus4;
            player.PlayerBoard.Tools[1] = Tool.Plus3;
            player.PlayerBoard.Tools[2] = Tool.Plus3;
            player.PlayerBoard.Tools[0].Used = true;
            player.PlayerBoard.Tools[1].Used = true;
            player.PlayerBoard.Tools[2].Used = true;

            var stats = new PlayerStats(player);

            var tappedTools = new List<Tool> { Tool.Plus3.Tap(), Tool.Plus3.Tap(), Tool.Plus4.Tap() };
            CollectionAssert.AreEquivalent(tappedTools, stats.TappedTools);
            CollectionAssert.AreEquivalent(new List<Tool>(), stats.UntappedTools);
        }
Пример #5
0
        public void Creation_of_PlayerStats()
        {
            var player = new Player
            {
                Name = "Frank",
                Chair = Chair.West,
                Color = PlayerColor.Red,
                Mode = PlayerMode.ComputerStrategyPeople,
                ReadyToStart = true,
                PlayerBoard = new PlayerBoard
                {
                    Food = 22,
                    FoodTrack = 4,
                    PeopleToPlace = 3,
                    TotalPeople = 9,
                    Score = 33,
                }
            };
            player.PlayerBoard.Resources[Resource.Wood] = 5;
            player.PlayerBoard.Resources[Resource.Brick] = 6;
            player.PlayerBoard.Resources[Resource.Stone] = 7;
            player.PlayerBoard.Resources[Resource.Gold] = 8;

            var stats = new PlayerStats(player);

            Assert.AreEqual("Frank", stats.Name);
            Assert.AreEqual(Chair.West, stats.Chair);
            Assert.AreEqual(PlayerColor.Red, stats.Color);
            Assert.AreEqual(PlayerMode.ComputerStrategyPeople, stats.Mode);
            Assert.AreEqual(true, stats.ReadyToStart);
            Assert.AreEqual(22, stats.Food);
            Assert.AreEqual(4, stats.FoodTrack);
            Assert.AreEqual(3, stats.PeopleToPlace);
            Assert.AreEqual(9, stats.TotalPeople);
            Assert.AreEqual(33, stats.Score);
            Assert.AreEqual(5, stats.Wood);
            Assert.AreEqual(6, stats.Brick);
            Assert.AreEqual(7, stats.Stone);
            Assert.AreEqual(8, stats.Gold);
        }
Пример #6
0
 public void SetCheiftan(Player player)
 {
     _cheiftanChair = player.Chair;
     while (player.Chair != Next().Chair)
         ;
 }
Пример #7
0
        public void AddToEnd(Player player)
        {
            if (_playerQueue.Contains(player))
                throw new Exception("Cannot add the same player more than once");

            _playerQueue.Enqueue(player);
        }
Пример #8
0
        private DiceResult UseAction(Player player, Space space)
        {
            var result = new DiceResult(new int [0]);
            switch (space.BoardSpace)
            {
                case BoardSpace.HuntingGrounds:
                {
                    result = _dicePouch.Roll(space.QuantityPlaced(player));
                    var diceSum = result.Sum();
                    var numberOfFood = diceSum / 2;
                    player.PlayerBoard.Food += numberOfFood;
                    break;
                }
                case BoardSpace.Forest:
                {
                    // TODO: be sure to test max on food track, population, tools, resources
                    result = _dicePouch.Roll(space.QuantityPlaced(player));
                    var diceSum = result.Sum();
                    var wholeResources = diceSum / (int)Resource.Wood;
                    Board.WoodAvailable -= wholeResources;
                    player.PlayerBoard.Resources[Resource.Wood] += wholeResources;
                    break;
                }
                case BoardSpace.ClayPit:
                {
                    // TODO: be sure to test max on food track, population, tools, resources
                    result = _dicePouch.Roll(space.QuantityPlaced(player));
                    var diceSum = result.Sum();
                    var wholeResources = diceSum / (int)Resource.Brick;
                    Board.BrickAvailable -= wholeResources;
                    player.PlayerBoard.Resources[Resource.Brick] += wholeResources;
                    break;
                }
                case BoardSpace.Quarry:
                {
                    // TODO: be sure to test max on food track, population, tools, resources
                    result = _dicePouch.Roll(space.QuantityPlaced(player));
                    var diceSum = result.Sum();
                    var wholeResources = diceSum / (int)Resource.Stone;
                    Board.StoneAvailable -= wholeResources;
                    player.PlayerBoard.Resources[Resource.Stone] += wholeResources;
                    break;
                }
                case BoardSpace.River:
                {
                    // TODO: be sure to test max on food track, population, tools, resources
                    result = _dicePouch.Roll(space.QuantityPlaced(player));
                    var diceSum = result.Sum();
                    var wholeResources = diceSum / (int)Resource.Gold;
                    Board.GoldAvailable -= wholeResources;
                    player.PlayerBoard.Resources[Resource.Gold] += wholeResources;
                    break;
                }
                case BoardSpace.ToolMaker:
                {
                    // TODO: be sure to test max on food track, population, tools, resources
                    var tools = player.PlayerBoard.Tools;
                    var minValue = tools.Min(t => t.Value);

                    var hasAToolFree = tools.Any(t => !t.Used);

                    for (int toolPosition = 0; toolPosition < tools.Length; toolPosition++)
                    {
                        if (hasAToolFree && tools[toolPosition].Used)
                            continue;

                        if (tools[toolPosition].Value == minValue)
                        {
                            tools[toolPosition] = Tool.ByValue(minValue + 1);
                            // TODO: remove tool from stack
                            // TODO: add tool back to stack when upgrading from 1/2 to 3/4
                            break;
                        }
                    }
                    break;
                }
                case BoardSpace.Hut:
                {
                    // TODO: be sure to test max on food track, population, tools, resources
                    ++player.PlayerBoard.PeopleToPlace;
                    ++player.PlayerBoard.TotalPeople;
                    break;
                }
                case BoardSpace.Field:
                {
                    // TODO: be sure to test max on food track, population, tools, resources
                    ++player.PlayerBoard.FoodTrack;
                    break;
                }
                case BoardSpace.CivilizationCardSlot1:
                {
                    player.PayingForSpace = BoardSpace.CivilizationCardSlot1;
                    break;
                }
                case BoardSpace.CivilizationCardSlot2:
                {
                    player.PayingForSpace = BoardSpace.CivilizationCardSlot2;
                    break;
                }
                case BoardSpace.CivilizationCardSlot3:
                {
                    player.PayingForSpace = BoardSpace.CivilizationCardSlot3;
                    break;
                }
                case BoardSpace.CivilizationCardSlot4:
                {
                    player.PayingForSpace = BoardSpace.CivilizationCardSlot4;
                    break;
                }
                case BoardSpace.BuildingTileSlot1:
                {
                    throw new NotImplementedException();
                    break;
                }
                case BoardSpace.BuildingTileSlot2:
                {
                    throw new NotImplementedException();
                    break;
                }
                case BoardSpace.BuildingTileSlot3:
                {
                    throw new NotImplementedException();
                    break;
                }
                case BoardSpace.BuildingTileSlot4:
                {
                    throw new NotImplementedException();
                    break;
                }
                default:
                {
                    throw new NotImplementedException();
                }
            }

            space.ReturnToPlayer(player);
            return result;
        }
Пример #9
0
        public GameResponse<Guid> AddPlayer()
        {
            if (Phase != GamePhase.ChoosePlayers)
                return GameResponse<Guid>.Fail();

            if (_players.Count() == MAX_PLAYER_COUNT)
                return GameResponse<Guid>.Fail();

            var player = new Player();
            _players.Add(player);

            return GameResponse<Guid>.Pass(player.Id);
        }
Пример #10
0
        private void AddTappedTool(Player player, int index)
        {
            var tool = player.PlayerBoard.Tools[index];
            if (tool.Value == 0)
                return;

            if (tool.Used)
                TappedTools.Add(tool);
            else
                UntappedTools.Add(tool);
        }
Пример #11
0
        public void Tools_all_untapped()
        {
            var player = new Player
            {
                PlayerBoard = new PlayerBoard()
            };
            player.PlayerBoard.Tools[0] = Tool.Plus2;
            player.PlayerBoard.Tools[1] = Tool.Plus2;
            player.PlayerBoard.Tools[2] = Tool.Plus1;
            player.PlayerBoard.Tools[0].Used = false;
            player.PlayerBoard.Tools[1].Used = false;
            player.PlayerBoard.Tools[2].Used = false;

            var stats = new PlayerStats(player);

            CollectionAssert.AreEquivalent(new List<Tool>(), stats.TappedTools);
            var untappedTools = new List<Tool> { Tool.Plus1, Tool.Plus2, Tool.Plus2 };
            CollectionAssert.AreEquivalent(untappedTools, stats.UntappedTools);
        }
Пример #12
0
        public void Tools_empty()
        {
            var player = new Player
            {
                PlayerBoard = new PlayerBoard()
            };
            player.PlayerBoard.Tools[0] = Tool.None;
            player.PlayerBoard.Tools[1] = Tool.None;
            player.PlayerBoard.Tools[2] = Tool.None;
            player.PlayerBoard.Tools[0].Used = false;
            player.PlayerBoard.Tools[1].Used = true;
            player.PlayerBoard.Tools[2].Used = false;

            var stats = new PlayerStats(player);

            CollectionAssert.AreEquivalent(new List<Tool>(), stats.TappedTools);
            CollectionAssert.AreEquivalent(new List<Tool>(), stats.UntappedTools);
        }