public void LotteryClickItem(LotteryItem item) { if (item.isBusy && item.NameOfBusy != g.deviceID) { Inform_item.SetActive(true); _InfText.text = string.Format(LangSystem.lng.listL[15], item.id, item.NameOfBusy); //_InfText.text = string.Format("Билет {0} занят игроком {1}", item.id, item.NameOfBusy); // print(string.Format("ячейка {0} занята игроком {1}", item.id, item.NameOfBusy)); } else if (!item.isBusy) { int money; if (lotType != 3) { money = g.silver; } else { money = g.gold; } if (money >= price) { g.LotteryConfirm.SetActive(true); g.LotteryConfirm.transform.GetChild(4).GetChild(0).GetChild(0).GetComponent <Text>().text = item.id.ToString(); // выводим номер id на табло g.LotteryConfirm.transform.GetChild(3).GetComponent <Button>().onClick.RemoveAllListeners(); g.LotteryConfirm.transform.GetChild(3).GetComponent <Button>().onClick.AddListener(delegate { ConfirmLotteryItem(item.id, g.deviceID, g.color[1], g.botIcon[1]); }); // подтверждаем выбор } else { g.noMoney.SetActive(true); } } }
private static void LogOpen(Character character, Container container, LotteryItem lotteryItem) { var b = TransactionLogEvent.Builder().SetTransactionType(TransactionType.LotteryOpen) .SetCharacter(character) .SetContainer(container) .SetItem(lotteryItem); character.LogTransaction(b); }
public static void Load() { MySqlCommand command = new MySqlCommand(MySqlCommandType.SELECT); command.Select("lottery"); MySqlReader reader = new MySqlReader(command); while (reader.Read()) { LotteryItem item = new LotteryItem(); item.Rank = reader.ReadInt32("rank"); item.Chance = reader.ReadInt32("chance"); item.Name = reader.ReadString("prize_name"); item.ID = reader.ReadUInt32("prize_item"); item.Color = reader.ReadByte("color"); item.Sockets = reader.ReadByte("hole_num"); item.Plus = reader.ReadByte("addition_lev"); LotteryItems.Add(item); } reader.Close(); Console.WriteLine("Lottery items loaded."); }
/// <summary> /// 更新奖品配置 /// </summary> /// <param name="context"></param> private void UpdateLotteryItem(HttpContext context) { //验证权限 int moduleID = 312; AdminPermission adminPer = new AdminPermission(userExt, moduleID); if (!adminPer.GetPermission((long)Permission.Edit)) { ajv.msg = "非法操作,无操作权限"; context.Response.Write(ajv.SerializeToJson()); return; } int itemIndex = GameRequest.GetFormInt("id", 0); string itemType = GameRequest.GetFormString("ItemType"); string itemQuota = GameRequest.GetFormString("ItemQuota"); string itemRate = GameRequest.GetFormString("ItemRate"); //验证ID if (itemIndex == 0) { ajv.msg = "非法操作,无效的奖品索引"; context.Response.Write(ajv.SerializeToJson()); return; } //验证类型 if (!Utils.Validate.IsPositiveInt(itemType)) { ajv.msg = "请输入正确的奖品类型"; context.Response.Write(ajv.SerializeToJson()); return; } //验证数量 if (!Utils.Validate.IsPositiveInt(itemQuota)) { ajv.msg = "请输入正确的奖品数量"; context.Response.Write(ajv.SerializeToJson()); return; } //验证中奖几率 if (!Utils.Validate.IsPositiveInt(itemRate)) { ajv.msg = "请输入正确的中奖几率"; context.Response.Write(ajv.SerializeToJson()); return; } LotteryItem model = new LotteryItem(); model.ItemIndex = itemIndex; model.ItemType = Convert.ToInt32(itemType); model.ItemQuota = Convert.ToInt32(itemQuota); model.ItemRate = Convert.ToInt32(itemRate); int result = FacadeManage.aideTreasureFacade.UpdateLotteryItem(model); if (result > 0) { ajv.msg = "修改成功"; ajv.SetValidDataValue(true); } else { ajv.msg = "修改失败"; } context.Response.Write(ajv.SerializeToJson()); }
public static void WorkProcess() { Console.WriteLine("开奖程序已开启 \r\n"); Random rnd = new Random(); int[] minItems = { 1, 2, 3 }; int[] allItems = { 1, 2, 3, 4, 5, 6, 7, 8 }; int[] items; //string[] names = { "兵", "炮", "傌", "俥", "相", "仕", "帥", "棋王" }; int timeNum = 0; int totalCount = 0; try { LotteryItem liBll = new LotteryItem(); List <Model.LotteryItem> liList = liBll.GetList(1, 1000, out totalCount, "", null); if (liList == null || liList.Count == 0) { Console.WriteLine("系统需要预先设置开奖元素,已终止执行!"); Console.ReadLine(); return; } LotterySln.BLL.RunLottery rlBll = new LotterySln.BLL.RunLottery(); LotterySln.BLL.UserBetLottery ublBll = new LotterySln.BLL.UserBetLottery(); LotterySln.BLL.UserPoint uBll = new LotterySln.BLL.UserPoint(); while (true) { timeNum++; if (timeNum > 10) { timeNum = 0; } if (timeNum < 8) { items = minItems; } else { items = allItems; } //处于最大的预备时间 DateTime maxCurrDate = DateTime.Now; //上一期期数 int lastPeriod = 0; //上一期开奖时间 DateTime lastRunTime = DateTime.MinValue; //上一次执行时间 DateTime currRunTime = DateTime.MinValue; //上期已开奖的数字 int lastNum = -1; //当前期ID object numberId = null; DateTime currTime = DateTime.Now; if (currTime < DateTime.Parse(currTime.ToString("yyyy-MM-dd")).AddHours(9)) { currTime = DateTime.Parse(currTime.ToString("yyyy-MM-dd")).AddHours(9); } List <Model.RunLottery> rlList = rlBll.GetList(1, 6, out totalCount, "", null); if (rlList == null || rlList.Count == 0) { //每期都要保证有5期是预设奖期,进行投注 for (int i = 1; i <= 5; i++) { double currMin = i * 5; Model.RunLottery rlModel = new Model.RunLottery(); rlModel.LotteryNum = string.Empty; rlModel.RunDate = currTime.AddMinutes(currMin); rlModel.Status = 0; rlModel.LastUpdatedDate = currTime.AddMinutes(currMin); rlBll.Insert(rlModel); } //睡眠一分钟 Thread.Sleep(30000); } else { #region 序非第一次运行 //获取当前即将开奖的期 Model.RunLottery currModel = null; //将获取上一期开奖时间和开奖数字 List <Model.RunLottery> lastList = rlList.FindAll(x => x.Status == 1); if (lastList != null && lastList.Count > 0) { Model.RunLottery lastModel = lastList.OrderByDescending(x => x.Period).First(); if (lastModel != null) { lastRunTime = lastModel.RunDate; lastNum = Int32.Parse(lastModel.LotteryNum); lastPeriod = lastModel.Period; } } List <Model.RunLottery> currReadyList = rlList.FindAll(x => x.Status == 0); if (currReadyList != null && currReadyList.Count > 0) { //获取当前最大开奖时间 currModel = currReadyList.OrderByDescending(x => x.Period).First(); maxCurrDate = currModel.RunDate; //获取当前即将开奖的期 currModel = currReadyList.OrderBy(x => x.Period).First(); if (currModel != null) { numberId = currModel.NumberID; currRunTime = currModel.RunDate; } } //如果已控制了开奖结果,则直接开奖,否则系统随机开奖 if (currModel != null && !string.IsNullOrEmpty(currModel.LotteryNum)) { #region 控制开奖 int currNum = Int32.Parse(currModel.LotteryNum); //对应赔率 decimal fixRatio = liList.Find(x => x.ItemCode == currNum.ToString()).FixRatio; TimeSpan spaceTs = currRunTime.AddMilliseconds(-8000) - DateTime.Now; if (spaceTs.TotalMilliseconds > 0) { Thread.Sleep(spaceTs); } int betNum = 0; //已投注数 decimal totalPointNum = 0; //棋子总数 int winnerNum = 0; //中奖人数 decimal winPointNum = 0; //中奖支出棋子总数 //提前处理投注等问题 List <Model.UserBetLottery> ublList = ublBll.GetList(1, 10000000, out totalCount, "and RunLotteryID = '" + numberId + "' ", null); if (ublList != null && ublList.Count > 0) { betNum = ublList.Count; totalPointNum = ublList.Sum(x => x.TotalPointNum); foreach (Model.UserBetLottery ublModel in ublList) { //判断是否中奖 if (ublModel.ItemAppend.IndexOf(currNum.ToString()) > -1) { decimal dWinPointNum = 0; string[] currItemArr = ublModel.ItemAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] currBetNumArr = ublModel.BetNumAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int currItemArrLen = currItemArr.Length; for (int i = 0; i < currItemArrLen; i++) { if (currItemArr[i] == currNum.ToString()) { dWinPointNum = fixRatio * int.Parse(currBetNumArr[i]); } } //中奖支出棋子 winPointNum = winPointNum + dWinPointNum; ublModel.WinPointNum = dWinPointNum; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { ublBll.Update(ublModel); Model.UserPoint uModel = uBll.GetModelByUser(ublModel.UserID); if (uModel != null) { uModel.PointNum = uModel.PointNum + dWinPointNum; uBll.Update(uModel); } scope.Complete(); } } } //计算中奖人数 winnerNum = ublList.Where(x => x.WinPointNum > 0).GroupBy(x => x.UserID).Count(); } spaceTs = currRunTime.AddMilliseconds(-1000) - DateTime.Now; if (spaceTs.TotalMilliseconds > 0) { Thread.Sleep(spaceTs); } currModel.Status = 1; currModel.LastUpdatedDate = DateTime.Now; currModel.BetNum = betNum; currModel.TotalPointNum = totalPointNum; currModel.WinnerNum = winnerNum; currModel.WinPointNum = winPointNum; rlBll.Update(currModel); //每天最多开奖结束时间为第二天14:00 int h = maxCurrDate.Hour; if (h > 1 && h <= 2) { maxCurrDate = DateTime.Parse(maxCurrDate.ToString("yyyy-MM-dd")).AddHours(9); } else { maxCurrDate = maxCurrDate.AddMinutes(5); } Model.RunLottery rlModel = new Model.RunLottery(); rlModel.LotteryNum = string.Empty; rlModel.RunDate = maxCurrDate; rlModel.Status = 0; rlModel.LastUpdatedDate = maxCurrDate; rlBll.Insert(rlModel); Console.WriteLine("第{0}期 开奖结果 {1} 开奖时间 {2} 系统时间 {3}", currModel.Period, currNum, currModel.RunDate, currModel.LastUpdatedDate); #endregion } else { #region 系统随机开奖 //保证开奖,避免当前期开的奖与上一期的相同 while (true) { int currNum = rnd.Next(1, items.Length); //对应赔率 decimal fixRatio = liList.Find(x => x.ItemCode == currNum.ToString()).FixRatio; //尽量避免当前期开的奖与上一期的相同 if (currNum != lastNum) { TimeSpan spaceTs = currRunTime.AddMilliseconds(-8000) - DateTime.Now; if (spaceTs.TotalMilliseconds > 0) { Thread.Sleep(spaceTs); } int betNum = 0; //已投注数 decimal totalPointNum = 0; //棋子总数 int winnerNum = 0; //中奖人数 decimal winPointNum = 0; //中奖支出棋子总数 //提前处理投注等问题 List <Model.UserBetLottery> ublList = ublBll.GetList(1, 10000000, out totalCount, "and RunLotteryID = '" + numberId + "' ", null); if (ublList != null && ublList.Count > 0) { betNum = ublList.Count; totalPointNum = ublList.Sum(x => x.TotalPointNum); foreach (LotterySln.Model.UserBetLottery ublModel in ublList) { //判断是否中奖 if (ublModel.ItemAppend.IndexOf(currNum.ToString()) > -1) { decimal dWinPointNum = 0; string[] currItemArr = ublModel.ItemAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); string[] currBetNumArr = ublModel.BetNumAppend.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); int currItemArrLen = currItemArr.Length; for (int i = 0; i < currItemArrLen; i++) { if (currItemArr[i] == currNum.ToString()) { dWinPointNum = fixRatio * int.Parse(currBetNumArr[i]); } } //中奖支出棋子 winPointNum = winPointNum + dWinPointNum; ublModel.WinPointNum = dWinPointNum; using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required)) { ublBll.Update(ublModel); Model.UserPoint uModel = uBll.GetModelByUser(ublModel.UserID); if (uModel != null) { uModel.PointNum = uModel.PointNum + dWinPointNum; uBll.Update(uModel); } scope.Complete(); } } } //计算中奖人数 winnerNum = ublList.Where(x => x.WinPointNum > 0).GroupBy(x => x.UserID).Count(); } spaceTs = currRunTime.AddMilliseconds(-1000) - DateTime.Now; if (spaceTs.TotalMilliseconds > 0) { Thread.Sleep(spaceTs); } currModel.LotteryNum = currNum.ToString(); currModel.Status = 1; currModel.LastUpdatedDate = DateTime.Now; currModel.BetNum = betNum; currModel.TotalPointNum = totalPointNum; currModel.WinnerNum = winnerNum; currModel.WinPointNum = winPointNum; rlBll.Update(currModel); //每天最多开奖结束时间为第二天14:00 int h = maxCurrDate.Hour; if (h > 1 && h <= 2) { maxCurrDate = DateTime.Parse(maxCurrDate.ToString("yyyy-MM-dd")).AddHours(9); } else { maxCurrDate = maxCurrDate.AddMinutes(5); } Model.RunLottery rlModel = new Model.RunLottery(); rlModel.LotteryNum = string.Empty; rlModel.RunDate = maxCurrDate; rlModel.Status = 0; rlModel.LastUpdatedDate = maxCurrDate; rlBll.Insert(rlModel); Console.WriteLine("第{0}期 开奖结果 {1} 开奖时间 {2} 系统时间 {3}", currModel.Period, currNum, currModel.RunDate, currModel.LastUpdatedDate); break; } } #endregion } //每次开奖完后睡眠4分钟后继续循环,以便控制当前期开奖 Thread.Sleep(360000); #endregion } } } catch (Exception ex) { Console.WriteLine("程序发生了异常,原因:{0}", ex.Message); Console.ReadLine(); } }
public int UpdateLotteryItem(LotteryItem model) { return(this.aideTreasureData.UpdateLotteryItem(model)); }
// 更新界面中间 Item 显示 void UpdateCenterItem() { for (int i = 1; i <= ObjectSelf.GetInstance().lotteryitemmap.Count; i++) { if (ObjectSelf.GetInstance().lotteryitemmap.ContainsKey(i)) { LotteryItemlayer lotery = ObjectSelf.GetInstance().lotteryitemmap[i] as LotteryItemlayer; if (lotery != null) { GameObject item = m_ItemLayout.transform.GetChild(i - 1).gameObject; item.SetActive(true); string str = "treasure_content" + i.ToString(); item.transform.FindChild("LayerText").GetComponent <Text>().text = GameUtils.getString(str); GameObject Goods = item.transform.FindChild("Goods").gameObject; // goods if (ObjectSelf.GetInstance().mapkey == i) { item.transform.FindChild("BgIndex").gameObject.SetActive(true); } else { item.transform.FindChild("BgIndex").gameObject.SetActive(false); } int j = 0; foreach (var lotteryItem in lotery.lotteryitemlist) { LotteryItem lotItem = lotteryItem; RuintreasureTemplate temp = (RuintreasureTemplate)DataTemplate.GetInstance().m_RuintreasureTable.getTableData(lotteryItem.id); GameObject goods = Goods.transform.GetChild(lotItem.viewnum - 1).gameObject; goods.gameObject.SetActive(true); // 取消显示所有星级 GameObject starLevel = goods.transform.Find("UI_Star_Level").gameObject; starLevel.SetActive(false); for (int k = 0; k < 5; ++k) { starLevel.transform.GetChild(k).gameObject.SetActive(false); } if (lotItem.isget == 1) // 已领取 { GameObject reached = goods.transform.FindChild("Reached").gameObject; reached.SetActive(true); // 特殊事件,显示特殊字 if (lotItem.superid == 100001 || lotItem.superid == 100008 || lotItem.superid == 100009) { reached.transform.FindChild("TipsText").GetComponent <Text>().text = "X3"; } else if (lotItem.superid == 100002) { reached.transform.FindChild("TipsText").GetComponent <Text>().text = "X2"; } else { reached.transform.FindChild("TipsText").GetComponent <Text>().text = GameUtils.getString("shop_content29"); } } else { GameObject reached = goods.transform.FindChild("Reached").gameObject; reached.SetActive(false); } // 事件 if (temp.getType() == 2) { Image icon = goods.transform.FindChild("Icon").GetComponent <Image>(); icon.gameObject.SetActive(false); goods.transform.FindChild("qiyu").gameObject.SetActive(true); //icon.sprite = UIResourceMgr.LoadSprite(common.defaultPath + "UI_baozang_6"); //icon.sprite = Resources.Load<Sprite>(temp.getIcon()); goods.transform.FindChild("NumberText").gameObject.SetActive(false); } else // 物品 { goods.transform.FindChild("qiyu").gameObject.SetActive(false); Image icon = goods.transform.FindChild("Icon").GetComponent <Image>(); icon.gameObject.SetActive(true); //icon.sprite = Resources.Load<Sprite>("UI/Sprites/UI_baozang_6.png"); int ID = temp.getParameter1(); EM_OBJECT_CLASS type = GameUtils.GetObjectClassById(ID); if (type == EM_OBJECT_CLASS.EM_OBJECT_CLASS_COMMON || type == EM_OBJECT_CLASS.EM_OBJECT_CLASS_RUNE) // 道具 对应数据表26 { ItemTemplate itemTemp = (ItemTemplate)DataTemplate.GetInstance().m_ItemTable.getTableData(ID); icon.sprite = UIResourceMgr.LoadSprite(common.defaultPath + itemTemp.getIcon_s()); // 显示符文星级 if (type == EM_OBJECT_CLASS.EM_OBJECT_CLASS_RUNE) { int quality = itemTemp.getRune_quality(); GameObject star = goods.transform.Find("UI_Star_Level").gameObject; star.SetActive(true); for (int k = 0; k < quality; ++k) { star.transform.GetChild(k).gameObject.SetActive(true); } } //Debug.Log(i + " " + j + " EM_OBJECT_CLASS_COMMON " + temp.getId() + " " + itemTemp.getIcon_s() + " " + lotteryItem.id); } else if (type == EM_OBJECT_CLASS.EM_OBJECT_CLASS_RES) // 资源 对应数据表53 { ResourceindexTemplate resTemp = (ResourceindexTemplate)DataTemplate.GetInstance().m_ResourceindexTemplate.getTableData(ID); icon.sprite = UIResourceMgr.LoadSprite(common.defaultPath + resTemp.getIcon3()); //Debug.Log(i + " " + j + " EM_OBJECT_CLASS_RES " + temp.getId() + " " + resTemp.getIcon3() + " " + lotteryItem.id); } else { Debug.Log(i + " " + j + " other " + temp.getId() + " " + lotteryItem.id); } goods.transform.FindChild("NumberText").gameObject.SetActive(true); goods.transform.FindChild("NumberText").GetComponent <Text>().text = temp.getParameter2(); } j++; } } } } }