private static bool FeedPetWithDiet(MsgInformationEx MsgDTO, PetRecord pet, CookingDietModel diet) { if (!diet.Attributes.Contains(pet.Attribute)) { MsgSender.PushMsg(MsgDTO, $"{pet.Name}说不想吃这个东西(请喂食正确特性的菜肴)"); return(false); } var cookingRec = CookingRecord.Get(MsgDTO.FromQQ); if (!cookingRec.CheckDiet(diet.Name)) { MsgSender.PushMsg(MsgDTO, "你没有该菜肴!"); return(false); } var resMsg = $"{pet.Name}兴奋的吃掉了 {diet.Name},并打了个饱嗝\r\n"; pet.LastFeedTime = DateTime.Now; resMsg += pet.ExtGain(MsgDTO, diet.Exp); cookingRec.DietConsume(diet.Name); cookingRec.Update(); MsgSender.PushMsg(MsgDTO, resMsg); return(true); }
public bool ResolveItem(MsgInformationEx MsgDTO, object[] param) { var name = param[0] as string; var item = HonorSvc.FindItem(name); if (item == null) { MsgSender.PushMsg(MsgDTO, "未查找到相关物品!"); return(false); } var itemColle = ItemCollectionRecord.Get(MsgDTO.FromQQ); if (!itemColle.CheckItem(name)) { MsgSender.PushMsg(MsgDTO, "你尚未持有该物品!"); return(false); } itemColle.ItemConsume(name); itemColle.Update(); var count = Math.Max(item.Price / 20, 1); var flavorings = ExpeditionSceneSvc.RandFlavorings(count); var cookingRec = CookingRecord.Get(MsgDTO.FromQQ); cookingRec.FlavoringIncome(flavorings); cookingRec.Update(); var msg = flavorings.Select(p => $"{p.Key}×{p.Value}").JoinToString(","); MsgSender.PushMsg(MsgDTO, $"分解成功!你获得了:\r\n{msg}"); return(true); }
private bool DealDiet(MsgInformationEx MsgDTO, string name, long aimQQ, int price) { var aimDietRec = CookingRecord.Get(aimQQ); if (!aimDietRec.CheckDiet(name)) { MsgSender.PushMsg(MsgDTO, "对方没有该菜肴!"); return(false); } var dietModel = CookingDietSvc[name]; if (dietModel.EstimatedPrice < price) { MsgSender.PushMsg(MsgDTO, $"交易价格不能低于该菜肴的成本价格({dietModel.EstimatedPrice.CurencyFormat()})!"); return(false); } var sourceOSPerson = OSPerson.GetPerson(MsgDTO.FromQQ); var fee = OSPersonBuff.CheckBuff(MsgDTO.FromQQ, "苍天") ? 0 : price / 20; if (sourceOSPerson.Golds < price + fee) { MsgSender.PushMsg(MsgDTO, "你没有足够的金币来支付!"); return(false); } var count = aimDietRec.CookedDietDic[name]; var msg = $"收到来自 {CodeApi.Code_At(MsgDTO.FromQQ)} 的交易请求:\r\n" + $"希望得到的菜肴:{name}\r\n" + $"价格:{price.CurencyFormat()}({dietModel.EstimatedPrice.CurencyFormat()})\r\n" + $"你当前持有:{count}个,是否确认交易?"; if (!WaiterSvc.WaitForConfirm(MsgDTO.FromGroup, aimQQ, msg, MsgDTO.BindAi, 10)) { MsgSender.PushMsg(MsgDTO, "交易取消!"); return(false); } var sourceDietRec = CookingRecord.Get(MsgDTO.FromQQ); sourceDietRec.AddDiet(name); sourceDietRec.Update(); aimDietRec.DietConsume(name); aimDietRec.Update(); sourceOSPerson.Golds -= price + fee; sourceOSPerson.Update(); var aimOSPerson = OSPerson.GetPerson(aimQQ); aimOSPerson.Golds += price; aimOSPerson.Update(); MsgSender.PushMsg(MsgDTO, "交易完毕!"); return(true); }
public ExpeditionAward Award(long QQNum) { var award = new ExpeditionAward() { Name = Name }; if (GoldBonus != null) { award.Gold = GoldBonus.Min + Rander.RandRange(GoldBonus.Min, GoldBonus.Max); var osPerson = OSPerson.GetPerson(QQNum); osPerson.Golds += award.Gold; osPerson.Update(); } if (ItemBonus != null) { var count = ItemBonus.Min + Rander.RandRange(ItemBonus.Min, ItemBonus.Max); award.Items = Enumerable.Range(0, count).Select(p => ItemBonus.Options.RandElement()).ToList(); var itemColle = ItemCollectionRecord.Get(QQNum); foreach (var item in award.Items) { itemColle.ItemIncome(item); } } if (FlavoringBonus != null) { var count = FlavoringBonus.Min + Rander.RandRange(FlavoringBonus.Min, FlavoringBonus.Max); award.Flavorings = Enumerable.Range(0, count).Select(p => FlavoringBonus.Options.RandElement()).ToList(); var flavoringRec = CookingRecord.Get(QQNum); foreach (var flavoring in award.Flavorings) { flavoringRec.FlavoringIncome(flavoring); } flavoringRec.Update(); } return(award); }
public bool AssertCalculate(MsgInformationEx MsgDTO, object[] param) { var osPerson = OSPerson.GetPerson(MsgDTO.FromQQ); if (osPerson.Golds < 50) { MsgSender.PushMsg(MsgDTO, $"你的金币余额不足({osPerson.Golds.CurencyFormat()}/{50.CurencyFormat()})!"); return(false); } if (!WaiterSvc.WaitForConfirm_Gold(MsgDTO, 50)) { MsgSender.PushMsg(MsgDTO, "操作取消!"); return(false); } osPerson.Golds -= 50; osPerson.Update(); var resultDic = new Dictionary <string, int> { { "金币资产", osPerson.Golds } }; var itemRecord = ItemCollectionRecord.Get(MsgDTO.FromQQ); if (!itemRecord.HonorCollections.IsNullOrEmpty()) { var itemAssert = itemRecord.AssertToGold(); resultDic.Add("物品资产", itemAssert); } if (!osPerson.GiftDic.IsNullOrEmpty()) { var giftsMaterialDic = osPerson.GiftDic.SelectMany(p => GiftSvc[p.Key].MaterialDic); var giftAssert = giftsMaterialDic.Sum(g => HonorSvc.FindItem(g.Key).Price *g.Value); resultDic.Add("礼物资产", giftAssert); } var pet = PetRecord.Get(MsgDTO.FromQQ); if (pet.Level > 0 || pet.Exp > 0) { var petAssert = PetLevelSvc.ExpToGolds(pet.Level, pet.Exp); resultDic.Add("宠物资产", petAssert); } var dietRec = CookingRecord.Get(MsgDTO.FromQQ); if (!dietRec.LearndDietMenu.IsNullOrEmpty() || !dietRec.CookedDietDic.IsNullOrEmpty() || !dietRec.FlavoringDic.IsNullOrEmpty()) { var dietAssert = dietRec.LearndDietMenu.Sum(menu => HonorSvc.FindHonor(CookingDietSvc[menu].ExchangeHonor).Items.Sum(item => item.Price)); dietAssert += dietRec.CookedDietDic.Sum(diet => CookingDietSvc[diet.Key].EstimatedPrice * diet.Value); dietAssert += dietRec.FlavoringDic.Sum(p => p.Value) * 20; resultDic.Add("烹饪资产", dietAssert); } var msg = "请查阅你的资产评估报告:\r\n" + $"{string.Join("\r\n", resultDic.Select(rd => $"{rd.Key}:{rd.Value.CurencyFormat()}"))}" + $"\r\n总资产:{resultDic.Sum(p => p.Value).CurencyFormat()}"; MsgSender.PushMsg(MsgDTO, msg, true); return(true); }