示例#1
0
 public void LoadRewardItems(int pCharID)
 {
     try
     {
         locker.WaitOne();
         DataTable Rewarddata = null;
         using (DatabaseClient dbClient = Program.CharDBManager.GetClient())
         {
             Rewarddata = dbClient.ReadDataTable("SELECT *FROM RewardItems WHERE CharID='" + pCharID + "'");
         }
         if (Rewarddata != null)
         {
             foreach (DataRow row in Rewarddata.Rows)
             {
                 RewardItem pItem = RewardItem.LoadFromDatabase(row);
                 if (!this.RewardItems.ContainsKey(pItem.PageID))
                 {
                     this.RewardItems[pItem.PageID] = new List <RewardItem>();
                 }
                 this.RewardItems[pItem.PageID].Add(pItem);
             }
         }
     }
     finally
     {
         locker.ReleaseMutex();
     }
 }
示例#2
0
        public static RewardItem LoadFromDatabase(System.Data.DataRow row)
        {
            RewardItem ppItem = new RewardItem
            {
                Slot   = GetDataTypes.GetSByte(row["Slot"]),
                ID     = GetDataTypes.GetUshort(row["ItemID"]),
                CharID = GetDataTypes.GetInt(row["CharID"]),
                PageID = GetDataTypes.GetByte(row["PageID"])
            };

            return(ppItem);
        }
示例#3
0
        public static RewardItem LoadFromDatabase(System.Data.DataRow row)
        {
            RewardItem ppItem = new RewardItem
            {
                Slot = GetDataTypes.GetSByte(row["Slot"]),
                ID = GetDataTypes.GetUshort(row["ItemID"]),
                CharID = GetDataTypes.GetInt(row["CharID"]),
                PageID = GetDataTypes.GetByte(row["PageID"])
            };

            return ppItem;
        }
示例#4
0
 public void RemoveRewardItem(RewardItem pItem)
 {
     try
     {
         locker.WaitOne();
         pItem.RemoveFromDatabase();
         this.RewardItems[pItem.PageID].Remove(pItem);
     }
     finally
     {
         locker.ReleaseMutex();
     }
 }
示例#5
0
 public void AddRewardItem(RewardItem pItem)
 {
     try
     {
         locker.WaitOne();
         if (!this.RewardItems.ContainsKey(pItem.PageID))
         {
             this.RewardItems[pItem.PageID] = new List <RewardItem>();
         }
         pItem.AddToDatabase();
         this.RewardItems[pItem.PageID].Add(pItem);
     }
     finally
     {
         locker.ReleaseMutex();
     }
 }
示例#6
0
        public void AddRewardItem(RewardItem pItem)
        {
            try
            {
                locker.WaitOne();
                if (!this.RewardItems.ContainsKey(pItem.PageID))
                {
                    this.RewardItems[pItem.PageID] = new List<RewardItem>();

                }
                pItem.AddToDatabase();
                this.RewardItems[pItem.PageID].Add(pItem);
            }
            finally
            {
                locker.ReleaseMutex();
            }
        }
示例#7
0
 public bool GetEmptySlot(out byte pSlot, out ushort PageID) //cpu intensive?
 {
     pSlot  = 0;
     PageID = 0;
     for (byte i = 0; i < this.RewardItems.Count; ++i)
     {
         for (byte i2 = 0; i2 < 24; ++i2)
         {
             RewardItem Item = this.RewardItems[i].Find(ss => ss.Slot == i2);
             if (Item == null)
             {
                 pSlot  = i2;
                 PageID = i;
                 return(true);
             }
         }
     }
     return(false); //no more empty slots found
 }
示例#8
0
        public bool GiveMasterRewardItem(ushort ItemID,byte count)
        {
            MasterRewardState States;
            ushort PageID;
            byte pSlot;
            if (this.RewardInventory.GetEmptySlot(out pSlot, out PageID))
            {
              if (!Data.DataProvider.Instance.MasterRewardStates.TryGetValue(ItemID, out States))
                 return false;

                RewardItem Reward = new RewardItem
                  {
                      ID = ItemID,
                      Slot = (sbyte)pSlot,
                      PageID = PageID,
                      Ammount = count,

                  };
                Reward.UpgradeStats = new UpgradeStats
                {
                    Str = States.Str,
                    Int = States.Int,
                    Spr = States.Spr,
                    Dex = States.Dex,
                    End = States.End,
                };
                this.RewardInventory.AddRewardItem(Reward);
                return true;
            }
            else
            {
                //Todo Send FULL
                return false;
            }
        }
示例#9
0
 public void RemoveRewardItem(RewardItem pItem)
 {
     try
     {
         locker.WaitOne();
         pItem.RemoveFromDatabase();
         this.RewardItems[pItem.PageID].Remove(pItem);
     }
     finally
     {
         locker.ReleaseMutex();
     }
 }