コード例 #1
0
        public void Test_Build_CompleteConstruction()
        {
            Console.WriteLine ("");
            Console.WriteLine ("Preparing test");
            Console.WriteLine ("");

            var settings = EngineSettings.DefaultVerbose;
            settings.ConstructionRate = 10;

            var person = new Person (settings);
            person.Home = new Building (BuildingType.Shelter, settings);
            person.Home.Inventory.Items [ItemType.Timber] = settings.ShelterTimberCost;
            person.Home.PercentComplete = 99;

            var needEntry = new NeedEntry (ActivityVerb.Build, ItemType.Shelter, PersonVitalType.NotSet, 1, 100);

            person.AddNeed (needEntry);

            var activity = new BuildShelterActivity (person, needEntry, settings, new ConsoleHelper(settings));
            activity.Shelter = person.Home;

            activity.Act (person);

            Assert.AreEqual (100, person.Home.PercentComplete);
            Assert.IsTrue (person.Home.IsCompleted);

            Assert.AreEqual (0, person.Needs.Count);
        }
コード例 #2
0
        public void Test_Build_ContinueConstruction()
        {
            var settings = EngineSettings.DefaultVerbose;
            settings.ConstructionRate = 1;

            var person = new Person (settings);
            person.Home = new Building (BuildingType.House, settings);
            person.Home.Inventory.Items[ItemType.Timber] = 50; // TODO: Get the 50 value from somewhere easier to configures

            var needEntry = new NeedEntry (ActivityVerb.Build, ItemType.Shelter, PersonVitalType.NotSet, 1, 100);

            var activity = new BuildShelterActivity (person, needEntry, settings, new ConsoleHelper(settings));

            activity.Act (person);

            Assert.AreEqual (1, person.Home.PercentComplete);
        }
コード例 #3
0
        public void Test_Build_NotEnoughTimber()
        {
            var settings = EngineSettings.DefaultVerbose;

            var person = new Person (settings);

            var needEntry = new NeedEntry (ActivityVerb.Build, ItemType.Shelter, PersonVitalType.NotSet, 1, 100);

            var activity = new BuildShelterActivity (person, needEntry, settings, new ConsoleHelper(settings));

            activity.Act (person);

            Assert.AreEqual (1, person.Needs.Count);

            var foundNeedEntry = person.Needs [0];

            Assert.AreEqual (ItemType.Timber, foundNeedEntry.ItemType);
            Assert.AreEqual (50, foundNeedEntry.Quantity);
            Assert.AreEqual (101, foundNeedEntry.Priority);
        }
コード例 #4
0
        public void Test_Build_StartConstruction()
        {
            Console.WriteLine ("");
            Console.WriteLine ("Preparing test");
            Console.WriteLine ("");

            var settings = EngineSettings.DefaultVerbose;

            var person = new Person (settings);
            person.Inventory.AddItem (ItemType.Timber, 50); // TODO: Get the 50 value from somewhere easier to configures

            var needEntry = new NeedEntry (ActivityVerb.Build, ItemType.Shelter, PersonVitalType.NotSet, 1, 100);

            var activity = new BuildShelterActivity (person, needEntry, settings, new ConsoleHelper(settings));

            Console.WriteLine ("");
            Console.WriteLine ("Executing test");
            Console.WriteLine ("");

            activity.Act (person);

            Console.WriteLine ("");
            Console.WriteLine ("Analysing test");
            Console.WriteLine ("");

            Assert.IsNotNull (person.Home);
            Assert.AreEqual (50, person.Home.Inventory.Items[ItemType.Timber]); // TODO: Should all the timber necessarily be provided as soon as construction starts?
        }