コード例 #1
0
        /** 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);
            }
        }
コード例 #2
0
 /** Removes any item from instance */
 public void Clear()
 {
     Item             = null;
     RemainingCharges = 0;
     Cursed           = false;
     KnownToBeCursed  = false;
     IDLevel          = IdentificationLevel.Auto;
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 public int GetQuantity(MDRItem item)
 {
     if (itemQuantity.ContainsKey(item.ID))
     {
         return(itemQuantity[item.ID]);
     }
     else
     {
         return(0);
     }
 }
コード例 #5
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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        /** 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);
            }
        }
コード例 #8
0
        /**
         * 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));
        }
コード例 #9
0
 public void SubtractQuantity(MDRItem item, int delta = 1)
 {
     AddQuanity(item, -delta);
 }
コード例 #10
0
 public void SetQuanity(MDRItem item, int value)
 {
     itemQuantity[item.ID] = value;
     doInventoryChanged();
 }
コード例 #11
0
        /** 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));
        }