Exemple #1
0
        public void Model_Item_FormatOutput_Name_WithSpace_Should_Pass()
        {
            Item myData;

            foreach (var attribute in AttributeList.GetListItem)
            {
                var attributeEnum = AttributeList.ConvertStringToEnum(attribute);

                foreach (var location in ItemLocationList.GetListItem)
                {
                    var locationEnum = ItemLocationList.ConvertStringToEnum(location);

                    myData = DefaultModels.ItemDefault(locationEnum, attributeEnum);

                    // Add leading space to name, to test the trim...
                    myData.Name = " " + myData.Name;

                    var Expected = "Item for " + location + " , Auto Created for " + location + " with " + attribute + "+" + myData.Value + " , Damage : " + myData.Damage + " , Range : " + myData.Range;

                    var Actual = myData.FormatOutput();

                    Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
                }
            }
        }
Exemple #2
0
        public void Model_Item_Instantiate_Should_Pass()
        {
            // Walk all the Attributes and Locations and make an Item for each one
            // Verify the properties.

            Item myData;

            foreach (var attribute in AttributeList.GetListItem)
            {
                var attributeEnum = AttributeList.ConvertStringToEnum(attribute);

                foreach (var location in ItemLocationList.GetListItem)
                {
                    var locationEnum = ItemLocationList.ConvertStringToEnum(location);

                    myData = DefaultModels.ItemDefault(locationEnum, attributeEnum);


                    Assert.AreEqual(locationEnum, myData.Location, "location: " + location + " " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual(attributeEnum, myData.Attribute, "attribute: " + attribute + " " + TestContext.CurrentContext.Test.Name);

                    Assert.AreEqual(1, myData.Value, "value " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual(1, myData.Damage, "damage " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual(1, myData.Range, "range " + TestContext.CurrentContext.Test.Name);


                    Assert.AreEqual("Item for " + location, myData.Name, "Name " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual("Auto Created", myData.Description, "Description " + TestContext.CurrentContext.Test.Name);
                    Assert.AreEqual(null, myData.ImageURI, "range " + TestContext.CurrentContext.Test.Name);
                }
            }
        }
        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);
        }
Exemple #4
0
 public void itemSourceEditor_Closed(object sender, EventArgs e)
 {
     if ((sender as ItemSourceEditor).DialogResult.GetValueOrDefault(false))
     {
         if (CurrentItem.LocationInfo != (sender as ItemSourceEditor).ItemSources)
         {
             tempSources = (sender as ItemSourceEditor).ItemSources;
             UpdateSourcesBox(tempSources);
             SourcesChanged = true;
         }
     }
 }
        public void Model_ItemLocationList_ConvertStringToEnum_Should_Pass()
        {
            var myList = Enum.GetNames(typeof(ItemLocationEnum)).ToList();

            ItemLocationEnum myActual;
            ItemLocationEnum myExpected;

            foreach (var item in myList)
            {
                myActual   = ItemLocationList.ConvertStringToEnum(item);
                myExpected = (ItemLocationEnum)Enum.Parse(typeof(ItemLocationEnum), item);

                Assert.AreEqual(myExpected, myActual, "string: " + item + TestContext.CurrentContext.Test.Name);
            }
        }
Exemple #6
0
 private void UpdateSourcesBox(ItemLocationList newList)
 {
     if (newList != null && newList.Count > 0)
     {
         if (newList.Count > 0)
         {
             TB_Source.Text = TB_SourceNote.Text = "";
             foreach (ItemLocation il in newList)
             {
                 if (il == null)
                 {
                     continue;
                 }
                 TB_Source.Text     += il.Description + "\n";
                 TB_SourceNote.Text += il.Note + "\n";
             }
             TB_Source.Text     = TB_Source.Text.TrimEnd('\n');
             TB_SourceNote.Text = TB_SourceNote.Text.TrimEnd('\n');
         }
         else if (newList[0] != null)
         {
             TB_Source.Text     = newList[0].Description;
             TB_SourceNote.Text = newList[0].Note;
         }
         else
         {
             TB_Source.Text     = "";
             TB_SourceNote.Text = "";
         }
     }
     else
     {
         TB_Source.Text     = "";
         TB_SourceNote.Text = "";
     }
 }
Exemple #7
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);
        }
 private void UpdateSourcesBox(ItemLocationList newList) {
     if (newList != null && newList.Count > 0) {
         if (newList.Count > 0) {
             TB_Source.Text = TB_SourceNote.Text = "";
             foreach (ItemLocation il in newList) {
                 if (il == null) { continue; }
                 TB_Source.Text += il.Description + "\n";
                 TB_SourceNote.Text += il.Note + "\n";
             }
             TB_Source.Text = TB_Source.Text.TrimEnd('\n');
             TB_SourceNote.Text = TB_SourceNote.Text.TrimEnd('\n');
         } else if (newList[0] != null){
             TB_Source.Text = newList[0].Description;
             TB_SourceNote.Text = newList[0].Note;
         } else {
             TB_Source.Text = "";
             TB_SourceNote.Text = "";
         }
     }
     else {
         TB_Source.Text = "";
         TB_SourceNote.Text = "";
     }
 }
 public void itemSourceEditor_Closed(object sender, EventArgs e)
 {
     if ((sender as ItemSourceEditor).DialogResult.GetValueOrDefault(false))
     {
         if (CurrentItem.LocationInfo != (sender as ItemSourceEditor).ItemSources)
         {
             tempSources = (sender as ItemSourceEditor).ItemSources;
             UpdateSourcesBox(tempSources);
             SourcesChanged = true;
         }
     }
 }