Exemplo n.º 1
0
        public void TestConditional1()
        {
            var worldState          = GameInit.CreateWorldState("Attributes/credibility_and_money");
            var storyEventsScenario = new StoryEventsScenario("Attributes/test_story_effects");
            var condScenario        = new ConditionalEventsScenario("Scenarios/test_conditional", worldState);
            var cred  = Attribs.GetAttribByName("Credibility");
            var money = Attribs.GetAttribByName("Money");

            worldState.JournalistState[cred] = 0;
            var scheduler = new PressEventScheduler(worldState, new DateTime(2016, 1, 1), new DateTime(2017, 2, 2), storyEventsScenario, condScenario);

            Assert.AreEqual(500, worldState.JournalistState[money]);
            var cond = scheduler.PopNextEvent();

            Assert.IsNotNull(cond as CutsceneEvent);
            Assert.AreEqual("Unconditional conditional!", (cond as CutsceneEvent).Description);
            var evt = NextAsMultipleChoice(scheduler);

            evt.Apply(evt.Choices[1], worldState);
            Assert.AreEqual(250, worldState.JournalistState[cred]);
            evt = NextAsMultipleChoice(scheduler);
            Assert.AreEqual("Credibility is 250.", evt.Description);
            evt.Apply(evt.Choices[0], worldState);
            Assert.AreEqual(0, worldState.JournalistState[money]);
            evt = NextAsMultipleChoice(scheduler);
            evt.Apply(evt.Choices[0], worldState);
            Assert.AreEqual(275, worldState.JournalistState[cred]);
            Assert.IsNull(scheduler.PopNextEvent());
        }
Exemplo n.º 2
0
        public void TestMultipleScenarios()
        {
            WorldState           state     = CreateWorldState(450);
            StoryEventsScenario  scenario  = new StoryEventsScenario("Scenarios/test_story");
            StoryEventsScenario  scenario2 = new StoryEventsScenario("Scenarios/test_story2");
            IPressEventScheduler scheduler = new PressEventScheduler(state, new DateTime(1989, 11, 17), new DateTime(1990, 1, 1), scenario, scenario2);
            var evt = scheduler.PopNextEvent();

            Assert.AreEqual(new DateTime(1989, 11, 17), evt.Date);
            Assert.AreEqual(0, evt.Preconditions.Count);
            Assert.AreEqual(typeof(CutsceneEvent), evt.GetType());
            Assert.AreEqual(evt.Date, new DateTime(1989, 11, 17));
            evt = scheduler.PopNextEvent();
            Assert.AreEqual(evt.Date, new DateTime(1989, 11, 19));
            Assert.AreEqual("InsertedNotHigh", ((CutsceneEvent)evt).Description);
            evt = scheduler.PopNextEvent();
            Assert.AreEqual("EventLowCredibility", ((CutsceneEvent)evt).Description);
            state.JournalistState[Attribs.Credibility] = 522;
            evt = scheduler.PopNextEvent();
            Assert.AreEqual("InsertedEqual", ((CutsceneEvent)evt).Description);
            evt = scheduler.PopNextEvent();
            Assert.AreNotEqual(null, evt);
            Assert.AreEqual("EventHighCredibility", ((CutsceneEvent)evt).Description);
            Assert.AreEqual(new DateTime(1989, 11, 22), evt.Date);
            evt = scheduler.PopNextEvent();
            Assert.AreEqual(new DateTime(1989, 11, 25), evt.Date);
            Assert.AreEqual("InsertedLast", ((CutsceneEvent)evt).Description);
        }
Exemplo n.º 3
0
        private static MultipleChoiceEvent NextAsMultipleChoice(PressEventScheduler scheduler)
        {
            var evt = scheduler.PopNextEvent() as MultipleChoiceEvent;

            Assert.IsNotNull(evt);
            return(evt);
        }
Exemplo n.º 4
0
        public void TestConditionalAttribsCompare()
        {
            var worldState   = GameInit.CreateWorldState("Attributes/credibility_and_money");
            var condScenario = new ConditionalEventsScenario("Scenarios/test_conditional_attribcmp", worldState);
            var cred         = Attribs.GetAttribByName("Credibility");
            var money        = Attribs.GetAttribByName("Money");

            worldState.JournalistState[cred] = 500;
            worldState.SetValue(money, 500);
            var scheduler = new PressEventScheduler(worldState, new DateTime(1605, 1, 1), new DateTime(2020, 2, 2), condScenario);

            Assert.IsNull(scheduler.PopNextEvent());
            worldState.SetValue(money, 499);
            Assert.AreEqual("More credibility", scheduler.PopNextEvent().Name);
            Assert.IsNull(scheduler.PopNextEvent());
            worldState.SetValue(money, 501);
            Assert.AreEqual("More money", scheduler.PopNextEvent().Name);
            Assert.IsNull(scheduler.PopNextEvent());
            worldState.SetValue(cred, 100);
            worldState.SetValue(money, 101);
            Assert.IsNull(scheduler.PopNextEvent());
            worldState.SetValue(money, 100);
            Assert.AreEqual("Little of both", scheduler.PopNextEvent().Name);
            Assert.IsNull(scheduler.PopNextEvent());
            worldState.Date = new DateTime(2016, 12, 12);
            Assert.AreEqual("Late", scheduler.PopNextEvent().Name);
            Assert.IsNull(scheduler.PopNextEvent());
            Assert.IsTrue(condScenario.IsTerminated);
        }
Exemplo n.º 5
0
        public void TestAttributesAndTermination()
        {
            var worldState          = GameInit.CreateWorldState("Attributes/credibility_only");
            var storyEventsScenario = new StoryEventsScenario("Attributes/test_story_effects");
            var cred      = Attribs.GetAttribByName("Credibility");
            var scheduler = new PressEventScheduler(worldState, new DateTime(2016, 1, 1), new DateTime(2017, 2, 2), storyEventsScenario);
            var evt       = NextAsMultipleChoice(scheduler);

            Assert.AreEqual(500, worldState.JournalistState[cred]);
            evt.Apply(evt.Choices[0], worldState);
            Assert.AreEqual(125, worldState.JournalistState[cred]);
            evt = NextAsMultipleChoice(scheduler);
            evt.Apply(evt.Choices[0], worldState);
            Assert.AreEqual(150, worldState.JournalistState[cred]);
            Assert.IsNull(scheduler.PopNextEvent());
        }
Exemplo n.º 6
0
        public void TestNotMatchingDates()
        {
            var worldState          = GameInit.CreateWorldState("Attributes/credibility_and_money");
            var storyEventsScenario = new StoryEventsScenario("Attributes/test_story_effects");
            var condScenario        = new ConditionalEventsScenario("Scenarios/test_conditional", worldState);
            var cred  = Attribs.GetAttribByName("Credibility");
            var money = Attribs.GetAttribByName("Money");

            worldState.JournalistState[cred] = 500;
            var scheduler = new PressEventScheduler(worldState, new DateTime(1605, 1, 1), new DateTime(1606, 2, 2), storyEventsScenario, condScenario);

            Assert.AreEqual(500, worldState.JournalistState[money]);
            var cond = scheduler.PopNextEvent();

            Assert.IsNotNull(cond as CutsceneEvent);
            Assert.AreEqual("Unconditional conditional!", (cond as CutsceneEvent).Description);
            Assert.IsNull(scheduler.PopNextEvent());
        }
Exemplo n.º 7
0
        public void TestBasic()
        {
            var initialCredibility = 450;
            var state = CreateWorldState(initialCredibility);

            Attribs.SetAttribsCollection(new Dictionary <string, Attrib>()
            {
                { "Credibility", Attribs.Credibility }
            });
            StoryEventsScenario  scenario  = new StoryEventsScenario("Scenarios/test_story");
            IPressEventScheduler scheduler = new PressEventScheduler(state, new DateTime(1989, 11, 17), new DateTime(1990, 1, 1), scenario);
            var evt = scheduler.PopNextEvent();

            Assert.AreEqual(new DateTime(1989, 11, 17), evt.Date);
            Assert.AreEqual(0, evt.Preconditions.Count);
            Assert.AreEqual(typeof(CutsceneEvent), evt.GetType());
            Assert.AreEqual(evt.Date, new DateTime(1989, 11, 17));
            evt = scheduler.PopNextEvent();
            Assert.AreEqual("EventLowCredibility", ((CutsceneEvent)evt).Description);
            evt = scheduler.PopNextEvent();
            Assert.AreEqual(null, evt);
        }