Ejemplo n.º 1
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (this.IsCompleted())
            {
                return(false);
            }

            if (message is VanillaCompletionMessage args && args.CompletionType == 4 && this.IsWhenMatched())
            {
                if (this._targetNames.Count == 0 && !string.IsNullOrEmpty(args.String))
                {
                    this.IncrementCount(1);

                    return(true);
                }

                foreach (string targetName in this._targetNames)
                {
                    if (args.String != null && args.String.Contains(targetName))
                    {
                        this.IncrementCount(1);

                        return(true);
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 2
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (message.Trigger != "PlayerMoved" || !this.IsWhenMatched() || this.IsCompleted())
            {
                return(false);
            }

            if (message is PlayerMovedMessage movedMessage)
            {
                if (movedMessage.Location.Name != this.Data.Location)
                {
                    return(false);
                }

                if (this.Data.Tile.HasValue && this.Data.Tile.Value == movedMessage.TilePosition)
                {
                    this.IncrementCount(this.Count);
                    return(true);
                }

                if (this.Data.Area.HasValue && this.Data.Area.Value.Contains((int)movedMessage.Position.X, (int)movedMessage.Position.Y))
                {
                    this.IncrementCount(this.Count);
                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (!this.IsCompleted() && this.Trigger == message.Trigger && this.IsWhenMatched())
            {
                this.IncrementCount(1);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 4
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (this.IsCompleted())
            {
                return(false);
            }

            if (message is DeliverMessage deliverMessage)
            {
                if (deliverMessage.Item == null || this.Data.AcceptedContextTags == null || !this.IsWhenMatched())
                {
                    return(false);
                }

                if (deliverMessage.Npc.Name != this.Data.NpcName)
                {
                    return(false);
                }

                if (Helper.CheckItemContextTags(deliverMessage.Item, this.Data.AcceptedContextTags))
                {
                    int    requiredAmount = this.Count - this.CurrentCount;
                    int    donatedAmount  = Math.Min(deliverMessage.Item.Stack, requiredAmount);
                    string reaction       = this.Data.Message;

                    if (donatedAmount < requiredAmount && !string.IsNullOrEmpty(this.Data.NotEnoughMessage))
                    {
                        reaction = string.Format(this.Data.NotEnoughMessage, requiredAmount - donatedAmount);
                    }

                    deliverMessage.Item.Stack -= donatedAmount;
                    this.IncrementCount(donatedAmount);

                    if (!string.IsNullOrEmpty(reaction))
                    {
                        deliverMessage.Npc.CurrentDialogue.Push(new Dialogue(reaction, deliverMessage.Npc));
                        Game1.drawDialogue(deliverMessage.Npc);
                    }

                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (this.IsCompleted())
            {
                return(false);
            }

            if (message is DeliverMessage deliverMessage && this.IsWhenMatched() && this._itemsToRemove.Any(i => i.ParentSheetIndex == deliverMessage.Item.ParentSheetIndex))
            {
                return(this.DoTalk(deliverMessage.Npc, deliverMessage.Who));
            }

            if (message is TalkRequest talkRequest && this.IsWhenMatched())
            {
                return(this.DoTalk(talkRequest.speaker, talkRequest.who));
            }

            return(false);
        }
Ejemplo n.º 6
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (this.IsCompleted())
            {
                return(false);
            }

            if (message is GiftMessage giftMessage && this.IsWhenMatched())
            {
                if (giftMessage.Item == null || giftMessage.Npc == null)
                {
                    return(false);
                }

                if (this.Data.NpcName != null && this.Data.NpcName != giftMessage.Npc.Name)
                {
                    return(false);
                }

                if (this.Data.AcceptedContextTags != null && !Helper.CheckItemContextTags(giftMessage.Item, this.Data.AcceptedContextTags))
                {
                    return(false);
                }

                if (this.Data.MinimumLikeLevel > LikeLevels.None)
                {
                    int        like_level      = giftMessage.Npc.getGiftTasteForThisItem(giftMessage.Item);
                    LikeLevels gift_like_level = MapGiftLikeLevel(like_level);

                    if (gift_like_level < this.Data.MinimumLikeLevel)
                    {
                        return(false);
                    }
                }

                this.IncrementCount(1);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 7
0
        private bool CheckTasks(IStoryMessage storyMessage)
        {
            if (this.Tasks == null || !this.IsInQuestLogAndActive())
            {
                return(false);
            }

            bool worked = false;

            foreach (var task in this.Tasks)
            {
                if (!task.IsRegistered() || !task.IsActive())
                {
                    continue;
                }

                worked |= task.OnCheckProgress(storyMessage);
            }

            return(worked);
        }
Ejemplo n.º 8
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (this.IsCompleted())
            {
                return(false);
            }

            if (message is VanillaCompletionMessage completionArgs && completionArgs.CompletionType == Quest.type_resource)
            {
                if (completionArgs.Item == null || this.Data.AcceptedContextTags == null || !this.IsWhenMatched())
                {
                    return(false);
                }

                if (Helper.CheckItemContextTags(completionArgs.Item, this.Data.AcceptedContextTags))
                {
                    this.IncrementCount(completionArgs.Item.Stack);

                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 9
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (this.IsCompleted())
            {
                return(false);
            }

            if (message is FishMessage fishMessage)
            {
                if (fishMessage.Fish == null || this.Data.AcceptedContextTags == null || !this.IsWhenMatched())
                {
                    return(false);
                }

                if (Helper.CheckItemContextTags(fishMessage.Fish, this.Data.AcceptedContextTags))
                {
                    this.IncrementCount(fishMessage.Fish.Stack);

                    return(true);
                }
            }

            return(false);
        }
Ejemplo n.º 10
0
        public override bool OnCheckProgress(IStoryMessage message)
        {
            if (this.IsCompleted())
            {
                return(false);
            }

            if (message is TileActionMessage tileActionMessage && this.IsWhenMatched())
            {
                if (this.Data.Location != tileActionMessage.Location?.Name || this.Data.Tile != tileActionMessage.TilePosition)
                {
                    return(false);
                }

                if (this.Data.ItemAcceptedContextTags == null)
                {
                    this.IncrementCount(this.Count);

                    if (this.Data.Message != null)
                    {
                        Game1.drawObjectDialogue(this.Data.Message);
                    }

                    return(true);
                }

                Farmer farmer = tileActionMessage.Farmer;

                if (Helper.CheckItemContextTags(farmer.ActiveObject, this.Data.ItemAcceptedContextTags))
                {
                    int requiredAmount = this.Count - this.CurrentCount;
                    int donatedAmount  = Math.Min(farmer.ActiveObject.Stack, requiredAmount);

                    if (donatedAmount < requiredAmount)
                    {
                        if (this.Data.ItemRequiredMessage != null)
                        {
                            Game1.drawObjectDialogue(string.Format(this.Data.ItemRequiredMessage, requiredAmount));
                        }

                        return(true);
                    }

                    if (this.Data.ConsumeItem)
                    {
                        farmer.ActiveObject.Stack -= donatedAmount;

                        if (farmer.ActiveObject.Stack <= 0)
                        {
                            farmer.ActiveObject = null;
                            farmer.showNotCarrying();
                        }
                    }

                    this.IncrementCount(donatedAmount);

                    if (this.Data.StartEvent != null)
                    {
                        tileActionMessage.Location.StartEventFrom(this.Data.StartEvent);
                    }
                    else if (this.Data.Message != null)
                    {
                        Game1.drawObjectDialogue(this.Data.Message);
                    }

                    return(true);
                }
            }

            return(false);
        }