private void ProcessItemResult(Entity winner, TreasurePoolItem item, ItemLotResult result) { item.itemID = 0; item.timer.Stop(); item.lots.Clear(); // TODO: Send 0xD3 (TreasureLotItemPacket) with result }
public void LotItem(Entity entity, UInt16 itemIndex, UInt16 value) { TreasurePoolItem item = items[itemIndex]; item.lots[entity] = value; Entity bestLotter = null; int bestLot = 0; foreach (var itemLot in item.lots) { if (itemLot.Value != PassedLotValue && itemLot.Value > bestLot) { bestLotter = itemLot.Key; bestLot = itemLot.Value; } } // TODO: Send 0xD3 (TreasureLotItemPacket) to all members if (items[itemIndex].lots.Count == members.Count) { DistributeItemAt(itemIndex); } }
public void AddItem(Entity monster, UInt16 itemID) { int targetIndex = items.FindIndex(item => item.Empty); if (targetIndex == -1) { foreach (ItemFlags flags in replacePriority) { targetIndex = FindTargetIndex(flags); if (targetIndex != -1) { break; } } if (targetIndex == -1) { targetIndex = 0; } } TreasurePoolItem item = items[targetIndex]; if (!item.Empty) { DistributeItemAt(targetIndex); } item.itemID = itemID; item.timer.Reset(TreasurePoolMax); // TODO: Push 0xD2 (TreasureFindItemPacket) to members if (members.Count == 1) { // NOTE: This might not be desired for zone treasure pools? DistributeItemAt(targetIndex); } }
private void DistributeItemAt(int itemIndex) { TreasurePoolItem poolItem = items[itemIndex]; Item item = Item.Get(poolItem.itemID); Entity winner = null; int bestLot = 0; foreach (var itemLot in poolItem.lots) { if (itemLot.Value != PassedLotValue && itemLot.Value > bestLot) { winner = itemLot.Key; bestLot = itemLot.Value; } } if (winner == null) { winner = members.Where(member => member.CanAddItem(item) && poolItem.lots.ContainsKey(member)).ToList().GetRandom(); } if (winner.HasInventorySpace) { if (winner.AddItem(item)) { ProcessItemResult(winner, poolItem, ItemLotResult.Win); } else { ProcessItemResult(winner, poolItem, ItemLotResult.WinError); } } else { ProcessItemResult(winner, poolItem, ItemLotResult.Lost); } }