public void CanStoreGoods() { Game.CargoShips[1].Load(new List <IGood> { new Coffee() }); Game.CargoShips[2].Load(new List <IGood> { new Sugar() }); for (var i = 0; i < 7; i++) { RoleOwner.Goods.Add(new Indigo()); } ReselectRole(); var deliverGoods = new DeliverGoods { GoodType = GoodType.Indigo, ShipCapacity = 4, }; CanExecuteActionOnce(deliverGoods, RoleOwner); Assert.Equal(3, RoleOwner.Goods.Count); var storeGoods = new StoreGoods { DefaultStorage = GoodType.Indigo }; CanExecuteActionOnce(storeGoods, RoleOwner); Assert.Equal(2, RoleOwner.Goods.Count); RoleOwner.Role.CleanUp(); Assert.Single(RoleOwner.Goods); }
public void CanShipMultipleTimes() { RoleOwner.Goods.Add(new Coffee()); RoleOwner.Goods.Add(new Sugar()); ReselectRole(); var action = new DeliverGoods { GoodType = GoodType.Coffee, ShipCapacity = 4, }; CanExecuteActionMultiple(action, RoleOwner); }
public void CanUsePrivilege() { RoleOwner.Goods.Add(new Coffee()); RoleOwner.Goods.Add(new Coffee()); ReselectRole(); var action = new DeliverGoods { GoodType = GoodType.Coffee, ShipCapacity = 4, }; CanExecuteActionOnce(action, RoleOwner); Assert.Empty(RoleOwner.Goods); Assert.Equal(3, RoleOwner.VictoryPointChips.Count); }
public void MustLoadAsMuchAsPossible() { RoleOwner.Goods.Add(new Corn()); RoleOwner.Goods.Add(new Corn()); RoleOwner.Goods.Add(new Corn()); RoleOwner.Goods.Add(new Corn()); RoleOwner.Goods.Add(new Corn()); ReselectRole(); var action = new DeliverGoods { GoodType = GoodType.Corn, ShipCapacity = 4, }; Assert.Throws <GameException>(() => CanExecuteActionOnce(action, RoleOwner)); Assert.Equal(5, RoleOwner.Goods.Count); Assert.Empty(RoleOwner.VictoryPointChips); }
public void CannotLoadDifferentTypeOnSameShip() { RoleOwner.Goods.Add(new Tobacco()); var player = GetPlayerWithoutPrivilege(); player.Goods.Add(new Indigo()); ReselectRole(); var action = new DeliverGoods { GoodType = GoodType.Tobacco, ShipCapacity = 4, }; CanExecuteActionOnce(action, RoleOwner); action.GoodType = GoodType.Indigo; Assert.Throws <GameException>(() => CanExecuteActionOnce(action, player)); Assert.Single(player.Goods); Assert.Empty(player.VictoryPointChips); }
public void DeliversOnlyDeliverableOnes() { RoleOwner.Goods.Add(new Sugar()); RoleOwner.Goods.Add(new Sugar()); var player = GetPlayerWithoutPrivilege(); player.Goods.Add(new Sugar()); player.Goods.Add(new Sugar()); player.Goods.Add(new Sugar()); ReselectRole(); var action = new DeliverGoods { GoodType = GoodType.Sugar, ShipCapacity = 4, }; CanExecuteActionOnce(action, RoleOwner); CanExecuteActionOnce(action, player); Assert.Single(player.Goods); Assert.Equal(2, player.VictoryPointChips.Count); }
public void NotFullShipIsNotCleared() { var goodCount = 2; for (var i = 0; i < goodCount; i++) { RoleOwner.Goods.Add(new Indigo()); } ReselectRole(); var gameGoodCount = Game.Goods.Count; var action = new DeliverGoods { GoodType = GoodType.Indigo, ShipCapacity = 4 }; CanExecuteActionOnce(action, RoleOwner); Role.CleanUp(); Assert.False(Game.CargoShips[0].IsEmpty()); Assert.Equal(gameGoodCount, Game.Goods.Count); }
private void ExecuteDeliverGoods(DeliverGoods deliverGoods, IPlayer player) { var cargo = Game.CargoShips.FirstOrDefault(c => c.Capacity == deliverGoods.ShipCapacity); if (cargo == null) { throw new GameException($"Cargo ship with capacity {deliverGoods.ShipCapacity} does not exist"); } var goodsToDeliver = player.Goods.Where(g => g.Type == deliverGoods.GoodType).ToList(); if (goodsToDeliver.Count == 0) { throw new GameException($"no {deliverGoods.GoodType} barrels"); } CheckPlayerCanLoadToShip(player, goodsToDeliver, cargo); var deliveredCount = cargo.Load(goodsToDeliver); var deliveredGoods = goodsToDeliver.Take(deliveredCount).ToList(); DoDeliver(deliveredGoods, player); if (IsAbleToUseCargoShip(player) || IsAbleToUseWharf(player)) { MoveToNextPlayer(); } else if (player.Goods.Count > 0) { SetPlayerPhase(player, StorePhase); } else { SetPlayerPhase(player, EndedPhase); } }