Beispiel #1
0
        public void IsHandleTest()
        {
            Truck paperTruck = new Truck(TrashType.Paper,100,1.0f);
            Truck organicTruck = new Truck(TrashType.Organic, 100, 1.0f);

            Assert.IsTrue(paperTruck.CanHandle(TrashType.Paper));
            Assert.IsFalse(paperTruck.CanHandle(TrashType.Metal));

            Assert.IsTrue(organicTruck.CanHandle(TrashType.Paper));
            Assert.IsTrue(organicTruck.CanHandle(TrashType.Plastic));
            Assert.IsTrue(organicTruck.CanHandle(TrashType.Organic));
            Assert.IsFalse(organicTruck.CanHandle(TrashType.Metal));
        }
Beispiel #2
0
        public Game(
            IMapTile[][] cityMap
        )
        {
            City = new City(cityMap);
            _currentDate = Trash2012Begin;
            Company = new Company();

            var newTruck1 = new Truck(TrashType.Paper, 25, 1f);
            var newTruck2 = new Truck(TrashType.Paper, 25, 1f);
            Company.Trucks.Add(newTruck1);
            Company.Trucks.Add(newTruck2);

            GameRandomness = new Random();
        }
Beispiel #3
0
        public Game(
            IMapTile[][] cityMap,
            int initialMoneyAmount
        )
        {
            City = new City(cityMap);
            _currentDate = Trash2012Begin;
            Company = new Company(initialMoneyAmount);

            var newTruck1 = new Truck(TrashType.Paper, 50, 1f);
            //var newTruck2 = new Truck(TrashType.Paper, 55, 1f);
            Company.Trucks.Add(newTruck1);
            //Company.Trucks.Add(newTruck2);

            GameRandomness = new Random();
        }
Beispiel #4
0
        /// <summary>
        /// Apply a travel to a game city
        /// </summary>
        /// <param name="dailyTravel">truck travel</param>
        /// <param name="assignedTruck">truck</param>
        /// <returns>total collected garbage</returns>
        public int ApplyTravel(Travel dailyTravel, Truck assignedTruck)
        {
            int garbageAccumulation = 0;
            foreach (var tile in dailyTravel)
            {
                if (assignedTruck.IsFull)
                    break;

                if (tile.ModelTile is IHouseTile)
                {
                    var tilHouse = tile.ModelTile as IHouseTile;
                    var trashAmount = tilHouse.Garbage.Amount;
                    if (trashAmount > 0)
                    {
                        var collectedGarbage = assignedTruck.Swallow(tilHouse.Garbage);
                        garbageAccumulation += collectedGarbage;
                        tilHouse.Garbage = new Trash(
                            tilHouse.Garbage.Type,
                            tilHouse.Garbage.Amount - collectedGarbage
                        );
                    }
                }
            }
            return garbageAccumulation;
        }