Example #1
0
 public DungeonEntityPlacer(
     ILiveEntityHandler entityHandler,
     ICultureHandler cultureHandler,
     IEntityTemplateHandler templateHandler,
     IPhysicsManager physicsManager,
     IEntityFactory entityFactory)
 {
     this.EntityFactory         = entityFactory;
     this.CultureHandler        = cultureHandler;
     this.EntityTemplateHandler = templateHandler;
     this.PhysicsManager        = physicsManager;
     this.EntityHandler         = entityHandler;
 }
        public void SetUp()
        {
            GlobalConstants.ActionLog = new ActionLog();

            this.prefab = GD.Load <Node2D>(GlobalConstants.GODOT_ASSETS_FOLDER + "Scenes/JoyObject.tscn");

            this.scriptingEngine = new ScriptingEngine();

            ILiveEntityHandler entityHandler = Mock.Of <ILiveEntityHandler>();

            IRelationship friendship = Mock.Of <IRelationship>();

            IEntityRelationshipHandler relationshipHandler = Mock.Of <IEntityRelationshipHandler>(
                handler => handler.Get(It.IsAny <IJoyObject[]>(), It.IsAny <string[]>(), It.IsAny <bool>())
                == new IRelationship[] { friendship });

            IEntity questObject = Mock.Of <IEntity>(
                entity => entity.JoyName == "NAME1" &&
                entity.MyWorld == Mock.Of <IWorldInstance>(
                    w => w.GetRandomSentient() == Mock.Of <IEntity>(
                        e => e.JoyName == "NAME2")));

            this.world = Mock.Of <IWorldInstance>(
                w => w.GetRandomSentientWorldWide() == questObject &&
                w.GetRandomSentient() == questObject &&
                w.GetWorlds(It.IsAny <IWorldInstance>()) == new List <IWorldInstance>
            {
                Mock.Of <IWorldInstance>(mock => mock.Name == "TEST2")
            } &&
                w.GetOverworld() == Mock.Of <IWorldInstance>(
                    mock => mock.Name == "EVERSE" &&
                    mock.GetRandomSentient() == questObject &&
                    mock.GetRandomSentientWorldWide() == questObject) &&
                w.Name == "TEST");

            INeed friendshipMock = Mock.Of <INeed>(
                need => need.Fulfill(It.IsAny <int>()) == 1 &&
                need.Name == "friendship");
            IDictionary <string, INeed> needs = new Dictionary <string, INeed>();

            needs.Add("friendship", friendshipMock);

            IRollableValue <int> mockPersonality = Mock.Of <IEntityStatistic>(
                value => value.Value == 4 &&
                value.Name == "personality");
            IDictionary <string, IEntityStatistic> stats = new Dictionary <string, IEntityStatistic>();

            stats.Add(
                "personality",
                new EntityStatistic(
                    "personality",
                    4,
                    GlobalConstants.DEFAULT_SUCCESS_THRESHOLD));

            this.instigator = Mock.Of <IEntity>(
                entity => entity.PlayerControlled == true &&
                entity.MyWorld == this.world &&
                entity.Needs == needs &&
                entity.Statistics == stats &&
                entity.Sentient == true &&
                entity.Guid == Guid.NewGuid());

            this.listener = Mock.Of <IEntity>(entity => entity.MyWorld == this.world &&
                                              entity.Needs == needs &&
                                              entity.Statistics == stats &&
                                              entity.Sentient == true &&
                                              entity.Guid == Guid.NewGuid());

            GlobalConstants.GameManager = Mock.Of <IGameManager>(
                manager => manager.Player == this.instigator &&
                manager.ConversationEngine == new ConversationEngine(relationshipHandler, Guid.NewGuid()) &&
                manager.RelationshipHandler == relationshipHandler &&
                manager.RumourMill == new ConcreteRumourMill(new RNG()));

            this.target = GlobalConstants.GameManager.ConversationEngine;

            friendship.AddParticipant(this.listener.Guid);
            friendship.AddParticipant(this.instigator.Guid);
        }