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(); } }
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); }
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; }
public void RemoveRewardItem(RewardItem pItem) { try { locker.WaitOne(); pItem.RemoveFromDatabase(); this.RewardItems[pItem.PageID].Remove(pItem); } finally { locker.ReleaseMutex(); } }
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(); } }
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(); } }
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 }
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; } }