Example #1
0
 public virtual void OnFishCaught(Farmer farmer, Item fish_item)
 {
     foreach (string acceptableContextTagSet in acceptableContextTagSets)
     {
         bool     fail  = false;
         string[] array = acceptableContextTagSet.Split(',');
         foreach (string obj in array)
         {
             bool     found_match = false;
             string[] array2      = obj.Split('/');
             foreach (string acceptable_tag in array2)
             {
                 if (fish_item.HasContextTag(acceptable_tag.Trim()))
                 {
                     found_match = true;
                     break;
                 }
             }
             if (!found_match)
             {
                 fail = true;
             }
         }
         if (!fail)
         {
             IncrementCount(fish_item.Stack);
             break;
         }
     }
 }
 public virtual bool IsValidItem(Item item)
 {
     if (item == null)
     {
         return(false);
     }
     foreach (string acceptableContextTagSet in acceptableContextTagSets)
     {
         bool     fail  = false;
         string[] array = acceptableContextTagSet.Split(',');
         foreach (string obj in array)
         {
             bool     found_match = false;
             string[] array2      = obj.Split('/');
             foreach (string acceptable_tag in array2)
             {
                 if (item.HasContextTag(acceptable_tag.Trim()))
                 {
                     found_match = true;
                     break;
                 }
             }
             if (!found_match)
             {
                 fail = true;
             }
         }
         if (!fail)
         {
             return(true);
         }
     }
     return(false);
 }
Example #3
0
 public virtual void OnItemShipped(Farmer farmer, Item item, int shipped_price)
 {
     foreach (string acceptableContextTagSet in acceptableContextTagSets)
     {
         bool     fail  = false;
         string[] array = acceptableContextTagSet.Split(',');
         foreach (string obj in array)
         {
             bool     found_match = false;
             string[] array2      = obj.Split('/');
             foreach (string acceptable_tag in array2)
             {
                 if (item.HasContextTag(acceptable_tag.Trim()))
                 {
                     found_match = true;
                     break;
                 }
             }
             if (!found_match)
             {
                 fail = true;
             }
         }
         if (!fail)
         {
             if (useShipmentValue.Value)
             {
                 IncrementCount(shipped_price);
             }
             else
             {
                 IncrementCount(item.Stack);
             }
             break;
         }
     }
 }
Example #4
0
        public virtual void OnGiftGiven(Farmer farmer, NPC npc, Item item)
        {
            bool is_valid_gift = true;

            foreach (string acceptableContextTagSet in acceptableContextTagSets)
            {
                is_valid_gift = false;
                bool     fail  = false;
                string[] array = acceptableContextTagSet.Split(',');
                foreach (string obj in array)
                {
                    bool     found_match = false;
                    string[] array2      = obj.Split('/');
                    foreach (string acceptable_tag in array2)
                    {
                        if (item.HasContextTag(acceptable_tag.Trim()))
                        {
                            found_match = true;
                            break;
                        }
                    }
                    if (!found_match)
                    {
                        fail = true;
                    }
                }
                if (!fail)
                {
                    is_valid_gift = true;
                    break;
                }
            }
            if (!is_valid_gift)
            {
                return;
            }
            if (minimumLikeLevel.Value > LikeLevels.None)
            {
                int        like_level      = npc.getGiftTasteForThisItem(item);
                LikeLevels gift_like_level = LikeLevels.None;
                switch (like_level)
                {
                case 6:
                    gift_like_level = LikeLevels.Hated;
                    break;

                case 4:
                    gift_like_level = LikeLevels.Disliked;
                    break;

                case 8:
                    gift_like_level = LikeLevels.Neutral;
                    break;

                case 2:
                    gift_like_level = LikeLevels.Liked;
                    break;

                case 0:
                    gift_like_level = LikeLevels.Loved;
                    break;
                }
                if (gift_like_level < minimumLikeLevel.Value)
                {
                    return;
                }
            }
            IncrementCount(1);
        }
Example #5
0
        public virtual int OnItemDelivered(Farmer farmer, NPC npc, Item item)
        {
            if (IsComplete())
            {
                return(0);
            }
            if (npc.Name != targetName.Value)
            {
                return(0);
            }
            bool is_valid_delivery = true;

            foreach (string acceptableContextTagSet in acceptableContextTagSets)
            {
                is_valid_delivery = false;
                bool     fail  = false;
                string[] array = acceptableContextTagSet.Split(',');
                foreach (string obj in array)
                {
                    bool     found_match = false;
                    string[] array2      = obj.Split('/');
                    foreach (string acceptable_tag in array2)
                    {
                        if (item.HasContextTag(acceptable_tag.Trim()))
                        {
                            found_match = true;
                            break;
                        }
                    }
                    if (!found_match)
                    {
                        fail = true;
                    }
                }
                if (!fail)
                {
                    is_valid_delivery = true;
                    break;
                }
            }
            if (!is_valid_delivery)
            {
                return(0);
            }
            int required_amount = GetMaxCount() - GetCount();
            int donated_amount  = Math.Min(item.Stack, required_amount);

            if (donated_amount < required_amount)
            {
                return(0);
            }
            Item donated_item = item.getOne();

            donated_item.Stack = donated_amount;
            _order.donatedItems.Add(donated_item);
            item.Stack -= donated_amount;
            IncrementCount(donated_amount);
            if (!string.IsNullOrEmpty(message.Value))
            {
                npc.CurrentDialogue.Push(new Dialogue(message.Value, npc));
                Game1.drawDialogue(npc);
            }
            return(donated_amount);
        }