示例#1
0
 public void PerformQuestAction(IEntity questor, IQuest quest, IJoyAction completedAction)
 {
     if (quest.FulfilsRequirements(questor, completedAction) && quest.AdvanceStep())
     {
         this.CompleteQuest(questor, quest);
     }
 }
示例#2
0
        public virtual ITopic[] Interact(IEntity instigator, IEntity listener)
        {
            this.GetBits();

            IJoyAction fulfillNeed = this.CachedActions.First(action =>
                                                              action.Name.Equals("fulfillneedaction", StringComparison.OrdinalIgnoreCase));
            IJoyAction influence = this.CachedActions.First(action =>
                                                            action.Name.Equals("modifyrelationshippointsaction", StringComparison.OrdinalIgnoreCase));

            fulfillNeed.Execute(
                new IJoyObject[] { instigator, listener },
                new[] { "friendship" },
                new Dictionary <string, object>
            {
                { "need", "friendship" },
                { "value", instigator.Statistics[EntityStatistic.PERSONALITY].Value },
                { "counter", 0 },
                { "doAll", true }
            });

            string[] tags = this.RelationshipHandler is null
                ? new string[0]
                : this.RelationshipHandler.Get(
                new[] { instigator.Guid, listener.Guid })
                            .SelectMany(relationship => relationship.Tags).ToArray();

            influence.Execute(
                new IJoyObject[] { instigator, listener },
                tags,
                new Dictionary <string, object>
            {
                { "value", instigator.Statistics[EntityStatistic.PERSONALITY].Value }
            });

            influence.Execute(
                new IJoyObject[] { listener, instigator },
                tags,
                new Dictionary <string, object>
            {
                { "value", listener.Statistics[EntityStatistic.PERSONALITY].Value }
            });

            bool?isFamily = this.RelationshipHandler?.IsFamily(instigator.Guid, listener.Guid);

            if (isFamily is null == false && isFamily == true)
            {
                fulfillNeed.Execute(
                    new IJoyObject[] { instigator, listener },
                    new string[] { "family" },
                    new Dictionary <string, object>
                {
                    { "need", "family" },
                    { "value", instigator.Statistics[EntityStatistic.PERSONALITY].Value },
                    { "counter", 0 },
                    { "doAll", true }
                });
            }

            return(this.FetchNextTopics());
        }
示例#3
0
        public override bool ExecutedSuccessfully(IJoyAction action)
        {
            if (action.Name.Equals("enterworldaction", StringComparison.OrdinalIgnoreCase) == false)
            {
                return(false);
            }

            foreach (object obj in action.LastArgs)
            {
                if (obj is IWorldInstance world)
                {
                    if (this.Areas.Contains(world.Guid) == false)
                    {
                        return(false);
                    }
                }
            }

            IWorldInstance        overworld = GlobalConstants.GameManager.Player.MyWorld.GetOverworld();
            List <IWorldInstance> worlds    = overworld.GetWorlds(overworld)
                                              .Where(instance => this.Areas.Contains(instance.Guid))
                                              .ToList();

            return(worlds.All(world => action.LastParticipants.First().HasDataKey(world.Name)) && action.Successful);
        }
示例#4
0
        public void PerformQuestAction(IEntity questor, IJoyAction completedAction)
        {
            List <IQuest> copy = new List <IQuest>(this.GetQuestsForEntity(questor.Guid));

            foreach (IQuest quest in copy)
            {
                this.PerformQuestAction(questor, quest, completedAction);
            }
        }
示例#5
0
        public void QuestTracker_Should_AdvanceOrCompleteQuest()
        {
            //given
            IJoyAction action = Mock.Of <IJoyAction>();
            IQuest     quest  = Mock.Of <IQuest>(
                q => q.AdvanceStep() &&
                q.FulfilsRequirements(this.left, action) == true &&
                q.CompleteQuest(this.left, false) == true &&
                q.IsComplete);

            this.target.AddQuest(this.left.Guid, quest);
            quest.StartQuest(this.left);

            //when
            this.target.PerformQuestAction(this.left, quest, action);

            //then
            Assert.That(this.target.GetQuestsForEntity(this.left.Guid), Is.Empty);
        }
示例#6
0
        public override ITopic[] Interact(IEntity instigator, IEntity listener)
        {
            IJoyAction influence = this.CachedActions.First(action =>
                                                            action.Name.Equals("modifyrelationshippointsaction", StringComparison.OrdinalIgnoreCase));

            influence.Execute(
                new IJoyObject[]
            {
                listener,
                instigator
            },
                new[] { "friendship" },
                new Dictionary <string, object>
            {
                { "value", -instigator.Statistics[EntityStatistic.PERSONALITY].Value }
            });

            return(this.FetchNextTopics());
        }
示例#7
0
        public override ITopic[] Interact(IEntity instigator, IEntity listener)
        {
            if (this.Happening == false)
            {
                return(base.Interact(instigator, listener));
            }

            base.Interact(instigator, listener);

            IJoyAction fulfillNeed = instigator.FetchAction("fulfillneedaction");

            int listenerSatisfaction = (
                instigator.Statistics[EntityStatistic.INTELLECT].Value
                + instigator.Statistics[EntityStatistic.ENDURANCE].Value
                + instigator.Statistics[EntityStatistic.PERSONALITY].Value) / 3;

            int instigatorSatisfaction = (
                listener.Statistics[EntityStatistic.INTELLECT].Value
                + listener.Statistics[EntityStatistic.ENDURANCE].Value
                + listener.Statistics[EntityStatistic.PERSONALITY].Value) / 3;

            fulfillNeed.Execute(
                new IJoyObject[] { instigator },
                new[] { "sex", "need" },
                new Dictionary <string, object>
            {
                { "need", "sex" },
                { "value", instigatorSatisfaction },
                { "counter", 10 }
            });
            fulfillNeed.Execute(
                new IJoyObject[] { listener },
                new[] { "sex", "need" },
                new Dictionary <string, object>
            {
                { "need", "sex" },
                { "value", listenerSatisfaction },
                { "counter", 10 }
            });

            return(this.FetchNextTopics());
        }
示例#8
0
        public override bool ExecutedSuccessfully(IJoyAction action)
        {
            if (action.LastTags.Any(tag => tag.Equals("item", StringComparison.OrdinalIgnoreCase)) == false)
            {
                return(false);
            }

            if (action.LastTags.Any(tag =>
                                    tag.Equals("trade", StringComparison.OrdinalIgnoreCase) ||
                                    tag.Equals("give", StringComparison.OrdinalIgnoreCase)) == false)
            {
                return(false);
            }

            if (action.LastParticipants.Select(o => o.Guid).Intersect(this.Actors).Count() != this.Actors.Count)
            {
                return(false);
            }

            List <IItemInstance> items = new List <IItemInstance>();

            foreach (object obj in action.LastArgs)
            {
                if (obj is IEnumerable <IItemInstance> toAdd)
                {
                    items.AddRange(toAdd);
                }
                else if (obj is IItemInstance item)
                {
                    items.Add(item);
                }
            }

            return(items.Select(instance => instance.Guid).Intersect(this.Items).Count() == this.Items.Count &&
                   action.Successful);
        }
示例#9
0
        private void CreateWorld()
        {
            //Make a new overworld generator
            OverworldGenerator overworldGen = new OverworldGenerator(this.m_WorldInfoHandler);

            //Generate the basic overworld
            this.m_World = new WorldInstance(
                overworldGen.GenerateWorldSpace(WORLD_SIZE, "plains"),
                new string[] { "overworld", "exterior" },
                "Everse",
                GlobalConstants.GameManager.EntityHandler,
                GlobalConstants.GameManager.Roller);

            //Set the date and time for 1/1/1555, 12:00pm
            this.m_World.SetDateTime(new JoyDateTime(1555, 1, 1, 12));

            //Do the spawn point
            SpawnPointPlacer spawnPlacer = new SpawnPointPlacer(GlobalConstants.GameManager.Roller);
            Vector2Int       spawnPoint  = spawnPlacer.PlaceSpawnPoint(this.m_World);

            while ((spawnPoint.x == -1 && spawnPoint.y == -1))
            {
                spawnPoint = spawnPlacer.PlaceSpawnPoint(this.m_World);
            }

            this.m_World.SpawnPoint = spawnPoint;

            //Set up the player
            //m_Player.Move(m_World.SpawnPoint);
            //m_World.AddEntity(m_Player);

            //Begin the first floor of the Naga Pits
            WorldInfo worldInfo = this.m_WorldInfoHandler.GetRandom("interior");

            DungeonGenerator dungeonGenerator = new DungeonGenerator();
            WorldInstance    dungeon          = dungeonGenerator.GenerateDungeon(
                worldInfo,
                WORLD_SIZE,
                3,
                GlobalConstants.GameManager,
                GlobalConstants.GameManager.Roller);

            Vector2Int transitionPoint = spawnPlacer.PlaceTransitionPoint(this.m_World);

            this.m_World.AddArea(transitionPoint, dungeon);
            this.Done = true;

            this.m_ActiveWorld = dungeon;
            this.m_Player.Move(dungeon.SpawnPoint);
            dungeon.AddEntity(this.m_Player);

            GlobalConstants.GameManager.EntityHandler.Add(this.m_Player);

            IItemInstance lightSource = GlobalConstants.GameManager.ItemFactory.CreateRandomItemOfType(
                new string[] { "light source" },
                true);

            IItemInstance bag = GlobalConstants.GameManager.ItemFactory.CreateRandomItemOfType(
                new[] { "container" },
                true);

            IJoyAction addItemAction = this.m_Player.FetchAction("additemaction");

            addItemAction.Execute(
                new IJoyObject[] { this.m_Player, lightSource },
                new[] { "pickup" },
                new Dictionary <string, object>
            {
                { "newOwner", true }
            });

            addItemAction.Execute(
                new IJoyObject[] { this.m_Player, bag },
                new[] { "pickup" },
                new Dictionary <string, object>
            {
                { "newOwner", true }
            });

            for (int i = 0; i < 4; i++)
            {
                IItemInstance newItem = GlobalConstants.GameManager.ItemFactory.CreateRandomWeightedItem(
                    true,
                    false);
                addItemAction.Execute(
                    new IJoyObject[]
                {
                    this.m_Player,
                    newItem
                },
                    new[] { "pickup" },
                    new Dictionary <string, object>
                {
                    { "newOwner", true }
                });
            }

            this.m_World.Tick();

            GlobalConstants.GameManager.WorldHandler.Add(this.m_World);

            WorldSerialiser worldSerialiser = new WorldSerialiser(GlobalConstants.GameManager.ObjectIconHandler);

            worldSerialiser.Serialise(this.m_World);

            this.Done = true;
        }
示例#10
0
 public abstract bool ExecutedSuccessfully(IJoyAction action);
示例#11
0
 public bool FulfilsRequirements(IEntity questor, IJoyAction action)
 {
     return(this.Actions[this.CurrentStep].ExecutedSuccessfully(action));
 }
示例#12
0
        public override ITopic[] Interact(IEntity instigator, IEntity listener)
        {
            this.Happening = false;

            IJoyObject[] participants = { instigator, listener };

            List <IRelationship> relationships = this.RelationshipHandler.Get(
                participants.Select(o => o.Guid),
                new[] { "sexual" },
                false)
                                                 .ToList();

            if (relationships.IsNullOrEmpty() &&
                listener.Sexuality.Compatible(listener, instigator) &&
                instigator.Sexuality.Compatible(instigator, listener))
            {
                relationships.Add(this.RelationshipHandler.CreateRelationship(
                                      participants.Select(o => o.Guid),
                                      new[] { "sexual" }));
            }

            if (listener.Sexuality.WillMateWith(listener, instigator, relationships) == false ||
                instigator.Sexuality.WillMateWith(instigator, listener, relationships) == false)
            {
                return(base.Interact(instigator, listener));
            }

            IJoyAction fulfillNeed = instigator.FetchAction("fulfillneedaction");

            int listenerSatisfaction = (
                instigator.Statistics[EntityStatistic.INTELLECT].Value
                + instigator.Statistics[EntityStatistic.ENDURANCE].Value
                + instigator.Statistics[EntityStatistic.PERSONALITY].Value) / 3;

            int instigatorSatisfaction = (
                listener.Statistics[EntityStatistic.INTELLECT].Value
                + listener.Statistics[EntityStatistic.ENDURANCE].Value
                + listener.Statistics[EntityStatistic.PERSONALITY].Value) / 3;


            fulfillNeed.Execute(
                new IJoyObject[] { instigator, listener },
                new[] { "sex", "need" },
                new Dictionary <string, object>
            {
                { "need", "sex" },
                { "value", instigatorSatisfaction },
                { "counter", 10 },
                { "overwrite", true }
            });
            fulfillNeed.Execute(
                new IJoyObject[] { listener, instigator },
                new[] { "sex", "need" },
                new Dictionary <string, object>
            {
                { "need", "sex" },
                { "value", listenerSatisfaction },
                { "counter", 10 },
                { "overwrite", true }
            });

            base.Interact(instigator, listener);

            this.Happening = true;

            return(this.FetchNextTopics());
        }