Exemple #1
0
 public static int Create(int itemid, MapleCharacter chr)
 {
     try
     {
         MapleItemInformationProvider mii = MapleItemInformationProvider.Instance;
         using (var db = new NeoMapleStoryDatabase())
         {
             var petmodel = new PetModel()
             {
                 Name      = mii.GetName(itemid),
                 Level     = 1,
                 Closeness = 0,
                 Fullness  = 100,
                 UniqueId  = MapleCharacter.GetNextUniqueId()
             };
             db.Pets.Add(petmodel);
             db.SaveChanges();
             chr.Save();
             return(petmodel.Id);
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(-1);
     }
 }
Exemple #2
0
        public void Save()
        {
            try
            {
                using (var db = new NeoMapleStoryDatabase())
                {
                    var deleteQuery = db.CashShopInventories.Where(x => x.AId == m_accountId).Select(x => x);
                    db.CashShopInventories.RemoveRange(deleteQuery);

                    List <CashShopInventoryModel> list = new List <CashShopInventoryModel>();
                    foreach (var citem in CashShopItems.Values)
                    {
                        list.Add(new CashShopInventoryModel()
                        {
                            UniqueId   = citem.UniqueId,
                            ItemId     = citem.ItemId,
                            Sn         = citem.Sn,
                            Quantity   = citem.Quantity,
                            Sender     = citem.Sender,
                            Message    = citem.Message,
                            ExpireDate = citem.Expire,
                            IsGift     = citem.IsGift,
                            IsRing     = citem.IsRing,
                        });
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
Exemple #3
0
        public static MaplePet Load(int itemid, byte position, int uniqueid)
        {
            var ret = new MaplePet(itemid, position, uniqueid);

            using (var db = new NeoMapleStoryDatabase())
            {
                var result = db.Pets.Where(x => x.UniqueId == uniqueid).Select(x => x).FirstOrDefault();
                if (result == null)
                {
                    return(null);
                }

                ret.PetInfo = result;
                return(ret);
            }
        }
Exemple #4
0
 public void Save()
 {
     try
     {
         using (var db = new NeoMapleStoryDatabase())
         {
             var pet = db.Pets.Where(x => x.UniqueId == UniqueId).Select(x => x).FirstOrDefault();
             if (pet == null)
             {
                 return;
             }
             pet = PetInfo;
             db.SaveChanges();
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
Exemple #5
0
        public void Load(int id)
        {
            try
            {
                using (var db = new NeoMapleStoryDatabase())
                {
                    var cashItemQuery = db.CashShopInventories.Where(x => x.AId == m_accountId).Select(x => x);

                    foreach (var item in cashItemQuery)
                    {
                        var citem = new MapleCashShopInventoryItem(item.UniqueId, item.ItemId, item.Sn, item.Quantity, item.IsGift)
                        {
                            Expire = item.ExpireDate,
                            Sender = item.Sender
                        };
                        if (CashShopItems.ContainsKey(citem.UniqueId))
                        {
                            CashShopItems[citem.UniqueId] = citem;
                        }
                        else
                        {
                            CashShopItems.Add(citem.UniqueId, citem);
                        }
                    }


                    var cashGiftQuery = db.CashShopGifts.Where(x => x.AId == m_accountId).Select(x => x);

                    foreach (var giftinfo in cashGiftQuery)
                    {
                        MapleCashShopInventoryItem gift;
                        if (giftinfo.ItemId >= 5000000 && giftinfo.ItemId <= 5000100)
                        {
                            int petId = MaplePet.Create(giftinfo.ItemId, m_player);
                            gift = new MapleCashShopInventoryItem(petId, giftinfo.ItemId, giftinfo.Sn, 1, true);
                        }
                        else
                        {
                            gift = new MapleCashShopInventoryItem(giftinfo.RingUniqueId, giftinfo.ItemId, giftinfo.Sn, giftinfo.Quantity, true)
                            {
                                IsRing = giftinfo.RingUniqueId > 0
                            };
                        }
                        gift.Expire  = giftinfo.ExpireDate;
                        gift.Sender  = giftinfo.Sender;
                        gift.Message = giftinfo.Message;

                        if (CashShopGifts.ContainsKey(gift.UniqueId))
                        {
                            CashShopGifts[gift.UniqueId] = gift;
                        }
                        else
                        {
                            CashShopGifts.Add(gift.UniqueId, gift);
                        }

                        if (CashShopItems.ContainsKey(gift.UniqueId))
                        {
                            CashShopItems[gift.UniqueId] = gift;
                        }
                        else
                        {
                            CashShopItems.Add(gift.UniqueId, gift);
                        }

                        Save();
                    }

                    var deleteGiftQuery = db.CashShopGifts.Where(x => x.AId == m_accountId).Select(x => x);
                    db.CashShopGifts.RemoveRange(deleteGiftQuery);

                    db.SaveChanges();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }