/** Purchase item, gives to currently selected party memeber. */ public bool PurchaseItem(MDRItem item) { MDRCharacter buyer = CoM.Party.Selected; if (buyer == null) { return(false); } if (CoM.Party.Gold < SellPrice(item)) { return(false); } // do the transaction if (buyer.GiveItem(MDRItemInstance.Create(item))) { CoM.Party.DebitGold(SellPrice(item), buyer); SubtractQuantity(item, 1); return(true); } else { CoM.PostMessage(buyer + " does not have enough space for " + item); return(false); } }
/** Removes any item from instance */ public void Clear() { Item = null; RemainingCharges = 0; Cursed = false; KnownToBeCursed = false; IDLevel = IdentificationLevel.Auto; }
public void AddQuanity(MDRItem item, int delta = 1) { itemQuantity[item.ID] = GetQuantity(item) + delta; doInventoryChanged(); // Auto id anything that goes into the store. CoM.GameStats.RegisterItemIdentified(item, IdentificationLevel.Full); }
public int GetQuantity(MDRItem item) { if (itemQuantity.ContainsKey(item.ID)) { return(itemQuantity[item.ID]); } else { return(0); } }
public MDRItemInstance ReceiveLoot(MDRItem item, MDRMonster sourceMonster, ref MDRCharacter giveToCharacter) { var instance = MDRItemInstance.Create(item, IdentificationLevel.Auto); giveToCharacter = giveToCharacter ?? RandomMember(); giveToCharacter.GiveItem(instance); if (sourceMonster != null) { CoM.GameStats.RegisterItemFound(giveToCharacter, instance, sourceMonster); } return(instance); }
public static MDRItemInstance Create(MDRItem item, IdentificationLevel idLevel = null) { if (item == null) { throw new ArgumentNullException("item"); } MDRItemInstance result = new MDRItemInstance(); result.Item = item; result.IDLevel = idLevel ?? IdentificationLevel.Full; result.RemainingCharges = Math.Min(item.DefaultCharges, item.Usable ? 1 : 0); result.Cursed = (item.CurseType != ItemCurseType.None); result.KnownToBeCursed = (idLevel == IdentificationLevel.Full) && (result.Cursed); return(result); }
/** Returns the name for this item at a given ID level */ public string ItemName(MDRItem item) { switch (ID) { case 4: case 3: return(item.Name); case 2: return(item.Type.Name); case 1: return(item.Type.TypeClass.Name); default: return(item.Type.TypeClass.Name); } }
/** * Gives a new item to party. * * @sourceMonster The monster that dropped this item. * @giveToCharacter The character that should receive the item, if null a random character will be selected. * * @returns the item instance created. * */ public MDRItemInstance ReceiveLoot(MDRItem item, MDRMonster sourceMonster = null) { MDRCharacter characterReceiving = null; return(ReceiveLoot(item, sourceMonster, ref characterReceiving)); }
public void SubtractQuantity(MDRItem item, int delta = 1) { AddQuanity(item, -delta); }
public void SetQuanity(MDRItem item, int value) { itemQuantity[item.ID] = value; doInventoryChanged(); }
/** Returns the price this store will sell a given item for */ public int SellPrice(MDRItem item) { float factor = 1 + (float)Math.Log(GetQuantity(item)); return((int)(item.Value / factor)); }