Beispiel #1
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;
        }
Beispiel #2
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);
        }