示例#1
0
 public void OnNPCReceiveGift(NPCReceiveGiftEvent args)
 {
     if (args.Giver == Game1.player)
     {
         GiftLog.AddGift(args.Target, args.Gift);
     }
 }
示例#2
0
        public JsonResult Burn(BurnGiftViewModel model)
        {
            try
            {
                using (var db = new KiaGalleryContext())
                {
                    var entity = db.Gift.Where(x => x.Code == model.code && x.GiftStatus == GiftStatus.SoldToTheCustomer).SingleOrDefault();

                    if (entity != null)
                    {
                        entity.GiftStatus = GiftStatus.Used;

                        entity.RevocationCustomerName        = model.fullName;
                        entity.RevocationCustomerPhoneNumber = model.phoneNumber;
                        entity.FactorNumber = model.facotrNumber;
                        entity.FactorPrice  = model.price;

                        var log = new GiftLog()
                        {
                            GiftId       = entity.Id,
                            GiftStatus   = GiftStatus.Used,
                            CreateUserId = 1,
                            CreateDate   = DateTime.Now,
                            Ip           = Request.UserHostAddress
                        };
                        db.GiftLog.Add(log);
                        return(Json(new
                        {
                            status = 200,
                            message = "کارت هدیه " + model.code + " نظر مصرف شد."
                        }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        return(Json(new
                        {
                            status = 404,
                            message = "کارت هدیه با این مشخصات یافت نشد."
                        }, JsonRequestBehavior.AllowGet));
                    }
                }
            }
            catch (Exception ex)
            {
                return(Json(new
                {
                    status = 500,
                    message = "در هنگام اجرای عملیات خطایی رخ داد."
                }, JsonRequestBehavior.AllowGet));
            }
        }
示例#3
0
        public override string GetDisplayText <T>(string currentDisplay, T character, Item item = null)
        {
            NPC          selectedNPC     = character as NPC ?? throw new ArgumentNullException("character", "Cannot display information about gifts for null Character");
            string       npcRelationship = base.GetDisplayText(currentDisplay, character, item);
            GiftResponse response        = (GiftResponse)selectedNPC.getGiftTasteForThisItem(item);

            if (Game1.player.friendshipData.TryGetValue(selectedNPC.Name, out Friendship friendship))
            {
                if (IsItemQuestGift(selectedNPC, item))
                {
                    response = GiftResponse.QuestItem;
                }
                else if (!KnowsAll)
                {
                    if (!Record)
                    {
                        return(npcRelationship);//This is an ambiguous case, at this point we don't know what the user wants and just return the base implementation
                    }
                    else
                    {
                        if ((friendship.Points / NPC.friendshipPointsPerHeartLevel) < Config.heartLevelToKnowAllGifts)
                        {
                            if (!GiftLog.PlayerHasGifted(selectedNPC.Name, item.Name))
                            {
                                response = GiftResponse.Unknown;
                            }
                        }
                    }
                }
                npcRelationship += Environment.NewLine;
                npcRelationship  = GetGiftResponse(npcRelationship, response);
                npcRelationship += AddGiftMiscInfo(friendship);
                return(npcRelationship);
            }
            return(npcRelationship);
        }