示例#1
0
        /// <summary>
        /// Size Packet 25 bytes
        /// </summary>
        /// <returns></returns>
        public byte[] GetCaddieData()
        {
            var CaddieInfo = ItemCaddie.GetCaddieByIndex(CaddieIndex);

            if (!(CaddieInfo == null))
            {
                return(CaddieInfo.GetCaddieInfo());
            }
            return(new byte[0x19]);
        }
示例#2
0
        public override byte[] GetCaddieData()
        {
            PlayerCaddieData CaddieInfo;

            CaddieInfo = ItemCaddie.GetCaddieByIndex(CaddieIndex);
            if (!(CaddieInfo == null))
            {
                return(CaddieInfo.GetCaddieInfo());
            }
            return(new byte[0x19]);
        }
示例#3
0
        // caddie system
        public bool SetCaddieIndex(uint Index)
        {
            if (Index == 0)
            {
                CaddieIndex = 0;
                return(true);
            }
            var Caddie = ItemCaddie.GetCaddieByIndex(Index);

            if (Caddie == null)
            {
                return(false);
            }
            CaddieIndex = Caddie.CaddieIdx;
            return(true);
        }
示例#4
0
        // caddie system
        public override bool SetCaddieIndex(uint Index)
        {
            PlayerCaddieData Caddie;

            if (Index == 0)
            {
                CaddieIndex = 0;
                return(true);
            }
            Caddie = ItemCaddie.GetCaddieByIndex(Index);
            if (Caddie == null)
            {
                return(false);
            }
            CaddieIndex = Caddie.CaddieIdx;
            return(true);
        }
示例#5
0
        public AddItemData AddItemToDB(AddItem ItemAddItemData)
        {
            Object          PlayerObjectData;
            TransactionData Tran;
            AddItemData     Result;

            Result = new AddItemData()
            {
                Status = false
            };
            var _db     = new PangyaEntities();
            var additem = _db.ProcAddItem((int)UID, (int)ItemAddItemData.ItemIffId, (int)ItemAddItemData.Quantity, Compare.IfCompare <byte>(IFFEntry.GetIff.IsSelfDesign(ItemAddItemData.ItemIffId), 1, 0), IFFEntry.GetIff.GetItemTimeFlag(ItemAddItemData.ItemIffId, ItemAddItemData.Day), (int)ItemAddItemData.Day).ToList();

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

                Tran = new TransactionData()
                {
                    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 (ItemAddItemData.ItemIffId.GetItemGroup())
                    {
                    case IffGroupFlag.ITEM_TYPE_CHARACTER:
                    {
                        PlayerObjectData = new CharacterData();

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

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

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

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

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

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

                        ((MascotData)(PlayerObjectData)).MascotDayToEnd = (ushort)dbdata.END_DATE.DaysBetween(DateTime.Now);
                        // ## add to card
                        ItemMascot.MascotAdd((MascotData)(PlayerObjectData));
                        // set the result data
                        Result = new AddItemData()
                        {
                            Status      = true,
                            ItemIndex   = ((MascotData)(PlayerObjectData)).MascotIndex,
                            ItemTypeID  = ((MascotData)(PlayerObjectData)).MascotTypeID,
                            ItemOldQty  = 0,
                            ItemNewQty  = 1,
                            ItemUCCKey  = string.Empty,
                            ItemFlag    = 4,
                            ItemEndDate = DateTime.Now.AddDays(ItemAddItemData.Day + 1),
                        };
                    }
                    break;
                    }
                }
                catch
                {
                }
            }
            // ## resulted
            return(Result);
        }
示例#6
0
        public AddItemData AddItem(AddItem ItemAddItemData)
        {
            Object      WareHouseData;
            AddItemData Result;

            Result = new AddItemData()
            {
                Status = false
            };


            if (UID == 0)
            {
                return(Result);
            }
            switch (ItemAddItemData.ItemIffId.GetItemGroup())
            {
            case IffGroupFlag.ITEM_TYPE_CHARACTER:
            {
                WareHouseData = ItemCharacter.GetChar(ItemAddItemData.ItemIffId, 1);

                if (WareHouseData == null)
                {
                    return(AddItemToDB(ItemAddItemData));
                }

                else if (!(WareHouseData != null))
                {
                    Result.Status      = true;
                    Result.ItemIndex   = ((CharacterData)(WareHouseData)).Index;
                    Result.ItemTypeID  = ((CharacterData)(WareHouseData)).TypeID;
                    Result.ItemOldQty  = 1;
                    Result.ItemNewQty  = 1;
                    Result.ItemUCCKey  = string.Empty;
                    Result.ItemFlag    = 0;
                    Result.ItemEndDate = null;

                    if (ItemAddItemData.Transaction)
                    {
                        ItemTransaction.AddChar(2, (CharacterData)WareHouseData);
                    }
                }
            }
            break;

            case IffGroupFlag.ITEM_TYPE_HAIR_STYLE:
            {
                var IffHair   = IFFEntry.GetIff.GetByHairColor(ItemAddItemData.ItemIffId);
                var character = ItemCharacter.GetCharByType((byte)IffHair.CharType);
                if (character != null)
                {
                    character.HairColour = IffHair.HairColor;
                    character.Update(character);
                    Result.Status      = true;
                    Result.ItemIndex   = character.Index;
                    Result.ItemTypeID  = ItemAddItemData.ItemIffId;
                    Result.ItemOldQty  = 0;
                    Result.ItemNewQty  = 1;
                    Result.ItemUCCKey  = null;
                    Result.ItemFlag    = 0;
                    Result.ItemEndDate = null;
                }
            }
            break;

            case IffGroupFlag.ITEM_TYPE_PART:
            {
                return(AddItemToDB(ItemAddItemData));
            }

            case IffGroupFlag.ITEM_TYPE_CLUB:
            {
                return(AddItemToDB(ItemAddItemData));
            }

            case IffGroupFlag.ITEM_TYPE_AUX:
            case IffGroupFlag.ITEM_TYPE_BALL:
            case IffGroupFlag.ITEM_TYPE_USE:
            {
                WareHouseData = ItemWarehouse.GetItem(ItemAddItemData.ItemIffId, 1);
                if (WareHouseData != null)
                {
                    Result.Status      = true;
                    Result.ItemIndex   = ((WarehouseData)(WareHouseData)).ItemIndex;
                    Result.ItemTypeID  = ((WarehouseData)(WareHouseData)).ItemTypeID;
                    Result.ItemOldQty  = ((WarehouseData)(WareHouseData)).ItemC0;
                    Result.ItemNewQty  = ((WarehouseData)(WareHouseData)).ItemC0 + ItemAddItemData.Quantity;
                    Result.ItemUCCKey  = ((WarehouseData)(WareHouseData)).ItemUCCUnique;
                    Result.ItemFlag    = (byte)((WarehouseData)(WareHouseData)).ItemFlag;
                    Result.ItemEndDate = null;
                    //Add
                    ((WarehouseData)(WareHouseData)).AddQuantity(ItemAddItemData.Quantity);

                    if (ItemAddItemData.Transaction)
                    {
                        ItemTransaction.AddItem(0x02, (WarehouseData)WareHouseData, ItemAddItemData.Quantity);
                    }
                }

                else if (WareHouseData == null)
                {
                    return(AddItemToDB(ItemAddItemData));
                }
            }
            break;

            case IffGroupFlag.ITEM_TYPE_CADDIE:
            {
                return(AddItemToDB(ItemAddItemData));
            }

            case IffGroupFlag.ITEM_TYPE_CADDIE_ITEM:
            {
                WareHouseData = ItemCaddie.GetCaddieBySkinId(ItemAddItemData.ItemIffId);

                if (!(WareHouseData == null))
                {
                    ((CaddieData)(WareHouseData)).Update();
                    ((CaddieData)(WareHouseData)).UpdateCaddieSkin(ItemAddItemData.ItemIffId, ItemAddItemData.Day);
                    Result.Status      = true;
                    Result.ItemIndex   = ((CaddieData)(WareHouseData)).CaddieIdx;
                    Result.ItemTypeID  = ((CaddieData)(WareHouseData)).CaddieSkin;
                    Result.ItemOldQty  = 1;
                    Result.ItemNewQty  = 1;
                    Result.ItemUCCKey  = string.Empty;
                    Result.ItemFlag    = 0;
                    Result.ItemEndDate = DateTime.Now.AddDays(ItemAddItemData.Day);
                }
            }
            break;

            case IffGroupFlag.ITEM_TYPE_SKIN:
            {
                return(AddItemToDB(ItemAddItemData));
            }

            case IffGroupFlag.ITEM_TYPE_MASCOT:
            {
                WareHouseData = ItemMascot.GetMascotByTypeId(ItemAddItemData.ItemIffId);

                if (WareHouseData != null)
                {
                    ((MascotData)(WareHouseData)).AddDay(ItemAddItemData.Day);
                    Result.Status      = true;
                    Result.ItemIndex   = ((MascotData)(WareHouseData)).MascotIndex;
                    Result.ItemTypeID  = ((MascotData)(WareHouseData)).MascotTypeID;
                    Result.ItemOldQty  = 1;
                    Result.ItemNewQty  = 1;
                    Result.ItemUCCKey  = "";
                    Result.ItemFlag    = 0;
                    Result.ItemEndDate = ((MascotData)(WareHouseData)).MascotEndDate;
                }
                else if (WareHouseData == null)
                {
                    return(AddItemToDB(ItemAddItemData));
                }
            }
            break;

            case IffGroupFlag.ITEM_TYPE_CARD:
            {
                WareHouseData = ItemCard.GetCard(ItemAddItemData.ItemIffId, 1);

                if (WareHouseData == null)
                {
                    AddItemToDB(ItemAddItemData);
                }
                else if (WareHouseData != null)
                {
                    Result.Status      = true;
                    Result.ItemIndex   = ((CardData)(WareHouseData)).CardIndex;
                    Result.ItemTypeID  = ((CardData)(WareHouseData)).CardTypeID;
                    Result.ItemOldQty  = ((CardData)(WareHouseData)).CardQuantity;
                    Result.ItemNewQty  = ((CardData)(WareHouseData)).CardQuantity + ItemAddItemData.Quantity;
                    Result.ItemUCCKey  = string.Empty;
                    Result.ItemFlag    = 0;
                    Result.ItemEndDate = null;

                    ((CardData)(WareHouseData)).AddQuantity(ItemAddItemData.Quantity);

                    if (ItemAddItemData.Transaction)
                    {
                        ItemTransaction.AddCard(0x02, (CardData)WareHouseData, ItemAddItemData.Quantity);
                    }
                }
            }
            break;
            }
            return(Result);
        }
示例#7
0
        public bool Available(uint TypeID, uint Quantity)
        {
            var ListSet = IFFEntry.GetIff.SetItem.SetList(TypeID);

            switch (TypeID.GetItemGroup())
            {
            case IffGroupFlag.ITEM_TYPE_SETITEM:
            {
                if (ListSet.Count <= 0)
                {
                    return(false);
                }

                else
                {
                    foreach (var data in ListSet)
                    {
                        Available(data.Keys.FirstOrDefault(), data.Values.FirstOrDefault());
                    }
                    return(true);
                }
            }

            case IffGroupFlag.ITEM_TYPE_CHARACTER:
            {
                return(true);
            }

            case IffGroupFlag.ITEM_TYPE_HAIR_STYLE:
            {
                return(true);
            }

            case IffGroupFlag.ITEM_TYPE_PART:
            {
                return(true);
            }

            case IffGroupFlag.ITEM_TYPE_CLUB:
            {
                if (ItemWarehouse.IsClubExist(TypeID))
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            }

            case IffGroupFlag.ITEM_TYPE_AUX:
            case IffGroupFlag.ITEM_TYPE_BALL:
            case IffGroupFlag.ITEM_TYPE_USE:
            {
                if (GetQuantity(TypeID) + Quantity > 32767)
                {
                    return(false);
                }
                return(true);
            }

            case IffGroupFlag.ITEM_TYPE_CADDIE:
            {
                if (ItemCaddie.IsExist(TypeID))
                {
                    return(false);
                }
                return(true);
            }

            case IffGroupFlag.ITEM_TYPE_CADDIE_ITEM:
            {
                if (ItemCaddie.CanHaveSkin(TypeID))
                {
                    return(true);
                }
                return(false);
            }

            case IffGroupFlag.ITEM_TYPE_SKIN:
            {
                if (ItemWarehouse.IsSkinExist(TypeID))
                {
                }
                return(true);
            }

            case IffGroupFlag.ITEM_TYPE_MASCOT:
            {
                return(true);
            }

            case IffGroupFlag.ITEM_TYPE_CARD:
            {
                return(true);
            }
            }
            return(false);
        }
示例#8
0
        // PlayerSave
        public void Save(PangyaEntities _db)
        {
            // # PLAYER TOOLBAR UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_TOOLBAR  @UID = '{UID}', @ITEMSTR = '{GetSqlUpdateToolbar()}'").FirstOrDefault();

            // #PLAYER ITEM UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_ITEM  @UID = '{UID}', @ITEMSTR = '{ItemWarehouse.GetSqlUpdateItems()}'").FirstOrDefault();

            // #PLAYER CADDIE UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_CADDIE  @UID = '{UID}', @ITEMSTR = '{ItemCaddie.GetSqlUpdateCaddie()}'").FirstOrDefault();

            // #PLAYER CHARACTER AND EQUIP UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_CHARACTER_EQUIP  @UID = '{UID}', @EQUIPSTR = '{ItemCharacter.GetSqlUpdateCharacter()}'").FirstOrDefault();

            // #PLAYER CARD UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_CARD  @UID = '{UID}', @ITEMSTR = '{ItemCard.GetSqlUpdateCard()}'").FirstOrDefault();

            // #PLAYER CARD EQUIP UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_CARD_EQUIP  @UID = '{UID}', @ITEMSTR = '{ItemCardEquip.GetSqlUpdateCardEquip()}'").FirstOrDefault();

            // #PLAYER MASCOT UPDATE
            _db.Database.SqlQuery <PangyaEntities>($"Exec dbo.USP_SAVE_MASCOT  @UID = '{UID}', @ITEMSTR = '{ItemMascot.GetSqlUpdateMascots()}'").FirstOrDefault();

            _db.Dispose();
        }