Esempio n. 1
0
        public static void Gifts_Req(InPacket lea, Client c)
        {
            int    ItemID        = lea.ReadInt();
            string ItemName      = lea.ReadString(62);
            string CharacterName = lea.ReadString(20);
            int    Type          = 1;

            if (CashShopFactory.GetItemData(ItemID) == null)
            {
                return;
            }

            c.Account.GamePoints -= CashShopFactory.GetItemData(ItemID).BargainPrice;
            c.Account.Save();

            dynamic datum = new Datum("gifts");

            datum.name     = CharacterName;
            datum.itemID   = ItemID;
            datum.itemName = ItemName;
            datum.receive  = 0;
            datum.Insert();

            CashShopPacket.Gifts(c, Type);
            CashShopPacket.MgameCash(c);
            CashShopPacket.GuiHonCash(c);
        }
Esempio n. 2
0
        public static void CheckName_Req(InPacket lea, Client c)
        {
            string Name    = lea.ReadString(20);
            bool   IsExist = Database.Exists("Characters", "name = '{0}'", Name);

            CashShopPacket.CheckName(c, IsExist ? 1 : 0);
        }
Esempio n. 3
0
        public static void CommodityToInventory_Req(InPacket lea, Client c)
        {
            var  chr    = c.Character;
            int  Slot   = lea.ReadInt();
            Item Source = chr.Items.getItem((byte)InventoryType.ItemType.Cash, (byte)Slot);

            if (Source.ItemID / 100000 == 90)
            {
                // 頭髮
                chr.Hair = Source.ItemID;
                chr.Items.Remove(Source.Type, Source.Slot);
                chr.Items.Save();
                CashShopPacket.CommodityToInventory(c);
                InventoryPacket.getInvenCash(c);
                InventoryHandler.UpdateInventory(c, (byte)InventoryType.ItemType.Equip);
                return;
            }
            else if (Source.ItemID / 100000 == 91)
            {
                // 眼睛
                chr.Eyes = Source.ItemID;
                chr.Items.Remove(Source.Type, Source.Slot);
                chr.Items.Save();
                CashShopPacket.CommodityToInventory(c);
                InventoryPacket.getInvenCash(c);
                InventoryHandler.UpdateInventory(c, (byte)InventoryType.ItemType.Equip);
                return;
            }
            else if (Source.ItemID / 100000 == 92 || Source.ItemID == 7820501)
            {
                // 寵物
                chr.Pets.Add(new Pet(Source.ItemID, 0, "", 1, 100, 100, 0, (byte)InventoryType.ItemType.Pet5,
                                     chr.Pets.GetNextFreeSlot(InventoryType.ItemType.Pet5)));
                chr.Items.Remove(Source.Type, Source.Slot);
                chr.Pets.Save();
                chr.Items.Save();
                CashShopPacket.CommodityToInventory(c);
                InventoryPacket.getInvenCash(c);
                InventoryHandler.UpdateInventory(c, (byte)InventoryType.ItemType.Pet5);
                return;
            }

            byte TargetType = InventoryType.getItemType(Source.ItemID);
            byte TargetSlot =
                chr.Items.GetNextFreeSlot((InventoryType.ItemType)InventoryType.getItemType(Source.ItemID));

            Source.Type = TargetType;
            Source.Slot = TargetSlot;
            chr.Items.Save();
            CashShopPacket.CommodityToInventory(c);
            InventoryPacket.getInvenCash(c);
            InventoryHandler.UpdateInventory(c, TargetType);
        }
Esempio n. 4
0
        public static void BuyCommodity_Req(InPacket lea, Client c)
        {
            int    ItemID   = lea.ReadInt();
            string ItemName = lea.ReadString(62);
            short  Quantity = 1;
            bool   IsLocked = true;

            var chr = c.Character;

            if (CashShopFactory.GetItemData(ItemID) == null)
            {
                return;
            }

            if (ItemID == 8842002)
            {
                Quantity = 10;
            }

            if (ItemID == 8841001 || ItemID == 8841002 || ItemID == 8841003 || ItemID == 8841004 || ItemID == 8841005)
            {
                Quantity = 20;
            }

            if (ItemID == 8890031 || ItemID == 8890037)             // 鞭炮 + 心花怒放
            {
                Quantity = 100;
            }

            if (ItemID / 100000 == 92 || ItemID == 8890031 || ItemID == 8890037)             // 寵物 + 鞭炮 + 心花怒放
            {
                IsLocked = false;
            }

            // 購買日誌
            dynamic datum = new Datum("BuyCommodityLog");

            datum.name     = chr.Name;
            datum.itemID   = ItemID;
            datum.itemName = ItemName;
            datum.Insert();

            c.Account.GamePoints -= CashShopFactory.GetItemData(ItemID).BargainPrice;
            c.Account.Save();

            chr.Items.Add(new Item(ItemID, IsLocked, 0, -1, (byte)InventoryType.ItemType.Cash,
                                   chr.Items.GetNextFreeSlot(InventoryType.ItemType.Cash), Quantity));
            chr.Items.Save();
            CashShopPacket.BuyCommodity(c);
            CashShopPacket.MgameCash(c);
            CashShopPacket.GuiHonCash(c);
            InventoryPacket.getInvenCash(c);
        }
Esempio n. 5
0
        public static void WarpToMap_Req(InPacket lea, Client gc)
        {
            int   CharacterID = lea.ReadInt();
            short MapX        = lea.ReadShort();
            short MapY        = lea.ReadShort();
            short PositionX   = lea.ReadShort();
            short PositionY   = lea.ReadShort();
            var   chr         = gc.Character;

            chr.MapX    = MapX;
            chr.MapY    = MapY;
            chr.PlayerX = PositionX;
            chr.PlayerY = PositionY;

            if (MapX == 77 && MapY == 1)
            {
                CashShopPacket.CashShopList1(gc); // 人物
                CashShopPacket.CashShopList2(gc); // 裝備
                CashShopPacket.CashShopList3(gc); // 能力
                CashShopPacket.CashShopList4(gc); // 靈物
                CashShopPacket.CashShopList5(gc); // 寶牌
                CashShopPacket.CashShopList6(gc);
                CashShopPacket.CashShopList7(gc); // 紅利積點
                CashShopPacket.CashShopList8(gc);
                CashShopPacket.CashShopList9(gc);
                CashShopPacket.MgameCash(gc);
                CashShopPacket.GuiHonCash(gc);

                // 接收禮物
                List <int> Gifts = new List <int>();

                foreach (dynamic datum in new Datums("Gifts").Populate())
                {
                    if (chr.Name.Equals(datum.name) && datum.receive == 0)
                    {
                        Gifts.Add(datum.itemID);
                        datum.receive = 1;
                        datum.Update("id = '{0}'", datum.id);
                    }
                }
                foreach (int ItemID in Gifts)
                {
                    chr.Items.Add(new Item(ItemID, true, 0, -1, (byte)InventoryType.ItemType.Cash, chr.Items.GetNextFreeSlot(InventoryType.ItemType.Cash)));
                    chr.Items.Save();
                }
                InventoryPacket.getInvenCash(gc);
                MapPacket.warpToMap(gc, chr, CharacterID, MapX, MapY, PositionX, PositionY);
                return;
            }

            Map Map = MapFactory.GetMap(MapX, MapY);

            MapPacket.warpToMap(gc, chr, CharacterID, MapX, MapY, PositionX, PositionY);

            if (Map.GetMapCharactersTotal() > 0)
            {
                foreach (Character All in Map.Characters)
                {
                    MapPacket.warpToMap(All.Client, chr, CharacterID, MapX, MapY, PositionX, PositionY);
                }

                MapPacket.createUser(gc, Map);
            }

            Map.Characters.Add(chr);

            //if ((MapX == 1 && MapY == 53) || (MapX == 1 && MapY == 54) || (MapX == 1 && MapY == 55))
            //    return;

            //if ((MapX == 10 && MapY == 63) || (MapX == 10 && MapY == 64))
            //{
            //    Monster Monster = new Monster(0, 1020001, 200, 10000, 10000, 0, 0, 1, 0xFF, 1, 0, 0, 0, 0, 0, 1, 0, 0, 1408, 659, true);
            //    Map.Monster.Add(Monster);
            //}

            MonsterPacket.createAllMonster(gc, Map, Map.Monster);

            int j = 0;

            for (int i = 0; i < 50; i++)
            {
                if (Map.Monster[i] != null)
                {
                    j++;
                }
            }

            //for (int i = 0; i < j; i++)
            //{
            //    foreach (Character All in map.Characters)
            //    {
            //        if (map.Monster[i].IsAlive == true)
            //            MonsterPacket.spawnMonster(All.Client, map.Monster[i], 0, 0, 0, 0);
            //    }
            //}

            //if (map.GetMapCharactersTotal() < 1)
            //{
            Map.ControlMonster(gc, j);
            //}

            //if (chr.IsFuring == true)
            //{
            //    foreach (Character All in Map.Characters)
            //    {
            //        StatusPacket.Fury(All.Client, chr, chr.FuringType);
            //    }
            //}
        }
Esempio n. 6
0
 public static void MgameCash_Req(InPacket lea, Client c)
 {
     CashShopPacket.MgameCash(c);
     CashShopPacket.GuiHonCash(c);
 }
Esempio n. 7
0
        public static void Game_Log_Req(InPacket lea, Client gc)
        {
            //int re = SearchBytes(lea.Content, new byte[] { 0x0 });
            string[]  data            = lea.ReadString(0x100 /*re*/).Split(new[] { (char)0x20 }, StringSplitOptions.None);
            int       encryptKey      = int.Parse(data[1]);
            string    username        = data[2];
            string    password        = data[4];
            int       selectCharacter = lea.ReadByte();
            IPAddress hostid          = lea.ReadIPAddress();

            gc.SetAccount(new Account(gc));

            try
            {
                gc.Account.Load(username);
                //var pe = new PasswordEncrypt(encryptKey);
                //string encryptPassword = pe.encrypt(gc.Account.Password, gc.RetryLoginCount > 0 ? password.ToCharArray() : null);

                if (password.Equals(gc.Account.Password))
                {
                    gc.Dispose();
                    Log.Error("Login Fail!");
                }
                else
                {
                    gc.Account.Characters = new List <Character>();
                    foreach (dynamic datum in new Datums("Characters").PopulateWith("id", "accountId = '{0}' ORDER BY position ASC", gc.Account.ID))
                    {
                        Character character = new Character(datum.id, gc);
                        character.Load(false);
                        character.IP = hostid;
                        gc.Account.Characters.Add(character);
                    }
                    gc.SetCharacter(gc.Account.Characters[selectCharacter]);
                }
                Log.Inform("Password = {0}", password);
                //Log.Inform("encryptKey = {0}", encryptKey);
                //Log.Inform("encryptPassword = {0}", encryptPassword);
            }
            catch (NoAccountException)
            {
                gc.Dispose();
                Log.Error("Login Fail!");
            }

            Character chr = gc.Character;

            chr.CharacterID = gc.CharacterID;
            MapFactory.AllCharacters.Add(chr);

            StatusPacket.UpdateHpMp(gc, 0, 0, 0, 0);
            GamePacket.FW_DISCOUNTFACTION(gc);
            StatusPacket.getStatusInfo(gc);
            InventoryPacket.getCharacterEquip(gc);
            SkillPacket.getSkillInfo(gc, chr.Skills.getSkills());
            QuestPacket.getQuestInfo(gc, chr.Quests.getQuests());
            GamePacket.getQuickSlot(gc, chr.Keymap);
            StoragePacket.getStoreInfo(gc);
            StoragePacket.getStoreMoney(gc);
            MapPacket.enterMapStart(gc);
            InventoryPacket.getInvenCash(gc);
            CashShopPacket.MgameCash(gc);
            CashShopPacket.GuiHonCash(gc);
            InventoryPacket.getInvenEquip(gc);
            InventoryPacket.getInvenEquip1(gc);
            InventoryPacket.getInvenEquip2(gc);
            InventoryPacket.getInvenSpend3(gc);
            InventoryPacket.getInvenOther4(gc);
            InventoryPacket.getInvenPet5(gc);
        }