private static void Bless(long QQNum, string BlessName, int BlessValue) { var response = PersonCacheRecord.Get(QQNum, "RandomFortune"); if (string.IsNullOrEmpty(response.Value)) { var randFor = GetRandomFortune(); var rf = new RandomFortuneCache() { QQNum = QQNum, FortuneValue = randFor, BlessName = BlessName, BlessValue = BlessValue }; response.Value = JsonConvert.SerializeObject(rf); response.ExpiryTime = CommonUtil.UntilTommorow(); response.Update(); } else { var model = JsonConvert.DeserializeObject <RandomFortuneCache>(response.Value); model.BlessName = BlessName; model.BlessValue = BlessValue; response.Value = JsonConvert.SerializeObject(model); response.ExpiryTime = CommonUtil.UntilTommorow(); response.Update(); } }
public bool LimitBonus(MsgInformationEx MsgDTO, object[] param) { var cache = PersonCacheRecord.Get(MsgDTO.FromQQ, "抽奖"); if (string.IsNullOrEmpty(cache.Value) || !int.TryParse(cache.Value, out var times) || times <= 0) { MsgSender.PushMsg(MsgDTO, "你没有抽奖机会!", true); return(false); } var items = HonorSvc.CurMonthLimitItems(); var item = items.ToDictionary(p => p, p => p.Rate).RandRated(); var session = new MsgSession(MsgDTO); session.Add($"恭喜你抽到了 【{item.Name}】*1"); session.Add($" {item.Description} "); var record = ItemCollectionRecord.Get(MsgDTO.FromQQ); var m = record.ItemIncome(item.Name); if (!string.IsNullOrEmpty(m)) { session.Add(m); } session.Send(); cache.Value = (times - 1).ToString(); cache.Update(); return(true); }
public bool GoldLimitBonus(MsgInformationEx MsgDTO, object[] param) { var osPerson = OSPerson.GetPerson(MsgDTO.FromQQ); if (osPerson.Golds < 500) { MsgSender.PushMsg(MsgDTO, $"你没有足够的金币兑换({osPerson.Golds.CurencyFormat()}/{500.CurencyFormat()})", true); return(false); } if (!WaiterSvc.WaitForConfirm_Gold(MsgDTO, 500)) { MsgSender.PushMsg(MsgDTO, "操作取消"); return(false); } osPerson.Golds -= 500; var cache = PersonCacheRecord.Get(MsgDTO.FromQQ, "抽奖"); if (!int.TryParse(cache.Value, out var times)) { times = 0; } times++; cache.Value = times.ToString(); osPerson.Update(); cache.Update(); MsgSender.PushMsg(MsgDTO, $"兑换成功,你现在共有{times}次抽奖机会,快使用 【抽奖】 命令试试看吧!", true); return(true); }
public bool TenLimitBonus(MsgInformationEx MsgDTO, object[] param) { var cache = PersonCacheRecord.Get(MsgDTO.FromQQ, "抽奖"); if (string.IsNullOrEmpty(cache.Value) || !int.TryParse(cache.Value, out var times) || times < 10) { MsgSender.PushMsg(MsgDTO, "你没有足够的抽奖机会!", true); return(false); } var itemsRateDic = HonorSvc.CurMonthLimitItems().ToDictionary(p => p, p => p.Rate); var randItems = SafeDictionary <string, int> .Empty; for (var i = 0; i < 10; i++) { var randItem = itemsRateDic.RandRated(); randItems[randItem.Name] += 1; } var itemColle = ItemCollectionRecord.Get(MsgDTO.FromQQ); foreach (var(name, count) in randItems.Data) { itemColle.ItemIncome(name, count); } var msg = $"恭喜你抽到了 {randItems.Data.Select(p => $"【{p.Key}】*{p.Value}").JoinToString(",")} !"; MsgSender.PushMsg(MsgDTO, msg, true); cache.Value = (times - 10).ToString(); cache.Update(); return(true); }
public bool BonusChance(MsgInformationEx MsgDTO, object[] param) { var aimNum = (long)param[0]; var personCache = PersonCacheRecord.Get(aimNum, "抽奖"); personCache.Value = int.TryParse(personCache.Value, out var times) ? (times + 1).ToString() : 1.ToString(); personCache.Update(); MsgSender.PushMsg(MsgDTO, "奖励已生效!"); return(true); }
private MajFortuneCache TodayFortune(long QQNum) { var cache = PersonCacheRecord.Get(QQNum, "MajFortune"); if (!string.IsNullOrEmpty(cache.Value)) { return(JsonConvert.DeserializeObject <MajFortuneCache>(cache.Value)); } var newFortune = this.NewFortune(QQNum); cache.Value = JsonConvert.SerializeObject(newFortune); cache.ExpiryTime = CommonUtil.UntilTommorow(); cache.Update(); return(newFortune); }
protected override void Sign(MsgInformationEx MsgDTO) { var sign = SignInSuccessiveRecord.Sign(MsgDTO.FromGroup, MsgDTO.FromQQ); var goldsGen = Math.Min(sign.SuccessiveDays * 5, 50); OSPerson.GoldIncome(MsgDTO.FromQQ, goldsGen); var indexNo = SignInGroupInfo.GetAndUpdate(MsgDTO.FromGroup); var msg = $"签到成功!你已连续签到 {sign.SuccessiveDays}天,获得 {goldsGen.CurencyFormat()}!\r\n本群签到排名:【No.{indexNo}】"; if (sign.SuccessiveDays % 10 == 0) { var cache = PersonCacheRecord.Get(MsgDTO.FromQQ, "抽奖"); cache.Value = !string.IsNullOrEmpty(cache.Value) && int.TryParse(cache.Value, out var times) ? (times + 1).ToString() : 1.ToString(); cache.Update(); msg += "\r\n恭喜你获得一次抽奖机会,快去试试吧(当日有效!)"; } MsgSender.PushMsg(MsgDTO, msg, true); }
public bool TarotFortune(MsgInformationEx MsgDTO, object[] param) { var cache = PersonCacheRecord.Get(MsgDTO.FromQQ, "TarotFortune"); TarotCacheModel fortune; if (string.IsNullOrEmpty(cache.Value)) { fortune = GetRandTarotFortune(); cache.Value = JsonConvert.SerializeObject(fortune); cache.ExpiryTime = CommonUtil.UntilTommorow(); cache.Update(); } else { fortune = JsonConvert.DeserializeObject <TarotCacheModel>(cache.Value); } SendTarotFortune(MsgDTO, fortune); return(true); }
public bool RandomFortune(MsgInformationEx MsgDTO, object[] param) { var response = PersonCacheRecord.Get(MsgDTO.FromQQ, "RandomFortune"); if (string.IsNullOrEmpty(response.Value)) { var randFor = GetRandomFortune(); var rf = new RandomFortuneCache { QQNum = MsgDTO.FromQQ, FortuneValue = randFor, BlessName = string.Empty, BlessValue = 0 }; RandBless(rf); ShowRandFortune(MsgDTO, rf); response.Value = JsonConvert.SerializeObject(rf); response.ExpiryTime = CommonUtil.UntilTommorow(); response.Update(); } else { ShowRandFortune(MsgDTO, JsonConvert.DeserializeObject <RandomFortuneCache>(response.Value)); } return(true); }