public void Model_ItemLocationList_GetLocationByPosition_7_Should_Pass()
        {
            var value    = 7;
            var Actual   = ItemLocationList.GetLocationByPosition(value);
            var Expected = ItemLocationEnum.Feet;

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
Exemplo n.º 2
0
        // Hackathon rule.  If critical miss happens, a problem may occur...
        public string DetermineCriticalMissProblem(Character attacker)
        {
            // No such character
            if (attacker == null)
            {
                return(" Invalid Character ");
            }

            // Default message
            var myReturn = " Nothing Bad Happened ";

            // To hold the dropped item
            Item droppedItem;

            // It may be a critical miss, roll again and find out...
            var rnd = HelperEngine.RollDice(1, 10);

            /*
             *  1. Primary Hand Item breaks, and is lost forever
             *  2-4, Character Drops the Primary Hand Item back into the item pool
             *  5-6, Character drops a random equipped item back into the item pool
             *  7-10, Nothing bad happens, luck was with the attacker
             */

            switch (rnd)
            {
            case 1:
                myReturn = " Luckily, nothing to drop from " + ItemLocationEnum.PrimaryHand;
                var myItem = ItemsViewModel.Instance.GetItem(attacker.PrimaryHand);
                if (myItem != null)
                {
                    myReturn = " Item " + myItem.Name + " from " + ItemLocationEnum.PrimaryHand + " Broke, and lost forever";
                }

                attacker.PrimaryHand = null;
                break;

            case 2:
            case 3:
            case 4:
                // Put on the new item, which drops the one back to the pool
                myReturn    = " Luckily, nothing to drop from " + ItemLocationEnum.PrimaryHand;
                droppedItem = attacker.AddItem(ItemLocationEnum.PrimaryHand, null);
                if (droppedItem != null)
                {
                    // Add the dropped item to the pool
                    ItemPool.Add(droppedItem);
                    myReturn = attacker.Name + " dropped " + droppedItem.Name + " from " + ItemLocationEnum.PrimaryHand;
                }
                break;

            case 5:
            case 6:
                var LocationRnd    = HelperEngine.RollDice(1, ItemLocationList.GetListCharacter.Count);
                var myLocationEnum = ItemLocationList.GetLocationByPosition(LocationRnd);
                myReturn = " Luckily, nothing to drop from " + myLocationEnum;

                // Put on the new item, which drops the one back to the pool
                droppedItem = attacker.AddItem(myLocationEnum, null);
                if (droppedItem != null)
                {
                    // Add the dropped item to the pool
                    ItemPool.Add(droppedItem);
                    myReturn = attacker.Name + " dropped " + droppedItem.Name + " from " + myLocationEnum;
                }
                break;
            }

            return(myReturn);
        }