コード例 #1
0
 private bool SetOutTimeItem(GoldAuctionItem AuctionItem)
 {
     try
     {
         if (AuctionItem.Lock || DateTime.Parse(AuctionItem.AuctionTime).AddHours((double)AuctionItem.LifeTime) > TimeUtil.NowDateTime())
         {
             return(true);
         }
         if (AuctionItem.BuyerData.m_RoleID != 0)
         {
             return(this.DisposeAward(AuctionItem));
         }
         AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(AuctionItem.AuctionSource);
         if (null == AuctionCfg)
         {
             LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]null == config AuctionSource = {0}", AuctionItem.AuctionSource), null, true);
             return(false);
         }
         int NextAuctiontype = AuctionCfg.GetNextAuction(AuctionItem.AuctionType);
         if (NextAuctiontype <= -1)
         {
             return(this.DisposeAward(AuctionItem));
         }
         AuctionItem.OldAuctionType = AuctionItem.AuctionType;
         AuctionItem.AuctionType    = NextAuctiontype;
         AuctionItem.AuctionTime    = TimeUtil.NowDataTimeString("yyyy-MM-dd HH:mm:ss");
         AuctionItem.UpDBWay        = 3;
         AuctionItem.LifeTime       = AuctionCfg.GetTimeByAuction(NextAuctiontype);
         this.S2CCache.Clear();
         if (this.SendUpdate2DB(AuctionItem))
         {
             LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]超时换拍卖行ProductionTime = {0}, AuctionSource={1},AuctionType={2}", AuctionItem.ProductionTime, AuctionItem.AuctionSource, AuctionItem.AuctionType), null, true);
             return(true);
         }
         LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]超时换拍卖行 db失败 ProductionTime = {0}, AuctionSource={1}", AuctionItem.ProductionTime, AuctionItem.AuctionSource), null, true);
         if (AuctionItem.LifeTime == -1)
         {
             LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GetTimeByAuction =-1 AuctionOrderEnum={0}", NextAuctiontype), null, true);
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
     return(false);
 }
コード例 #2
0
 private void InitFromDB()
 {
     try
     {
         for (int i = 1; i < 3; i++)
         {
             LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]InitFromDB AuctionID={0}", i), null, true);
             GetAuctionDBData DBData = Global.sendToDB <GetAuctionDBData, string>(2080, i.ToString(), 0);
             if (DBData == null || !DBData.Flag)
             {
                 LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GoldAuctionManager.InitFromDB DBData={0}, type={1}", null == DBData, i), null, true);
             }
             else
             {
                 foreach (GoldAuctionDBItem item in DBData.ItemList)
                 {
                     GoldAuctionItem temp = new GoldAuctionItem();
                     CopyData.CopyAuctionDB2Item(item, out temp);
                     AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(item.AuctionSource);
                     if (null == AuctionCfg)
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GetAuctionConfig null == config AuctionSource ={0}", ((AuctionEnum)item.AuctionSource).ToString()), null, true);
                     }
                     else
                     {
                         temp.LifeTime = AuctionCfg.GetTimeByAuction(i);
                         if (temp.LifeTime == -1)
                         {
                             LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GetTimeByAuction =-1 AuctionOrderEnum={0}", i), null, true);
                         }
                         else
                         {
                             this.AddNewAuctionItem(temp);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }
コード例 #3
0
 public static bool Copy2AuctionItemS2C(GoldAuctionItem sData, out AuctionItemS2C rData, string Seach, int Color)
 {
     rData = new AuctionItemS2C();
     try
     {
         rData.Goods = GlobalNew.ParseGoodsData(sData.StrGoods);
         int goodsID = rData.Goods.GoodsID;
         if (!string.IsNullOrEmpty(Seach))
         {
             List <int> goodsIDs = Global.StringToIntList(Seach, '#');
             if (goodsIDs.Find((int x) => x == goodsID) < 1)
             {
                 return(false);
             }
         }
         int color = Global.GetEquipColor(rData.Goods);
         if (Color > 0 && (1 << color - 1 & Color) == 0)
         {
             return(false);
         }
         rData.BuyRoleId      = sData.BuyerData.m_RoleID;
         rData.Price          = sData.BuyerData.Value;
         rData.AuctionItemKey = string.Format("{0}|{1}", sData.ProductionTime.Replace(':', ','), sData.AuctionSource);
         AuctionConfig cfg = GoldAuctionConfigModel.GetAuctionConfig(sData.AuctionSource);
         if (null != cfg)
         {
             rData.MaxPrice  = (long)cfg.MaxPrice;
             rData.UnitPrice = (long)cfg.UnitPrice;
         }
         rData.LastTime = TimeUtil.GetDiffTimeSeconds(DateTime.Parse(sData.AuctionTime).AddHours((double)sData.LifeTime), TimeUtil.NowDateTime(), false);
         return(true);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
     return(false);
 }
コード例 #4
0
 public static int LoadConfig()
 {
     try
     {
         Dictionary <int, AuctionConfig> _AuctionDict;
         GoldAuctionConfigModel.LoadAuctionData(out _AuctionDict);
         List <AuctionAwardConfig> _AuctionAwardList;
         GoldAuctionConfigModel.LoadAngelTempleAuctionAwardData(out _AuctionAwardList);
         lock (GoldAuctionConfigModel.AuctionDict)
         {
             GoldAuctionConfigModel.AuctionDict = _AuctionDict;
         }
         lock (GoldAuctionConfigModel.AuctionAwardList)
         {
             GoldAuctionConfigModel.AuctionAwardList = _AuctionAwardList;
         }
         return(1);
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
     return(0);
 }
コード例 #5
0
 public void KillBossAddAuction(int KillBossRole, long BossLife, List <AuctionRoleData> PointInfoList, AuctionEnum AuctionSource)
 {
     try
     {
         lock (this.AuctionMsgMutex)
         {
             AuctionAwardConfig AuctionAwardCfg = GoldAuctionConfigModel.RandAuctionAwardConfig();
             if (null == AuctionAwardCfg)
             {
                 LogManager.WriteLog(LogTypes.Error, "[ljl]KillBossAddAuction RandAuctionAwardConfig null == config", null, true);
             }
             else
             {
                 AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig((int)AuctionSource);
                 if (null == AuctionCfg)
                 {
                     LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]GoldAuctionConfigModel.GetAuctionConfig({0}) null == config", AuctionSource), null, true);
                 }
                 else
                 {
                     GoldAuctionItem item = new GoldAuctionItem();
                     item.AuctionSource      = (int)AuctionSource;
                     item.KillBossRoleID     = KillBossRole;
                     item.UpDBWay            = 2;
                     item.ProductionTime     = TimeUtil.NowDataTimeString("yyyy-MM-dd HH:mm:ss.fff");
                     item.BuyerData          = new AuctionRoleData();
                     item.BuyerData.m_RoleID = 0;
                     item.BuyerData.Value    = (long)AuctionCfg.OriginPrice;
                     int index = Global.GetRandomNumber(AuctionAwardCfg.StartValues, AuctionAwardCfg.EndValues) - 1;
                     index         = Math.Min(index, AuctionAwardCfg.strGoodsList.Count - 1);
                     item.StrGoods = AuctionAwardCfg.strGoodsList[index];
                     if (null == GlobalNew.ParseGoodsData(AuctionAwardCfg.strGoodsList[index]))
                     {
                         LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]null == item.Goods index={0}  ,  GoodsList.Count = {1}", index, AuctionAwardCfg.strGoodsList.Count), null, true);
                     }
                     else
                     {
                         item.BossLife = 0L;
                         foreach (AuctionRoleData PointInfo in PointInfoList)
                         {
                             item.BossLife += PointInfo.Value;
                             if (PointInfo.Value >= GameManager.systemParamsList.GetParamValueIntByName("AngelTempleAuction", -1))
                             {
                                 AuctionRoleData RoleData = new AuctionRoleData();
                                 CopyData.Copy <AuctionRoleData>(PointInfo, ref RoleData);
                                 item.RoleList.Add(RoleData);
                             }
                         }
                         if (item.BossLife < 1L)
                         {
                             item.BossLife = BossLife;
                         }
                         bool addFlag = false;
                         for (int i = 0; i < AuctionCfg.OrderList.Count; i++)
                         {
                             if (GoldAuctionManager.IsOpenAuction((AuctionOrderEnum)AuctionCfg.OrderList[i]))
                             {
                                 item.AuctionType = AuctionCfg.OrderList[i];
                                 item.LifeTime    = AuctionCfg.TimeList[i];
                                 if (item.AuctionType > 0 && item.AuctionType < 3)
                                 {
                                     if (this.GoldAuctionMgr.SendUpdate2DB(item))
                                     {
                                         this.GoldAuctionMgr.AddNewAuctionItem(item);
                                     }
                                     else
                                     {
                                         LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]新拍卖物品存库失败 未加入 time={0},AuctionSource={1}", item.ProductionTime, AuctionSource), null, true);
                                     }
                                     addFlag = true;
                                     break;
                                 }
                                 LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]AuctionType ={1} err,AuctionSource={0}", AuctionSource, item.AuctionType), null, true);
                             }
                         }
                         if (!addFlag)
                         {
                             int roleID = item.GetMaxmDamageID();
                             this.GoldAuctionMgr.SendItem(roleID, item.RoleList.Find((AuctionRoleData x) => x.m_RoleID == roleID), item, AuctionCfg);
                             LogManager.WriteLog(LogTypes.Info, string.Format("[ljl]新拍卖物品未加入 直接邮件发送给玩家第一名 time={0},AuctionSource={1}", item.ProductionTime, AuctionSource), null, true);
                         }
                     }
                 }
             }
         }
     }
     catch (Exception ex)
     {
         LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
     }
 }
コード例 #6
0
        private void SetGlodAuction(GameClient client, int nID, byte[] bytes, string[] cmdParams, ref int Info)
        {
            GoldAuctionItem item = null;

            Info = 0;
            try
            {
                int      type    = Convert.ToInt32(cmdParams[1]);
                string[] itemKey = cmdParams[2].Split(new char[]
                {
                    '|'
                });
                int Price = Convert.ToInt32(cmdParams[3]);
                if (itemKey == null || itemKey.Length != 2)
                {
                    Info = 3;
                }
                else
                {
                    string ProductionTime = itemKey[0].Replace(',', ':');
                    int    AuctionSource  = Convert.ToInt32(itemKey[1]);
                    if (type == 1 && client.ClientData.Faction < 1)
                    {
                        Info = 1;
                    }
                    AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(AuctionSource);
                    if (null == AuctionCfg)
                    {
                        LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]SetGlodAuction ({0}) null == config", AuctionSource), null, true);
                        Info = 4;
                    }
                    else
                    {
                        item = this.GoldAuctionMgr.GetGoldAuctionItem(type, ProductionTime, AuctionSource, true);
                        if (item == null || item.AuctionType != type)
                        {
                            Info = 9;
                        }
                        else if (client.ClientData.RoleID == item.BuyerData.m_RoleID)
                        {
                            Info = 11;
                        }
                        else if (item.BuyerData.m_RoleID == 0 && Price < AuctionCfg.OriginPrice)
                        {
                            Info = 5;
                        }
                        else if (Price < AuctionCfg.UnitPrice)
                        {
                            Info = 6;
                        }
                        else if ((long)Price <= item.BuyerData.Value)
                        {
                            Info = 10;
                        }
                        else if (!GameManager.ClientMgr.SubUserMoney(client, Price, "金团拍卖购买", false, false, false, false, DaiBiSySType.None))
                        {
                            Info = 7;
                        }
                        if (Info != 0)
                        {
                            this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource);
                        }
                        else
                        {
                            AuctionRoleData oldBuyerData = new AuctionRoleData();
                            CopyData.Copy <AuctionRoleData>(item.BuyerData, ref oldBuyerData);
                            bool upFlag   = false;
                            int  newBuyer = client.ClientData.RoleID;
                            item.BuyerData.Value      = (long)Price;
                            item.BuyerData.m_RoleID   = client.ClientData.RoleID;
                            item.BuyerData.m_RoleName = client.ClientData.RoleName;
                            item.BuyerData.ZoneID     = client.ClientData.ZoneID;
                            item.BuyerData.strUserID  = client.strUserID;
                            item.BuyerData.ServerId   = client.ServerId;
                            if (Price >= AuctionCfg.MaxPrice && AuctionCfg.MaxPrice > 0)
                            {
                                if (!this.GoldAuctionMgr.DisposeAward(item))
                                {
                                    Info = 8;
                                    LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]一口价 RoleId={0}, Price={1},itemKey={2} fail", newBuyer, Price, cmdParams[1]), null, true);
                                }
                                else
                                {
                                    this.GoldAuctionMgr.DelGoldAuction(item, "金团拍卖购买su");
                                    upFlag = true;
                                }
                            }
                            else if (!this.GoldAuctionMgr.UpdatePrice(item))
                            {
                                Info = 8;
                                LogManager.WriteLog(LogTypes.Error, string.Format("[ljl]更新价格 RoleId={0}, Price={1},itemKey={2} fail", newBuyer, Price, cmdParams[1]), null, true);
                            }
                            else
                            {
                                upFlag = true;
                            }
                            if (upFlag)
                            {
                                this.GoldAuctionMgr.ReturnOldAuctionMoney(oldBuyerData, item.StrGoods);
                            }
                            else
                            {
                                this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource);
                                GameManager.logDBCmdMgr.AddMessageLog(-1, "钻石", "金团购买失败扣除钻石", client.ClientData.RoleName, client.ClientData.RoleName, "减少", Price, client.ClientData.ZoneID, client.strUserID, -1, client.ServerId, "");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                if (null != item)
                {
                    this.GoldAuctionMgr.UnLock(item.ProductionTime, item.AuctionSource);
                }
                Info = 100;
                LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
            }
        }
コード例 #7
0
        public bool DisposeAward(GoldAuctionItem Item)
        {
            try
            {
                lock (this.AuctionMutex)
                {
                    if (null == Item)
                    {
                        return(false);
                    }

                    AuctionConfig AuctionCfg = GoldAuctionConfigModel.GetAuctionConfig(Item.AuctionSource);
                    if (null == AuctionCfg)
                    {
                        LogManager.WriteLog(LogTypes.Error,
                                            string.Format("[ljl]GoldAuctionConfigModel.GetAuctionConfig({0}) null == config",
                                                          (AuctionEnum)Item.AuctionSource), null, true);
                        return(false);
                    }

                    long averageNum = 0L;
                    int  minNum     = (int)GameManager.systemParamsList.GetParamValueIntByName("AngelTempleAuctionMin", 0);
                    if (minNum < 0)
                    {
                        LogManager.WriteLog(LogTypes.Error, "[ljl]AngelTempleAuctionMin < 0", null, true);
                        minNum = 1;
                    }

                    long delNum = 0L;
                    if (0 == Item.BuyerData.m_RoleID)
                    {
                        averageNum = 0L;
                        delNum     = Item.BuyerData.Value;
                    }
                    else if (Item.RoleList.Count < 1)
                    {
                        averageNum = 0L;
                    }
                    else if ((long)(minNum * Item.RoleList.Count) < Item.BuyerData.Value)
                    {
                        averageNum = (long)minNum;
                        delNum     = (long)Item.RoleList.Count * averageNum;
                    }
                    else if ((long)(minNum * Item.RoleList.Count) >= Item.BuyerData.Value)
                    {
                        averageNum = Item.BuyerData.Value / (long)Item.RoleList.Count;
                        delNum     = Item.BuyerData.Value;
                    }

                    Item.UpDBWay        = 1;
                    Item.OldAuctionType = Item.AuctionType;
                    this.S2CCache.Clear();
                    if (!this.SendUpdate2DB(Item))
                    {
                        Item.UpDBWay = 3;
                        return(false);
                    }

                    Item.BuyerData.Value -= delNum;
                    int AwardRole = Item.BuyerData.m_RoleID;
                    if (AwardRole > 0)
                    {
                        this.SendMoney(Item, averageNum, AuctionCfg);
                        this.SendItem(AwardRole, Item.BuyerData, Item, AuctionCfg);
                    }
                    else
                    {
                        AwardRole = Item.GetMaxmDamageID();
                        this.SendItem(AwardRole, Item.RoleList.Find((AuctionRoleData x) => x.m_RoleID == AwardRole),
                                      Item, AuctionCfg);
                    }
                }
            }
            catch (Exception ex)
            {
                LogManager.WriteLog(LogTypes.Exception, string.Format("[ljl]{0}", ex.ToString()), null, true);
                return(false);
            }
            return(true);
        }