public void PlayerPutCard(GPlayer PL, Packet packet)
        {
            TCardData             Data;
            PlayerCardData        PLCard;
            PlayerCharacterData   PLCharacter;
            AddData               ItemData;
            PlayerTransactionData Transac;

            Data = (TCardData)packet.Read(new TCardData());

            PLCard      = PL.Inventory.ItemCard.GetCard(Data.CardIndex);
            PLCharacter = PL.Inventory.ItemCharacter.GetChar(Data.CharIndex, CharType.bIndex);


            if (PLCard == null || PLCharacter == null)
            {
                return;
            }

            if (!(PLCard.CardTypeID == Data.CardTypeID) || (!(PLCharacter.TypeID == Data.CharTypeID)))
            {
                return;
            }

            if (!(CardCheckPosition(Data.CardTypeID, Data.Position)))
            {
                return;
            }


            ItemData = PL.Inventory.Remove(Data.CardTypeID, 1, true);

            if (!ItemData.Status)
            {
                PL.SendResponse(new byte[] { 0x71, 0x02, 0xB3, 0xF9, 0x56, 0x00 });
                return;
            }
            if (PL.Inventory.ItemCharacter.Card.UpdateCard(PL.GetUID, PLCharacter.Index, PLCharacter.TypeID, ItemData.ItemTypeID, (byte)Data.Position, 0, 0).First().Key)
            {
                Transac = new PlayerTransactionData()
                {
                    Types        = 0xCB,
                    TypeID       = PLCharacter.TypeID,
                    Index        = PLCharacter.Index,
                    PreviousQuan = 0,
                    NewQuan      = 0,
                    UCC          = "",
                    CardTypeID   = Data.CardTypeID,
                    CharSlot     = (byte)Data.Position,
                };

                PL.Inventory.ItemTransaction.Add(Transac);

                PL.SendTransaction();

                PL.Response.Write(new byte[] { 0x71, 0x02, 0x00, 0x00, 0x00, 0x00 });
                PL.Response.Write(Data.CardTypeID);
                PL.SendResponse();
            }
        }
        public void PlayerCardRemove(GPlayer PL, Packet packet)
        {
            TCardRemove           Data;
            PlayerCardEquipData   CARDDATA;
            PlayerCharacterData   PLCharacter;
            AddData               ItemData;
            AddItem               ItemAdd;
            PlayerTransactionData Transac;


            Data = (TCardRemove)packet.Read(new TCardRemove());

            if (!(Data.RemoverTypeID == 0x1A0000C2))
            {
                PL.SendResponse(new byte[] { 0x73, 0x02, 0x62, 0x73, 0x55, 0x00 });
                return;
            }

            PLCharacter = PL.Inventory.ItemCharacter.GetChar(Data.CharIndex, CharType.bIndex);

            CARDDATA = PL.Inventory.ItemCharacter.Card.GetCard(PLCharacter.Index, Data.Slot);

            if (!(CARDDATA == null || CARDDATA.CARD_TYPEID == 0) || !(GetItemGroup((uint)CARDDATA.CARD_TYPEID) == 0x1F))
            {
                PL.SendResponse(new byte[] { 0x73, 0x02, 0x62, 0x73, 0x55, 0x00 });
                return;
            }


            ItemData = PL.Inventory.Remove(Data.RemoverTypeID, 1, true);

            if (!ItemData.Status)
            {
                PL.SendResponse(new byte[] { 0x73, 0x02, 0x62, 0x73, 0x55, 0x00 });

                return;
            }

            ItemAdd = new AddItem()
            {
                ItemIffId   = CARDDATA.CHAR_TYPEID,
                Transaction = true,
                Quantity    = 1,
                Day         = 0
            };
            PL.Inventory.AddItem(ItemAdd);

            if (PL.Inventory.ItemCharacter.Card.UpdateCard(PL.GetUID, PLCharacter.Index, PLCharacter.TypeID, 0, (byte)Data.Slot, 0, 0).First().Key)
            {
                Transac = new PlayerTransactionData()
                {
                    Types        = 0xCB,
                    TypeID       = PLCharacter.TypeID,
                    Index        = PLCharacter.Index,
                    PreviousQuan = 0,
                    NewQuan      = 0,
                    UCC          = "",
                    CardTypeID   = 0,
                    CharSlot     = (byte)Data.Slot,
                };

                PL.Inventory.ItemTransaction.Add(Transac);

                PL.SendTransaction();

                PL.Response.Write(new byte[] { 0x73, 0x00 });
                PL.Response.WriteUInt32(0);
                PL.Response.WriteUInt32(CARDDATA.CARD_TYPEID);
                PL.SendResponse();
            }
        }
示例#3
0
        public AddData AddItemToDB(AddItem ItemAddData)
        {
            Object TPlayerItemData;
            PlayerTransactionData Tran;
            AddData Result;

            Result = new AddData()
            {
                Status = false
            };
            var _db     = new PangyaEntities();
            var additem = _db.ProcAddItem((int)UID, (int)ItemAddData.ItemIffId, (int)ItemAddData.Quantity, IfCompare <byte>(IffEntry.IsSelfDesign(ItemAddData.ItemIffId), 1, 0), IffEntry.GetItemTimeFlag(ItemAddData.ItemIffId, ItemAddData.Day), (int)ItemAddData.Day).ToList();

            if (additem.Count > 0)
            {
                var dbdata = additem.FirstOrDefault();

                Tran = new PlayerTransactionData()
                {
                    Types = 2, Index = (uint)dbdata.IDX, TypeID = (uint)dbdata.iffTypeId, PreviousQuan = 0, NewQuan = (uint)dbdata.Quantity, UCC = dbdata.UCC_KEY
                };

                ItemTransaction.Add(Tran);
                try
                {
                    switch ((TITEMGROUP)GetPartGroup(ItemAddData.ItemIffId))
                    {
                    case TITEMGROUP.ITEM_TYPE_CHARACTER:
                    {
                        TPlayerItemData = new PlayerCharacterData();

                        ((PlayerCharacterData)(TPlayerItemData)).Index      = (uint)dbdata.IDX;
                        ((PlayerCharacterData)(TPlayerItemData)).TypeID     = (uint)dbdata.iffTypeId;
                        ((PlayerCharacterData)(TPlayerItemData)).HairColour = 0;
                        ((PlayerCharacterData)(TPlayerItemData)).GiftFlag   = 0;
                        ItemCharacter.CharacterAdd((PlayerCharacterData)(TPlayerItemData));

                        CharacterIndex = (uint)dbdata.IDX;
                        Result         = new AddData()
                        {
                            Status      = true,
                            ItemIndex   = ((PlayerCharacterData)(TPlayerItemData)).Index,
                            ItemTypeID  = ((PlayerCharacterData)(TPlayerItemData)).TypeID,
                            ItemOldQty  = 1,
                            ItemNewQty  = 1,
                            ItemUCCKey  = string.Empty,
                            ItemFlag    = 0,
                            ItemEndDate = DateTime.MinValue,
                        };
                    }
                    break;

                    case TITEMGROUP.ITEM_TYPE_AUX:
                    case TITEMGROUP.ITEM_TYPE_PART:
                    case TITEMGROUP.ITEM_TYPE_CLUB:
                    case TITEMGROUP.ITEM_TYPE_BALL:
                    case TITEMGROUP.ITEM_TYPE_USE:
                    {
                        TPlayerItemData = new PlayerItemData();
                        ((PlayerItemData)(TPlayerItemData)).ItemIndex     = (uint)dbdata.IDX;
                        ((PlayerItemData)(TPlayerItemData)).ItemTypeID    = (uint)dbdata.iffTypeId;
                        ((PlayerItemData)(TPlayerItemData)).ItemC0        = (ushort)dbdata.Quantity;
                        ((PlayerItemData)(TPlayerItemData)).ItemUCCUnique = dbdata.UCC_KEY;
                        ((PlayerItemData)(TPlayerItemData)).CreateNewItem();
                        // Add to inventory list
                        ItemWarehouse.ItemAdd((PlayerItemData)(TPlayerItemData));
                        // Set the result data
                        Result = new AddData()
                        {
                            Status      = true,
                            ItemIndex   = ((PlayerItemData)(TPlayerItemData)).ItemIndex,
                            ItemTypeID  = ((PlayerItemData)(TPlayerItemData)).ItemTypeID,
                            ItemOldQty  = 0,
                            ItemNewQty  = ItemAddData.Quantity,
                            ItemUCCKey  = ((PlayerItemData)(TPlayerItemData)).ItemUCCUnique,
                            ItemFlag    = 0,
                            ItemEndDate = null,
                        };
                    }
                    break;

                    case TITEMGROUP.ITEM_TYPE_CADDIE:
                    {
                        TPlayerItemData = new PlayerCaddieData();
                        ((PlayerCaddieData)(TPlayerItemData)).CaddieIdx     = (uint)dbdata.IDX;
                        ((PlayerCaddieData)(TPlayerItemData)).CaddieTypeId  = (uint)dbdata.iffTypeId;
                        ((PlayerCaddieData)(TPlayerItemData)).CaddieDateEnd = (DateTime)dbdata.END_DATE;
                        ((PlayerCaddieData)(TPlayerItemData)).CaddieAutoPay = 0;
                        ((PlayerCaddieData)(TPlayerItemData)).CaddieType    = (byte)dbdata.Flag;
                        // Add caddie to inventory list
                        ItemCaddie.CadieAdd((PlayerCaddieData)(TPlayerItemData));
                        // set the result data
                        Result = new AddData()
                        {
                            Status      = true,
                            ItemIndex   = ((PlayerCaddieData)(TPlayerItemData)).CaddieIdx,
                            ItemTypeID  = ((PlayerCaddieData)(TPlayerItemData)).CaddieTypeId,
                            ItemOldQty  = 0,
                            ItemNewQty  = 1,
                            ItemUCCKey  = string.Empty,
                            ItemFlag    = ((PlayerCaddieData)(TPlayerItemData)).CaddieType,
                            ItemEndDate = null,
                        };
                    }
                    break;

                    case TITEMGROUP.ITEM_TYPE_SKIN:
                    {
                        TPlayerItemData = new PlayerItemData();
                        ((PlayerItemData)(TPlayerItemData)).ItemIndex     = (uint)dbdata.IDX;
                        ((PlayerItemData)(TPlayerItemData)).ItemTypeID    = (uint)dbdata.iffTypeId;
                        ((PlayerItemData)(TPlayerItemData)).ItemC0        = (ushort)ItemAddData.Quantity;
                        ((PlayerItemData)(TPlayerItemData)).ItemUCCUnique = dbdata.UCC_KEY;
                        ((PlayerItemData)(TPlayerItemData)).ItemFlag      = (byte)dbdata.Flag;
                        ((PlayerItemData)(TPlayerItemData)).ItemEndDate   = dbdata.END_DATE;
                        ((PlayerItemData)(TPlayerItemData)).ItemIsValid   = 1;
                        // Add to inventory list
                        ItemWarehouse.ItemAdd((PlayerItemData)(TPlayerItemData));
                        // Set the result data
                        Result = new AddData()
                        {
                            Status      = true,
                            ItemIndex   = ((PlayerItemData)(TPlayerItemData)).ItemIndex,
                            ItemTypeID  = ((PlayerItemData)(TPlayerItemData)).ItemTypeID,
                            ItemOldQty  = 0,
                            ItemNewQty  = ItemAddData.Quantity,
                            ItemUCCKey  = ((PlayerItemData)(TPlayerItemData)).ItemUCCUnique,
                            ItemFlag    = (byte)((PlayerItemData)(TPlayerItemData)).ItemFlag,
                            ItemEndDate = ((PlayerItemData)(TPlayerItemData)).ItemEndDate,
                        };
                    }
                    break;

                    case TITEMGROUP.ITEM_TYPE_CARD:
                    {
                        TPlayerItemData = new PlayerCardData();
                        ((PlayerCardData)(TPlayerItemData)).CardIndex      = (uint)dbdata.IDX;
                        ((PlayerCardData)(TPlayerItemData)).CardTypeID     = (uint)dbdata.iffTypeId;
                        ((PlayerCardData)(TPlayerItemData)).CardQuantity   = ItemAddData.Quantity;
                        ((PlayerCardData)(TPlayerItemData)).CardIsValid    = 1;
                        ((PlayerCardData)(TPlayerItemData)).CardNeedUpdate = false;
                        // ## add to card
                        ItemCard.CardAdd((PlayerCardData)(TPlayerItemData));
                        // set the result data
                        Result = new AddData()
                        {
                            Status      = true,
                            ItemIndex   = ((PlayerCardData)(TPlayerItemData)).CardIndex,
                            ItemTypeID  = ((PlayerCardData)(TPlayerItemData)).CardTypeID,
                            ItemOldQty  = 0,
                            ItemNewQty  = ((PlayerCardData)(TPlayerItemData)).CardQuantity,
                            ItemUCCKey  = string.Empty,
                            ItemFlag    = 0,
                            ItemEndDate = null,
                        };
                    }
                    break;

                    case TITEMGROUP.ITEM_TYPE_MASCOT:
                    {
                        TPlayerItemData = new PlayerMascotData();
                        ((PlayerMascotData)(TPlayerItemData)).MascotIndex      = (uint)dbdata.IDX;
                        ((PlayerMascotData)(TPlayerItemData)).MascotTypeID     = (uint)dbdata.iffTypeId;
                        ((PlayerMascotData)(TPlayerItemData)).MascotMessage    = "Pangya !";
                        ((PlayerMascotData)(TPlayerItemData)).MascotIsValid    = 1;
                        ((PlayerMascotData)(TPlayerItemData)).MascotNeedUpdate = false;
                        ((PlayerMascotData)(TPlayerItemData)).MascotEndDate    = (DateTime)dbdata.END_DATE;

                        ((PlayerMascotData)(TPlayerItemData)).MascotDayToEnd = (ushort)(DaysBetween(dbdata.END_DATE, DateTime.Now));
                        // ## add to card
                        ItemMascot.MascotAdd((PlayerMascotData)(TPlayerItemData));
                        // set the result data
                        Result = new AddData()
                        {
                            Status      = true,
                            ItemIndex   = ((PlayerMascotData)(TPlayerItemData)).MascotIndex,
                            ItemTypeID  = ((PlayerMascotData)(TPlayerItemData)).MascotTypeID,
                            ItemOldQty  = 0,
                            ItemNewQty  = 1,
                            ItemUCCKey  = string.Empty,
                            ItemFlag    = 4,
                            ItemEndDate = DateTime.Now.AddDays(ItemAddData.Day + 1),
                        };
                    }
                    break;
                    }
                }
                catch
                {
                    var player = (GPlayer)MainServer.Program._server.GetPlayerByUID(UID);
                    if (player != null)
                    {
                        player.Close();
                    }
                }
            }
            // ## resulted
            return(Result);
        }
        public void PlayerUseClubPowder(GPlayer player, Packet packet)
        {
            var                   SupplyTypeID = packet.ReadUInt32();
            var                   ClubIndex    = packet.ReadUInt32();
            PlayerItemData        ClubInfo;
            AddData               RemoveItem;
            PlayerTransactionData Tran;

            void SendCode(byte[] Code)
            {
                player.Response.Write(new byte[] { 0x47, 0x02 });
                player.Response.Write(Code);
                player.SendResponse();
            }

            // 47 02 00 1A,436208199=Titan Boo Powder L
            // 4B 02 00 1A,436208203=Titan Boo Powder H
            bool Check()
            {
                bool result;

                result = (SupplyTypeID == 0x1A00024B) || (SupplyTypeID == 0x1A000247);
                return(result);
            }

            if (!Check())
            {
                SendCode(READ_PACKET_ERROR);
                return;
            }
            ClubInfo = player.Inventory.ItemWarehouse.GetClub(ClubIndex, TGET_CLUB.gcIndex);
            if ((ClubInfo == null))
            {
                SendCode(CLUBSET_NOT_FOUND_OR_NOT_EXIST);
                return;
            }
            if (!ClubInfo.ClubSetCanReset())
            {
                SendCode(CLUBSET_CANNOT_CANCEL);
                return;
            }
            RemoveItem = player.Inventory.Remove(SupplyTypeID, 1, true);
            if (!RemoveItem.Status)
            {
                SendCode(REMOVE_ITEM_FAIL);
                return;
            }
            if (SupplyTypeID == 0x1A00024B)
            {
                player.AddPang((uint)Round(Convert.ToDouble(ClubInfo.ItemClubPangLog / 2)));
                player.SendPang();

                ClubInfo.ItemClubPoint += (uint)Round(Convert.ToDouble(ClubInfo.ItemClubPointLog / 2));
            }
            // Reset club point
            ClubInfo.ClubSetReset();
            // ## add transaction
            player.Inventory.ItemTransaction.AddClubSystem(ClubInfo);
            Tran = new PlayerTransactionData
            {
                Types        = 0xC9,
                TypeID       = ClubInfo.ItemTypeID,
                Index        = ClubInfo.ItemIndex,
                PreviousQuan = 0,
                NewQuan      = 0,
                UCC          = ""
            };
            // ## add transaction
            player.Inventory.ItemTransaction.Add(Tran);
            player.SendTransaction();

            player.Response.Write(new byte[] { 0x47, 0x02 });
            player.Response.Write(0);
            player.Response.WriteUInt32(ClubInfo.ItemTypeID);
            player.Response.WriteUInt32(ClubInfo.ItemIndex);
            player.SendResponse();
        }
示例#5
0
        public AddData Remove(uint ItemIffId, uint Index, uint Quantity, bool Transaction = true)
        {
            AddData               ItemDeletedData;
            PlayerItemData        Items;
            PlayerCardData        Cards;
            PlayerTransactionData Tran;

            ItemDeletedData = new AddData()
            {
                Status = false
            };
            if (UID <= 0)
            {
                return(ItemDeletedData);
            }

            if (ItemIffId <= 0 && Quantity <= 0)
            {
                return(ItemDeletedData);
            }


            switch ((TITEMGROUP)GetPartGroup(ItemIffId))
            {
            case TITEMGROUP.ITEM_TYPE_CLUB:
            case TITEMGROUP.ITEM_TYPE_USE:
            {
                Items = ItemWarehouse.GetItem(ItemIffId, Index, Quantity);

                if (!(Items == null))
                {
                    ItemDeletedData.Status      = true;
                    ItemDeletedData.ItemIndex   = Items.ItemIndex;
                    ItemDeletedData.ItemTypeID  = Items.ItemTypeID;
                    ItemDeletedData.ItemOldQty  = Items.ItemC0;
                    ItemDeletedData.ItemNewQty  = Items.ItemC0 - Quantity;
                    ItemDeletedData.ItemUCCKey  = Items.ItemUCCUnique;
                    ItemDeletedData.ItemFlag    = 0;
                    ItemDeletedData.ItemEndDate = null;
                    if (Transaction)
                    {
                        Tran = new PlayerTransactionData()
                        {
                            UCC = "", Types = 2, TypeID = Items.ItemTypeID, Index = Items.ItemIndex, PreviousQuan = Items.ItemC0, NewQuan = Items.ItemC0 - Quantity
                        };
                        ItemTransaction.Add(Tran);
                    }
                }
                // update item info
                Items.RemoveQuantity(Quantity);
                return(ItemDeletedData);
            }

            case TITEMGROUP.ITEM_TYPE_PART:
            {
                Items = ItemWarehouse.GetItem(ItemIffId, Index, 0);         // ## part should be zero

                if (!(Items == null))
                {
                    ItemDeletedData.Status      = true;
                    ItemDeletedData.ItemIndex   = Items.ItemIndex;
                    ItemDeletedData.ItemTypeID  = Items.ItemTypeID;
                    ItemDeletedData.ItemOldQty  = 1;
                    ItemDeletedData.ItemNewQty  = 0;
                    ItemDeletedData.ItemUCCKey  = Items.ItemUCCUnique;
                    ItemDeletedData.ItemFlag    = 0;
                    ItemDeletedData.ItemEndDate = null;
                    if (Transaction)
                    {
                        Tran = new PlayerTransactionData()
                        {
                            UCC = "", Types = 2, TypeID = Items.ItemTypeID, Index = Items.ItemIndex, PreviousQuan = 1, NewQuan = 0
                        };
                        ItemTransaction.Add(Tran);
                    }
                }
                // update item info
                Items.RemoveQuantity(Quantity);
                return(ItemDeletedData);
            }

            case TITEMGROUP.ITEM_TYPE_CARD:
            {
                Cards = ItemCard.GetCard(ItemIffId, Index, Quantity);

                if (!(Cards == null))
                {
                    ItemDeletedData.Status      = true;
                    ItemDeletedData.ItemIndex   = Cards.CardIndex;
                    ItemDeletedData.ItemTypeID  = Cards.CardTypeID;
                    ItemDeletedData.ItemOldQty  = Cards.CardQuantity;
                    ItemDeletedData.ItemNewQty  = Cards.CardQuantity - Quantity;
                    ItemDeletedData.ItemUCCKey  = string.Empty;
                    ItemDeletedData.ItemFlag    = 0;
                    ItemDeletedData.ItemEndDate = null;
                    if (Transaction)
                    {
                        Tran = new PlayerTransactionData()
                        {
                            UCC = "", Types = 2, TypeID = Cards.CardTypeID, Index = Cards.CardIndex, PreviousQuan = Cards.CardQuantity, NewQuan = Cards.CardQuantity - Quantity
                        };
                        ItemTransaction.Add(Tran);
                    }
                }
                // update item info
                Cards.RemoveQuantity(Quantity);
                return(ItemDeletedData);
            }
            }
            ItemDeletedData.SetData(false, 0, 0, 0, 0, string.Empty, 0, DateTime.Now);
            return(ItemDeletedData);
        }