public Purpose( int decayRef, int decayCounterRef, bool doesDecayRef, int priorityRef, int happinessThresholdRef, int valueRef, int maxValueRef, ISpriteState fulfillingSprite, IEntityRelationshipHandler relationshipHandler = null, IQuestProvider questProvider = null, int averageForDayRef = 0, int averageForWeekRef = 0) : base( decayRef, decayCounterRef, doesDecayRef, priorityRef, happinessThresholdRef, valueRef, maxValueRef, new string[0], fulfillingSprite, averageForDayRef, averageForWeekRef) { this.RelationshipHandler = relationshipHandler ?? GlobalConstants.GameManager?.RelationshipHandler; this.QuestProvider = questProvider ?? GlobalConstants.GameManager?.QuestProvider; }
/// <summary> /// Gets the quests that a <see cref="IQuestPerformer{T}"/> can accept from or turn in to a /// <see cref="IQuestProvider{T}"/>. /// </summary> /// <typeparam name="T">The type of quest performer.</typeparam> /// <param name="performer">The quest performer.</param> /// <param name="provider">The quest provider.</param> /// <param name="availableQuests">The quests that the <paramref name="performer"/> can accept to start from /// the <paramref name="provider"/>.</param> /// <param name="turnInQuests">The quests that the <paramref name="performer"/> has completed and can be /// turned in to the <paramref name="provider"/>.</param> public static void GetAvailableQuests <T>(T performer, IQuestProvider <T> provider, out IQuest <T>[] availableQuests, out IQuest <T>[] turnInQuests) where T : IQuestPerformer <T> { availableQuests = provider.Quests .Where(x => !performer.ActiveQuests.Contains(x) && (x.Repeatable || !performer.HasCompletedQuest(x))).ToArray(); var canTurnInQuests = performer.ActiveQuests.Where(x => x.FinishRequirements.HasRequirements(performer)).ToImmutable(); turnInQuests = provider.Quests.Where(x => canTurnInQuests.Contains(x)).ToArray(); }
protected void GetBits() { if (this.QuestProvider is null) { this.QuestProvider = GlobalConstants.GameManager?.QuestProvider; } if (this.RelationshipHandler is null) { this.RelationshipHandler = GlobalConstants.GameManager?.RelationshipHandler; } }
public GameStartPacketHandler(IOptions <WorldConfiguration> worldConfiguration, IFriendHttpClient friendHttpClient, IChannelHttpClient channelHttpClient, IConnectedAccountHttpClient connectedAccountHttpClient, IBlacklistHttpClient blacklistHttpClient, IPacketHttpClient packetHttpClient, ISerializer packetSerializer, IMailHttpClient mailHttpClient, IQuestProvider questProvider) { _worldConfiguration = worldConfiguration; _packetSerializer = packetSerializer; _blacklistHttpClient = blacklistHttpClient; _connectedAccountHttpClient = connectedAccountHttpClient; _channelHttpClient = channelHttpClient; _friendHttpClient = friendHttpClient; _packetHttpClient = packetHttpClient; _mailHttpClient = mailHttpClient; _questProvider = questProvider; }
public void SetUp() { ActionLog actionLog = new ActionLog(); GlobalConstants.ActionLog = actionLog; this.scriptingEngine = new ScriptingEngine(); IItemInstance item = Mock.Of <IItemInstance>(); this.overworld = Mock.Of <IWorldInstance>( w => w.Name == "overworld" && w.GetWorlds(It.IsAny <IWorldInstance>()) == new List <IWorldInstance> { Mock.Of <IWorldInstance>( instance => instance.Guid == Guid.NewGuid()) } && w.GetRandomSentientWorldWide() == Mock.Of <IEntity>( entity => entity.Guid == Guid.NewGuid() && entity.MyWorld == this.world && entity.Contents == new List <IItemInstance> { item })); this.world = Mock.Of <IWorldInstance>( w => w.GetOverworld() == this.overworld && w.Name == "TEST" && w.Guid == Guid.NewGuid()); this.left = Mock.Of <IEntity>( entity => entity.Guid == Guid.NewGuid() && entity.PlayerControlled == true && entity.MyWorld == this.world && entity.HasDataKey(It.IsAny <string>()) == false); this.right = Mock.Of <IEntity>( entity => entity.Guid == Guid.NewGuid() && entity.MyWorld == this.world && entity.Contents == new List <IItemInstance> { item }); IRelationship friendship = Mock.Of <IRelationship>( relationship => relationship.GetRelationshipValue(It.IsAny <Guid>(), It.IsAny <Guid>()) == 0); IEntityRelationshipHandler relationshipHandler = Mock.Of <IEntityRelationshipHandler>( handler => handler.Get(It.IsAny <IJoyObject[]>(), It.IsAny <string[]>(), It.IsAny <bool>()) == new[] { friendship }); ILiveItemHandler itemHandler = Mock.Of <ILiveItemHandler>( handler => handler.GetQuestRewards(It.IsAny <Guid>()) == new List <IItemInstance> { item }); IItemFactory itemFactory = Mock.Of <IItemFactory>( factory => factory.CreateRandomItemOfType( It.IsAny <string[]>(), It.IsAny <bool>()) == item && factory.CreateSpecificType( It.IsAny <string>(), It.IsAny <string[]>(), It.IsAny <bool>()) == item && factory.CreateRandomWeightedItem( It.IsAny <bool>(), It.IsAny <bool>()) == item); this.gameManager = Mock.Of <IGameManager>( manager => manager.ItemFactory == itemFactory && manager.Player == this.left && manager.ItemHandler == itemHandler && manager.GUIDManager == new GUIDManager()); GlobalConstants.GameManager = this.gameManager; this.target = new QuestProvider( relationshipHandler, itemHandler, itemFactory, new RNG()); this.questTracker = new QuestTracker(); }
public ScriptPacketHandler(IQuestProvider questProvider) { _questProvider = questProvider; }