Пример #1
0
        public static int AASStateGet(GamePlayer player)
        {
            int userID = player.PlayerCharacter.ID;
            bool result = true;
            player.IsAASInfo = false;
            player.IsMinor = true;

            using (ProduceBussiness db = new ProduceBussiness())
            {
                String ID = db.GetASSInfoSingle(userID);
                if (ID != "")
                {
                    player.IsAASInfo = true;
                    result = false;
                    int Age = Convert.ToInt32(ID.Substring(6, 4));
                    int month = Convert.ToInt32(ID.Substring(10, 2));

                    if (DateTime.Now.Year.CompareTo(Age + 18) > 0 || (DateTime.Now.Year.CompareTo(Age + 18) == 0 && DateTime.Now.Month.CompareTo(month) >= 0))
                        player.IsMinor = false;
                }
            }
            //int now=  DateTime.Now.Month;

            if (result && player.PlayerCharacter.IsFirst != 0 && player.PlayerCharacter.DayLoginCount < 1 && ISASSon)
            {
                player.Out.SendAASState(result);
            }

            //if (player.IsMinor || !player.IsAASInfo && ISASSon)
            //{
                player.Out.SendAASControl(AntiAddictionMgr.ISASSon, player.IsAASInfo, player.IsMinor);
            //}
            return 0;
        }
        public static string Bulid(HttpContext context)
        {
            bool value = false;
            string message = "Fail";

            XElement result = new XElement("Result");

            try
            {
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    StrengthenInfo[] infos = db.GetAllStrengthen();
                    foreach (StrengthenInfo info in infos)
                    {
                        result.Add(Road.Flash.FlashUtils.CreateStrengthenInfo(info));
                    }
                }

                value = true;
                message = "Success!";
            }
            catch (Exception ex)
            {
                log.Error("ItemStrengthenList", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));
            //return result.ToString(false);
            return csFunction.CreateCompressXml(context, result, "ItemStrengthenList", true);
        }
Пример #3
0
        public static string Bulid(HttpContext context)
        {
            bool value = false;
            string message = "Fail!";

            XElement result = new XElement("Result");
            try
            {
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    XElement template = new XElement("ItemTemplate");
                    ItemTemplateInfo[] items = db.GetAllGoods();
                    foreach (ItemTemplateInfo g in items)
                    {
                        template.Add(FlashUtils.CreateItemInfo(g));
                    }
                    result.Add(template);                    
                    value = true;
                    message = "Success!";
                }
            }
            catch
            { }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));

            //csFunction.CreateCompressXml(context, result, "TemplateAlllist1", false);
            return csFunction.CreateCompressXml(context, result, "TemplateAlllist", true);

        }
Пример #4
0
        private static bool LoadFusion(Dictionary<string, FusionInfo> fusion)
        {
            using (ProduceBussiness db = new ProduceBussiness())
            {
                FusionInfo[] infos = db.GetAllFusion();
                foreach (FusionInfo info in infos)
                {
                    List<int> list = new List<int>();
                    list.Add(info.Item1);
                    list.Add(info.Item2);
                    list.Add(info.Item3);
                    list.Add(info.Item4);
                    list.Add(info.Formula);
                    list.Sort();

                    StringBuilder items = new StringBuilder();
                    foreach (int i in list)
                    {
                        if (i == 0)
                            continue;
                        items.Append(i);
                    }

                    string key = items.ToString();

                    if (!fusion.ContainsKey(key))
                    {
                        fusion.Add(key, info);
                    }
                }
            }

            return true;
        }
Пример #5
0
        public static string Bulid(HttpContext context)
        {
            bool value = false;
            string message = "Fail!";

            XElement result = new XElement("Result");
            try
            {
                using (ProduceBussiness db = new ProduceBussiness())
                {                    
                    XElement Store = new XElement("Store");
                    ShopItemInfo[] shop = db.GetALllShop();
                    foreach (ShopItemInfo s in shop)
                    {                        
                        Store.Add(FlashUtils.CreateShopInfo(s));                     
                    }                    
                    result.Add(Store);
                    value = true;
                    message = "Success!";
                }
            }
            catch
            { }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));
            
            return csFunction.CreateCompressXml(context, result, "ShopItemList", true);

        }
Пример #6
0
        public static string Bulid(HttpContext context)
        {
            bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");

            try
            {
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    NpcInfo[] infos = db.GetAllNPCInfo();
                    foreach (NpcInfo info in infos)
                    {
                        result.Add(FlashUtils.CreatNPCInfo(info));
                    }

                    value = true;
                    message = "Success!";
                }
            }
            catch (Exception ex)
            {
                log.Error("Load NPCInfoList is fail!", ex);
            }

            result.Add(new XAttribute("vaule", value));
            result.Add(new XAttribute("message", message));

            return csFunction.CreateCompressXml(context, result, "NPCInfoList", true);
        }
Пример #7
0
        public static string Bulid(HttpContext context)
        {
            bool value = false;
            string message = "Fail!";
            XElement result = new XElement("Result");

            try
            {
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    QuestInfo[] quests = db.GetALlQuest();
                    QuestAwardInfo[] questgoods = db.GetAllQuestGoods();
                    QuestConditionInfo[] questcondiction = db.GetAllQuestCondiction();
                    QuestRateInfo[] questrate = db.GetAllQuestRate();
                    foreach (QuestInfo quest in quests)
                    {
                        //添加任务模板
                        XElement temp_xml = FlashUtils.CreateQuestInfo(quest);

                        //添加任何条件
                        IEnumerable temp_questcondiction = questcondiction.Where(s => s.QuestID == quest.ID);
                        foreach (QuestConditionInfo item1 in temp_questcondiction)
                        {
                            temp_xml.Add(FlashUtils.CreateQuestCondiction(item1));
                        }

                        //添加任务奖励
                        IEnumerable temp_questgoods = questgoods.Where(s => s.QuestID == quest.ID);
                        foreach (QuestAwardInfo item2 in temp_questgoods)
                        {
                            temp_xml.Add(FlashUtils.CreateQuestGoods(item2));
                        }
                        //<Rate BindMoneyRate="1|1|1|1" ExpRate="1.5|2|2.5|3" GoldRate="1.5|2|2.5|3" ExploitRate="1.5|2|2.5|3" CanOneKeyFinishTime="3" />
                        result.Add(temp_xml);
                    }
                    foreach (QuestRateInfo quest in questrate)
                    {
                        XElement temp_xml1 = FlashUtils.CreateQuestRate(quest);
                        result.Add(temp_xml1);
                    }
                    value = true;
                    message = "Success!";
                }
            }
            catch (Exception ex)
            {
                log.Error("QuestList", ex);
            }

            result.Add(new XAttribute("value", value));
            result.Add(new XAttribute("message", message));

            //return result.ToString(false);
            return csFunction.CreateCompressXml(context, result, "QuestList", true);
        }
Пример #8
0
 private static bool LoadProps(Dictionary<int, ItemTemplateInfo> allProp)
 {
     using (ProduceBussiness db = new ProduceBussiness())
     {
         ItemTemplateInfo[] list = db.GetSingleCategory(10);
         foreach (ItemTemplateInfo p in list)
         {
             allProp.Add(p.TemplateID, p);
         }
     }
     return true;
 }
Пример #9
0
 private static Dictionary<int, BallConfigInfo> LoadFromDatabase()
 {
     Dictionary<int, BallConfigInfo> list = new Dictionary<int, BallConfigInfo>();
     using (ProduceBussiness db = new ProduceBussiness())
     {
         BallConfigInfo[] BallConfigInfos = db.GetAllBallConfig();
         foreach (BallConfigInfo b in BallConfigInfos)
         {
             if (!list.ContainsKey(b.TemplateID))
             {
                 list.Add(b.TemplateID, b);
             }
         }
     }
     return list;
 }
Пример #10
0
        private static Dictionary<int, MissionInfo> LoadFromDatabase()
        {
            Dictionary<int, MissionInfo> dic = new Dictionary<int, MissionInfo>();
            using (ProduceBussiness db = new ProduceBussiness())
            {
                MissionInfo[] infos = db.GetAllMissionInfo();
                foreach (MissionInfo info in infos)
                {
                    if (!dic.ContainsKey(info.Id))
                    {
                        dic.Add(info.Id, info);
                    }
                }
            }

            return dic;
        }
Пример #11
0
        public static Dictionary<int, RefineryInfo> LoadFromBD()
        {
            List<RefineryInfo> infos = new List<RefineryInfo>();
            Dictionary<int, RefineryInfo> Temp_Refinery = new Dictionary<int, RefineryInfo>();


            using (ProduceBussiness db = new ProduceBussiness())
            {

                infos = db.GetAllRefineryInfo();

                foreach (RefineryInfo info in infos)
                {


                    //List<int> list = new List<int>();

                    //list.Add(info.RefineryID);
                    //list.Add(info.Item1);
                    //list.Add(info.Item2);
                    //list.Add(info.Item3);
                    //list.Add(info.Item4);

                    //list.Sort();

                    //StringBuilder Items = new StringBuilder();

                    //foreach (int i in list)
                    //{
                    //    Items.Append(i);
                    //}

                    //string key = Items.ToString();

                    if (!Temp_Refinery.ContainsKey(info.RefineryID))
                    {
                        Temp_Refinery.Add(info.RefineryID, info);
                    }
                }
            }

            return Temp_Refinery;
        }
Пример #12
0
        private static Dictionary<int, NpcInfo> LoadFromDatabase()
        {
            Dictionary<int, NpcInfo> list = new Dictionary<int, NpcInfo>();

            using (ProduceBussiness db = new ProduceBussiness())
            {
                NpcInfo[] infos = db.GetAllNPCInfo();

                foreach (NpcInfo info in infos)
                {
                    if (!list.ContainsKey(info.ID))
                    {
                        list.Add(info.ID, info);
                    }
                }
            }

            return list;
        }
Пример #13
0
 public static Dictionary<int, List<AchievementRewardInfo>> LoadAchievementRewardInfoDB(Dictionary<int, AchievementInfo> achievementInfos)
 {
     Dictionary<int, List<AchievementRewardInfo>> dictionary = new Dictionary<int, List<AchievementRewardInfo>>();
     using (ProduceBussiness bussiness = new ProduceBussiness())
     {
         AchievementRewardInfo[] aLlAchievementReward = bussiness.GetALlAchievementReward();
         using (Dictionary<int, AchievementInfo>.ValueCollection.Enumerator enumerator = achievementInfos.Values.GetEnumerator())
         {
             Func<AchievementRewardInfo, bool> predicate = null;
             AchievementInfo achievementInfo;
             while (enumerator.MoveNext())
             {
                 achievementInfo = enumerator.Current;
                 if (predicate == null)
                 {
                     predicate = s => s.AchievementID == achievementInfo.ID;
                 }
                 IEnumerable<AchievementRewardInfo> source = aLlAchievementReward.Where<AchievementRewardInfo>(predicate);
                 dictionary.Add(achievementInfo.ID, source.ToList<AchievementRewardInfo>());
             }
         }
     }
     return dictionary;
 }
Пример #14
0
        private static bool LoadStrengthen(Dictionary<int, StrengthenInfo> strengthen, Dictionary<int, StrengthenInfo> RefineryStrengthen)
        {
            using (ProduceBussiness db = new ProduceBussiness())
            {
                StrengthenInfo[] infos = db.GetAllStrengthen();

                StrengthenInfo[] Refineryinfos = db.GetAllRefineryStrengthen();

                StrengthenGoodsInfo[] StrengthGoodInfos = db.GetAllStrengthenGoodsInfo();

                foreach (StrengthenInfo info in infos)
                {
                    if (!strengthen.ContainsKey(info.StrengthenLevel))
                    {
                        strengthen.Add(info.StrengthenLevel, info);
                    }
                }
                foreach (StrengthenInfo info in Refineryinfos)
                {
                    if (!RefineryStrengthen.ContainsKey(info.StrengthenLevel))
                    {
                        RefineryStrengthen.Add(info.StrengthenLevel, info);
                    }
                }

                foreach (StrengthenGoodsInfo info in StrengthGoodInfos)
                {
                    if (!Strengthens_Goods.ContainsKey(info.ID))
                    {
                        Strengthens_Goods.Add(info.ID, info);
                    }
                }
            }

            return true;
        }
Пример #15
0
        private static bool LoadBall(Dictionary<int, BallInfo> balls,Dictionary<int, Tile> ballTile)
        {
            using (ProduceBussiness db = new ProduceBussiness())
            {
                BallInfo[] ballInfos = db.GetAllBall();
                foreach (BallInfo b in ballInfos)
                {
                    if (!balls.ContainsKey(b.ID))
                    {
                        balls.Add(b.ID, b);

                        Tile shape = null;
                        string file = string.Format("bomb\\{0}.bomb", b.ID);
                        if (File.Exists(file))
                        {
                            shape = new Tile(file,false);
                        }

                        if (shape != null)
                        {
                            ballTile.Add(b.ID, shape);
                        }
                        else
                        {
                            if (b.ID != 1 && b.ID != 2 && b.ID != 3)
                            {
                                if (log.IsErrorEnabled)
                                    log.Error("Ball's file is not exist!");
                                return false;
                            }
                        }
                    }
                }
            }

            if (!balls.ContainsKey(0))
            {
                BallInfo temp = new BallInfo();
                temp.ID = 0;
                temp.Power = 1;
                temp.Radii = 60;
                temp.Amount = 1;
                balls.Add(0, temp);
            }

            return true;
        }
Пример #16
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            AASInfo info = new AASInfo();
            info.UserID = client.Player.PlayerCharacter.ID;
            bool result = false;
            bool rlt = false;

            bool isclosed = packet.ReadBoolean();
            if (isclosed)
            {
                info.Name = "";
                info.IDNumber = "";
                info.State = 0;
                result = true;
            }
            else 
            {
                info.Name = packet.ReadString();
                info.IDNumber = packet.ReadString();
                result = CheckIDNumber(info.IDNumber);
                if (info.IDNumber != "")
                {
                    client.Player.IsAASInfo = true;
                    //result = false;
                    int Age = Convert.ToInt32(info.IDNumber.Substring(6, 4));
                    int month = Convert.ToInt32(info.IDNumber.Substring(10, 2));
                    if (DateTime.Now.Year.CompareTo(Age + 18) > 0 || (DateTime.Now.Year.CompareTo(Age + 18) == 0 && DateTime.Now.Month.CompareTo(month) >= 0))
                        client.Player.IsMinor = false;

                }
                if (info.Name != "" && result)
                {
                    info.State = 1;
                }
                else
                {
                    info.State = 0;
                }

            }

            if (result)
            {
                client.Out.SendAASState(false);
                client.Out.SendAASControl(false, client.Player.IsAASInfo, client.Player.IsMinor);
                using (ProduceBussiness db = new ProduceBussiness())
                {
                    rlt = db.AddAASInfo(info);
                    client.Out.SendAASInfoSet(rlt);
                }
            }

            if (rlt && (info.State == 1) )
            {
                ItemTemplateInfo rewardItem = Bussiness.Managers.ItemMgr.FindItemTemplate(11019);
                if (rewardItem != null)
                {
                    ItemInfo item = ItemInfo.CreateFromTemplate(rewardItem, 1, (int)ItemAddType.Other);
                    if (item != null)
                    {
                        item.IsBinds = true;
                        AbstractInventory bg = client.Player.GetItemInventory(item.Template);
                        if (bg.AddItem(item, bg.BeginSlot))
                        {
                            client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.Success", item.Template.Name));
                            
                        }
                        else
                        {
                            client.Out.SendMessage(eMessageType.ChatNormal, LanguageMgr.GetTranslation("ASSInfoSetHandle.NoPlace"));
                        }
                    }
                }

            }
            return 0;
        }
Пример #17
0
        private static bool LoadDailyAward(Dictionary<int, DailyAwardInfo> awards)
        {
            using (ProduceBussiness db = new ProduceBussiness())
            {
                DailyAwardInfo[] infos = db.GetAllDailyAward();
                foreach (DailyAwardInfo info in infos)
                {
                    if(!awards.ContainsKey(info.ID))
                    {
                        awards.Add(info.ID, info);
                    }
                }
            }

            return true;
        }
Пример #18
0
 public static Dictionary<int, List<AchievementConditionInfo>> LoadAchievementConditionInfoDB(Dictionary<int, AchievementInfo> achievementInfos)
 {
     Dictionary<int, List<AchievementConditionInfo>> dictionary = new Dictionary<int, List<AchievementConditionInfo>>();
     using (ProduceBussiness bussiness = new ProduceBussiness())
     {
         AchievementConditionInfo[] aLlAchievementCondition = bussiness.GetALlAchievementCondition();
         using (Dictionary<int, AchievementInfo>.ValueCollection.Enumerator enumerator = achievementInfos.Values.GetEnumerator())
         {
             Func<AchievementConditionInfo, bool> predicate = null;
             AchievementInfo achievementInfo;
             while (enumerator.MoveNext())
             {
                 achievementInfo = enumerator.Current;
                 if (predicate == null)
                 {
                     predicate = s => s.AchievementID == achievementInfo.ID;
                 }
                 IEnumerable<AchievementConditionInfo> source = aLlAchievementCondition.Where<AchievementConditionInfo>(predicate);
                 dictionary.Add(achievementInfo.ID, source.ToList<AchievementConditionInfo>());
                 if (source != null)
                 {
                     foreach (AchievementConditionInfo info in source)
                     {
                         if (!m_distinctCondition.Contains(info.CondictionType))
                         {
                             m_distinctCondition.Add(info.CondictionType, info.CondictionType);
                         }
                     }
                 }
             }
         }
         foreach (AchievementConditionInfo info2 in aLlAchievementCondition)
         {
             int condictionType = info2.CondictionType;
             int item = info2.Condiction_Para2;
             if (!m_recordLimit.ContainsKey(condictionType))
             {
                 m_recordLimit.Add(condictionType, new List<int>());
             }
             if (!m_recordLimit[condictionType].Contains(item))
             {
                 m_recordLimit[condictionType].Add(item);
             }
         }
         foreach (int num in m_recordLimit.Keys)
         {
             m_recordLimit[num].Sort();
         }
     }
     return dictionary;
 }
Пример #19
0
 public static Dictionary<int, AchievementInfo> LoadAchievementInfoDB()
 {
     Dictionary<int, AchievementInfo> dictionary = new Dictionary<int, AchievementInfo>();
     using (ProduceBussiness bussiness = new ProduceBussiness())
     {
         AchievementInfo[] aLlAchievement = bussiness.GetALlAchievement();
         foreach (AchievementInfo info in aLlAchievement)
         {
             if (!dictionary.ContainsKey(info.ID))
             {
                 dictionary.Add(info.ID, info);
             }
         }
     }
     return dictionary;
 }
Пример #20
0
        public void VaneLoading()
        {
            ThreadSafeRandom rand = new ThreadSafeRandom();

            using (ProduceBussiness db = new ProduceBussiness())
            {
                int cindex = rand.Next(4);
                int[] start = new int[] { 0, 10, 20, 30, 40 };
                int[] end = new int[] { 10, 20, 30, 40, 50 };
                for (int wind_id = start[cindex]; wind_id <= end[cindex]; wind_id++)
                {
                    VaneInfo vaneInfos = db.GetSingleVane(wind_id);
                    if (wind_id == start[cindex])
                    {
                        SendGameWindPic((byte)vaneInfos.VaneId2, vaneInfos.Param2);
                    }
                    else
                    {
                        SendGameWindPic((byte)vaneInfos.VaneId3, vaneInfos.Param3);
                    }
                }

            }
            //string[] digitals = new string[] {".", "1", "2", "3", "4", "5", "6", "7", "8", "9","0" };
            //for (int wind_id = 0; wind_id < 11; wind_id++)
            //{
            //    byte id =(byte)wind_id;
            //    byte[] windPic = CheckCode.CreateVane(digitals[wind_id], wind_id);
            //    SendGameWindPic(id, windPic);
            //}
        }
Пример #21
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn pkg;
            int num2;
            int num3;
            var business = new Bussiness.ProduceBussiness();

            if (client.Lottery != -1)
            {
                client.Out.SendMessage(eMessageType.Normal, "Rương đang hoạt động!");
                return 1;
            }
            int num = new Random().Next(0, listRandomitem.Count - 1);
            client.Lottery = num;
            int num4 = packet.ReadByte();
            int slot = packet.ReadInt();
            int templateId = packet.ReadInt();
            int money = 0;
            int gold = 0;
            int giftToken = 0;
            int medal = 0;
            PlayerInventory inventory = client.Player.GetInventory((eBageType)num4);
            PlayerInventory propBag = client.Player.PropBag;
            ItemInfo item = propBag.GetItemByTemplateID(0, 11456); //búa đập lu
            ItemInfo itemAt = inventory.GetItemAt(slot);
            List<ItemInfo> infos = new List<ItemInfo>();

            if ((itemAt != null) && (itemAt.TemplateID == 112019))
            {
                client.tempData = "start";
                if (itemAt.Count > 1)
                {
                    itemAt.Count--;
                    propBag.UpdateItem(itemAt);
                }
                else
                {
                    propBag.RemoveItem(itemAt);
                }
                pkg = new GSPacketIn((byte)ePackageType.LOTTERY_ALTERNATE_LIST, client.Player.PlayerId);
                foreach (int num10 in listRandomitem[num])
                {
                    pkg.WriteInt(num10);
                    pkg.WriteBoolean(false);
                    pkg.WriteByte(1);
                    pkg.WriteByte(1);
                }
                client.Out.SendTCP(pkg);
                return 1;
            }

            if ((((templateId != 11252) && (templateId != 11257)) && ((templateId != 11258) && (templateId != 11259))) && (templateId != 11260))
            {
                if (templateId != 112047 && templateId != 112100 && templateId != 112101)
                {
                    int num12 = 0;
                    List<int> list9 = new List<int>();
                    List<ItemInfo> list10 = new List<ItemInfo>();
                    foreach (int num10 in listTemplate)
                    {
                        int itemCount = propBag.GetItemCount(0, num10);
                        if (itemCount != 0)
                        {
                            num12 += itemCount;
                            list9.Add(num10);
                            ItemTemplateInfo goods = ItemMgr.FindItemTemplate(num10);
                            list10.Add(ItemInfo.CreateFromTemplate(goods, 1, 105));
                        }
                    }
                    if (list10.Count > 0)
                    {
                        int num14 = new Random().Next(0, list10.Count);
                        ItemInfo info5 = list10[num14];
                        int[] bag = new int[3];
                        this.OpenUpItem(info5.Template.Data, bag, infos, ref gold, ref money, ref giftToken, ref medal);
                        if (infos.Count > 0)
                        {
                            pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId);
                            pkg.WriteBoolean(true);
                            num3 = 1;
                            pkg.WriteInt(num3);
                            for (num2 = 0; num2 < num3; num2++)
                            {
                                pkg.WriteString(infos[0].Template.Name);
                                pkg.WriteInt(infos[0].TemplateID);
                                pkg.WriteInt(4);
                                pkg.WriteBoolean(false);
                            }
                            client.Out.SendTCP(pkg);
                            inventory.AddItem(infos[0]);
                            ItemInfo info6 = propBag.GetItemByTemplateID(0, info5.TemplateID);
                            if (info6.Count > 0)
                            {
                                info6.Count--;
                                propBag.UpdateItem(info6);
                            }
                            else
                            {
                                propBag.RemoveItem(info6);
                            }
                        }
                    }
                    client.Lottery = -1;
                    return 1;
                }

                else
                {
                    ItemInfo itemByTemplateID = propBag.GetItemByTemplateID(0, templateId);

                    if ((itemByTemplateID != null) && (item != null))
                    {
                        Console.WriteLine("User open ItemBoxID: " + itemByTemplateID.TemplateID);
                        if (itemByTemplateID.Count > 1)
                        {
                            itemByTemplateID.Count--;
                            propBag.UpdateItem(itemByTemplateID);
                        }
                        else
                        {
                            propBag.RemoveItem(itemByTemplateID);
                        }
                        if (item.Count > 4)
                        {
                            item.Count -= 4;
                            propBag.UpdateItem(item);
                        }
                        else
                        {
                            propBag.RemoveItem(item);
                        }
                        ThreadSafeRandom random = new ThreadSafeRandom();
                        int num15 = random.Next(100) * random.Next(100);
                        num2 = 0;
                        foreach (int num16 in RandomForGetItem)
                        {
                            if (num15 < (num16 * num16))
                            {
                                break;
                            }
                            num2++;
                        }
                        pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId);
                        pkg.WriteBoolean(true);
                        ItemInfo info9 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(listItemRandomForBox[num2]), 1, 105);
                        //ItemInfo info9 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(business.GetSingleItemsBox(itemByTemplateID.TemplateID)[num2].TemplateId), 1, 105);
                        num3 = 1;
                        pkg.WriteInt(num3);
                        pkg.WriteString(client.Player.PlayerCharacter.NickName);
                        //pkg.WriteInt(business.GetSingleItemsBox(itemByTemplateID.TemplateID)[num2].TemplateId);
                        pkg.WriteInt(listItemRandomForBox[num2]);
                        pkg.WriteInt(4);
                        pkg.WriteBoolean(false);
                        client.Out.SendTCP(pkg);
                        info9.BeginDate = DateTime.Now;
                        info9.ValidDate = 7;
                        info9.RemoveDate = DateTime.Now.AddDays(7.0);
                        inventory.AddItem(info9);
                    }

                }
            }
            else
            {
                List<int> list2 = new List<int>();
                switch (templateId)
                {
                    case 11252:
                        {
                            List<int> list3 = new List<int> {
                            0x1fa8, 0x2bcc, 0x2edd, 0x2e7f, 0x1b6e, 0x2b1f, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d,
                            0x2e7e, 0x2e7f, 0x2edd, 0x2e81
                         };
                            list2 = list3;
                            break;
                        }
                    case 11257:
                        {
                            List<int> list4 = new List<int> {
                            0x1fa8, 0x1f44, 0x1f46, 0x1f4e, 0x1fa7, 0x1b6e, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d,
                            0x2e7e, 0x2e7f, 0x2e80, 0x2e81
                         };
                            list2 = list4;
                            break;
                        }
                    case 11258:
                        {
                            List<int> list5 = new List<int> {
                            0x2b10, 0x2b0f, 0x2b04, 0x2b00, 0x23f2, 0x2072, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d,
                            0x23f3, 0x2e7f, 0x2e80, 0x2e81
                         };
                            list2 = list5;
                            break;
                        }
                    case 11259:
                        {
                            List<int> list6 = new List<int> {
                            0x2b10, 0x2b0f, 0x1b6e, 0x1b5e, 0x23f2, 0x2072, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x1b61, 0x36c2, 0x36c4, 0x1b67, 0x36c8, 0x2e7d,
                            0x23f3, 0x2e7f, 0x2e80, 0x2e81
                         };
                            list2 = list6;
                            break;
                        }
                    case 11260:
                        {
                            List<int> list7 = new List<int> {
                            0x1fa8, 0x2bcc, 0x2e80, 0x2e7f, 0x2b1d, 0x2b1f, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d,
                            0x2e7e, 0x2e7f, 0x2e80, 0x2e81
                         };
                            list2 = list7;
                            break;
                        }
                    default:
                        {
                            List<int> list8 = new List<int> {
                            0x1b72, 0x20d2, 0x1b6e, 0x11261, 0x23f2, 0x1124d, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x2b00, 0x36c2, 0x36c4, 0x1b67, 0x36c8, 0x2e7d,
                            0x23f3, 0x2e82, 0x334a, 0x334e
                         };
                            list2 = list8;
                            break;
                        }
                }
                int num11 = new Random().Next(0, list2.Count - 1);
                ItemInfo info3 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(list2[num11]), 1, 105);
                pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId);
                pkg.WriteBoolean(true);
                num3 = 1;
                pkg.WriteInt(num3);
                for (num2 = 0; num2 < num3; num2++)
                {
                    pkg.WriteString(info3.Template.Name);
                    pkg.WriteInt(info3.TemplateID);
                    pkg.WriteInt(4);
                    pkg.WriteBoolean(false);
                }
                client.Out.SendTCP(pkg);
                inventory.AddItem(info3);
                ItemInfo info4 = client.Player.PropBag.GetItemByTemplateID(0, templateId);
                if (info4.Count > 1)
                {
                    info4.Count--;
                    client.Player.PropBag.UpdateItem(info4);
                }
                else
                {
                    client.Player.PropBag.RemoveItem(info4);
                }
                client.Lottery = -1;
                return 1;
            }
            client.Lottery = -1;
            return 1;
        }
Пример #22
0
 public static void LoadItemRecordTypeInfoDB()
 {
     using (ProduceBussiness bussiness = new ProduceBussiness())
     {
         ItemRecordTypeInfo[] allItemRecordType = bussiness.GetAllItemRecordType();
         foreach (ItemRecordTypeInfo info in allItemRecordType)
         {
             if (!m_ItemRecordTypeInfo.Contains(info.RecordID))
             {
                 m_ItemRecordTypeInfo.Add(info.RecordID, info.Name);
             }
         }
     }
 }
Пример #23
0
        //, bool sendToClient)
        public byte GetVane(int Wind, int param)
        {
            byte vane_id = 0;
            //byte[] imageData = null;
            using (ProduceBussiness db = new ProduceBussiness())
            {
                VaneInfo vaneInfos = db.GetSingleVane(Math.Abs(Wind));
                switch (param)
                {
                    case 1:
                    vane_id = (byte)vaneInfos.VaneId1;
                    //imageData = vaneInfos.Param1;
                    break;

                    case 2:
                    vane_id = (byte)vaneInfos.VaneId2;
                    //imageData = vaneInfos.Param2;
                    break;

                    case 3:
                    vane_id = (byte)vaneInfos.VaneId3;
                    //imageData = vaneInfos.Param3;
                    break;
                }
                //if (sendToClient)
                // {
                //    SendGameWindPic(vane_id, imageData);
                //}
            }
            return vane_id;
        }
Пример #24
0
        public int HandlePacket(GameClient client, GSPacketIn packet)
        {
            GSPacketIn pkg;
            int        num2;
            int        num3;
            var        business = new Bussiness.ProduceBussiness();

            if (client.Lottery != -1)
            {
                client.Out.SendMessage(eMessageType.Normal, "Rương đang hoạt động!");
                return(1);
            }
            int num = new Random().Next(0, listRandomitem.Count - 1);

            client.Lottery = num;
            int             num4       = packet.ReadByte();
            int             slot       = packet.ReadInt();
            int             templateId = packet.ReadInt();
            int             money      = 0;
            int             gold       = 0;
            int             giftToken  = 0;
            int             medal      = 0;
            PlayerInventory inventory  = client.Player.GetInventory((eBageType)num4);
            PlayerInventory propBag    = client.Player.PropBag;
            ItemInfo        item       = propBag.GetItemByTemplateID(0, 11456); //búa đập lu
            ItemInfo        itemAt     = inventory.GetItemAt(slot);
            List <ItemInfo> infos      = new List <ItemInfo>();

            if ((itemAt != null) && (itemAt.TemplateID == 112019))
            {
                client.tempData = "start";
                if (itemAt.Count > 1)
                {
                    itemAt.Count--;
                    propBag.UpdateItem(itemAt);
                }
                else
                {
                    propBag.RemoveItem(itemAt);
                }
                pkg = new GSPacketIn((byte)ePackageType.LOTTERY_ALTERNATE_LIST, client.Player.PlayerId);
                foreach (int num10 in listRandomitem[num])
                {
                    pkg.WriteInt(num10);
                    pkg.WriteBoolean(false);
                    pkg.WriteByte(1);
                    pkg.WriteByte(1);
                }
                client.Out.SendTCP(pkg);
                return(1);
            }

            if ((((templateId != 11252) && (templateId != 11257)) && ((templateId != 11258) && (templateId != 11259))) && (templateId != 11260))
            {
                if (templateId != 112047 && templateId != 112100 && templateId != 112101)
                {
                    int             num12  = 0;
                    List <int>      list9  = new List <int>();
                    List <ItemInfo> list10 = new List <ItemInfo>();
                    foreach (int num10 in listTemplate)
                    {
                        int itemCount = propBag.GetItemCount(0, num10);
                        if (itemCount != 0)
                        {
                            num12 += itemCount;
                            list9.Add(num10);
                            ItemTemplateInfo goods = ItemMgr.FindItemTemplate(num10);
                            list10.Add(ItemInfo.CreateFromTemplate(goods, 1, 105));
                        }
                    }
                    if (list10.Count > 0)
                    {
                        int      num14 = new Random().Next(0, list10.Count);
                        ItemInfo info5 = list10[num14];
                        int[]    bag   = new int[3];
                        this.OpenUpItem(info5.Template.Data, bag, infos, ref gold, ref money, ref giftToken, ref medal);
                        if (infos.Count > 0)
                        {
                            pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId);
                            pkg.WriteBoolean(true);
                            num3 = 1;
                            pkg.WriteInt(num3);
                            for (num2 = 0; num2 < num3; num2++)
                            {
                                pkg.WriteString(infos[0].Template.Name);
                                pkg.WriteInt(infos[0].TemplateID);
                                pkg.WriteInt(4);
                                pkg.WriteBoolean(false);
                            }
                            client.Out.SendTCP(pkg);
                            inventory.AddItem(infos[0]);
                            ItemInfo info6 = propBag.GetItemByTemplateID(0, info5.TemplateID);
                            if (info6.Count > 0)
                            {
                                info6.Count--;
                                propBag.UpdateItem(info6);
                            }
                            else
                            {
                                propBag.RemoveItem(info6);
                            }
                        }
                    }
                    client.Lottery = -1;
                    return(1);
                }

                else
                {
                    ItemInfo itemByTemplateID = propBag.GetItemByTemplateID(0, templateId);

                    if ((itemByTemplateID != null) && (item != null))
                    {
                        Console.WriteLine("User open ItemBoxID: " + itemByTemplateID.TemplateID);
                        if (itemByTemplateID.Count > 1)
                        {
                            itemByTemplateID.Count--;
                            propBag.UpdateItem(itemByTemplateID);
                        }
                        else
                        {
                            propBag.RemoveItem(itemByTemplateID);
                        }
                        if (item.Count > 4)
                        {
                            item.Count -= 4;
                            propBag.UpdateItem(item);
                        }
                        else
                        {
                            propBag.RemoveItem(item);
                        }
                        ThreadSafeRandom random = new ThreadSafeRandom();
                        int num15 = random.Next(100) * random.Next(100);
                        num2 = 0;
                        foreach (int num16 in RandomForGetItem)
                        {
                            if (num15 < (num16 * num16))
                            {
                                break;
                            }
                            num2++;
                        }
                        pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId);
                        pkg.WriteBoolean(true);
                        ItemInfo info9 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(listItemRandomForBox[num2]), 1, 105);
                        //ItemInfo info9 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(business.GetSingleItemsBox(itemByTemplateID.TemplateID)[num2].TemplateId), 1, 105);
                        num3 = 1;
                        pkg.WriteInt(num3);
                        pkg.WriteString(client.Player.PlayerCharacter.NickName);
                        //pkg.WriteInt(business.GetSingleItemsBox(itemByTemplateID.TemplateID)[num2].TemplateId);
                        pkg.WriteInt(listItemRandomForBox[num2]);
                        pkg.WriteInt(4);
                        pkg.WriteBoolean(false);
                        client.Out.SendTCP(pkg);
                        info9.BeginDate  = DateTime.Now;
                        info9.ValidDate  = 7;
                        info9.RemoveDate = DateTime.Now.AddDays(7.0);
                        inventory.AddItem(info9);
                    }
                }
            }
            else
            {
                List <int> list2 = new List <int>();
                switch (templateId)
                {
                case 11252:
                {
                    List <int> list3 = new List <int> {
                        0x1fa8, 0x2bcc, 0x2edd, 0x2e7f, 0x1b6e, 0x2b1f, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d,
                        0x2e7e, 0x2e7f, 0x2edd, 0x2e81
                    };
                    list2 = list3;
                    break;
                }

                case 11257:
                {
                    List <int> list4 = new List <int> {
                        0x1fa8, 0x1f44, 0x1f46, 0x1f4e, 0x1fa7, 0x1b6e, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d,
                        0x2e7e, 0x2e7f, 0x2e80, 0x2e81
                    };
                    list2 = list4;
                    break;
                }

                case 11258:
                {
                    List <int> list5 = new List <int> {
                        0x2b10, 0x2b0f, 0x2b04, 0x2b00, 0x23f2, 0x2072, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d,
                        0x23f3, 0x2e7f, 0x2e80, 0x2e81
                    };
                    list2 = list5;
                    break;
                }

                case 11259:
                {
                    List <int> list6 = new List <int> {
                        0x2b10, 0x2b0f, 0x1b6e, 0x1b5e, 0x23f2, 0x2072, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x1b61, 0x36c2, 0x36c4, 0x1b67, 0x36c8, 0x2e7d,
                        0x23f3, 0x2e7f, 0x2e80, 0x2e81
                    };
                    list2 = list6;
                    break;
                }

                case 11260:
                {
                    List <int> list7 = new List <int> {
                        0x1fa8, 0x2bcc, 0x2e80, 0x2e7f, 0x2b1d, 0x2b1f, 0x2b21, 0x2b23, 0x2b25, 0x2b27, 0x36c0, 0x36c2, 0x36c4, 0x36c6, 0x36c8, 0x2e7d,
                        0x2e7e, 0x2e7f, 0x2e80, 0x2e81
                    };
                    list2 = list7;
                    break;
                }

                default:
                {
                    List <int> list8 = new List <int> {
                        0x1b72, 0x20d2, 0x1b6e, 0x11261, 0x23f2, 0x1124d, 0x2b21, 0x2b23, 0x23f2, 0x2b27, 0x2b00, 0x36c2, 0x36c4, 0x1b67, 0x36c8, 0x2e7d,
                        0x23f3, 0x2e82, 0x334a, 0x334e
                    };
                    list2 = list8;
                    break;
                }
                }
                int      num11 = new Random().Next(0, list2.Count - 1);
                ItemInfo info3 = ItemInfo.CreateFromTemplate(ItemMgr.FindItemTemplate(list2[num11]), 1, 105);
                pkg = new GSPacketIn((byte)ePackageType.CADDY_GET_AWARDS, client.Player.PlayerId);
                pkg.WriteBoolean(true);
                num3 = 1;
                pkg.WriteInt(num3);
                for (num2 = 0; num2 < num3; num2++)
                {
                    pkg.WriteString(info3.Template.Name);
                    pkg.WriteInt(info3.TemplateID);
                    pkg.WriteInt(4);
                    pkg.WriteBoolean(false);
                }
                client.Out.SendTCP(pkg);
                inventory.AddItem(info3);
                ItemInfo info4 = client.Player.PropBag.GetItemByTemplateID(0, templateId);
                if (info4.Count > 1)
                {
                    info4.Count--;
                    client.Player.PropBag.UpdateItem(info4);
                }
                else
                {
                    client.Player.PropBag.RemoveItem(info4);
                }
                client.Lottery = -1;
                return(1);
            }
            client.Lottery = -1;
            return(1);
        }