// Grabs a random character from the data store and puts it inbetween scale level min and max public Character GetRandomCharacter(int ScaleLevelMin, int ScaleLevelMax) { var myCharacterViewModel = CharactersViewModel.Instance; var rnd = HelperEngine.RollDice(1, myCharacterViewModel.Dataset.Count); var myData = new Character(myCharacterViewModel.Dataset[rnd - 1]); // Help identify which Character it is... myData.Name += " " + (1 + CharacterList.Count).ToString(); var rndScale = HelperEngine.RollDice(ScaleLevelMin, ScaleLevelMax); myData.ScaleLevel(rndScale); // Add Items... myData.Head = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.Head, AttributeEnum.Unknown); myData.Necklass = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.Necklass, AttributeEnum.Unknown); myData.PrimaryHand = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.PrimaryHand, AttributeEnum.Unknown); myData.OffHand = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.OffHand, AttributeEnum.Unknown); myData.RightFinger = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.RightFinger, AttributeEnum.Unknown); myData.LeftFinger = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.LeftFinger, AttributeEnum.Unknown); myData.Feet = ItemsViewModel.Instance.ChooseRandomItemString(ItemLocationEnum.Feet, AttributeEnum.Unknown); return(myData); }
// Add Monsters // Scale them to meet Character Strength... private void AddMonstersToRound() { // Check to see if the monster list is full, if so, no need to add more... if (MonsterList.Count() >= 6) { return; } // TODO, determine the character strength // add monsters up to that strength... var ScaleLevelMax = 2; var ScaleLevelMin = 1; // Make Sure Monster List exists and is loaded... var myMonsterViewModel = MonstersViewModel.Instance; myMonsterViewModel.ForceDataRefresh(); if (myMonsterViewModel.Dataset.Count() > 0) { // Get 6 monsters do { var rnd = HelperEngine.RollDice(1, myMonsterViewModel.Dataset.Count); { var item = new Monster(myMonsterViewModel.Dataset[rnd - 1]); // Help identify which monster it is... item.Name += " " + (1 + MonsterList.Count()).ToString(); var rndScale = HelperEngine.RollDice(ScaleLevelMin, ScaleLevelMax); item.ScaleLevel(rndScale); MonsterList.Add(item); } } while (MonsterList.Count() < 6); } else { // No monsters in DB, so add 6 new ones... for (var i = 0; i < 6; i++) { var item = new Monster(); // Help identify which monster it is... item.Name += " " + MonsterList.Count() + 1; MonsterList.Add(item); } } }
// Will drop between 1 and 4 items from the item set... public List <Item> GetRandomMonsterItemDrops(int round) { var myList = new List <Item>(); if (!GameGlobals.AllowMonsterDropItems) { return(myList); } var myItemsViewModel = ItemsViewModel.Instance; //// If no items, exit... //if (myItemsViewModel.Dataset.Count < 1) //{ // return myList; //} if (myItemsViewModel.Dataset.Count > 0) { // Random is enabled so build up a list of items dropped... var ItemCount = HelperEngine.RollDice(1, 4); for (var i = 0; i < ItemCount; i++) { var rnd = HelperEngine.RollDice(1, myItemsViewModel.Dataset.Count); var itemBase = myItemsViewModel.Dataset[rnd - 1]; var item = new Item(itemBase); item.ScaleLevel(round); // Make sure the item is added to the global list... var myItem = ItemsViewModel.Instance.CheckIfItemExists(item); if (myItem == null) { // Item does not exist, so add it to the datstore ItemsViewModel.Instance.InsertUpdateAsync(item).GetAwaiter().GetResult(); } else { // Swap them becaues it already exists, no need to create a new one... item = myItem; } // Add the item to the local list... myList.Add(item); } } return(myList); }
// Uses helper engine to roll for hit success public HitStatusEnum RollToHitTarget(int AttackScore, int DefenseScore) { var d20 = HelperEngine.RollDice(1, 20); // Turn On UnitTestingSetRoll if (GameGlobals.ForceRollsToNotRandom) { // Don't let it be 0, if it was not initialized... if (GameGlobals.ForceToHitValue < 1) { GameGlobals.ForceToHitValue = 1; } d20 = GameGlobals.ForceToHitValue; } if (d20 == 1) { // Force Miss HitStatus = HitStatusEnum.CriticalMiss; return(HitStatus); } if (d20 == 20) { // Force Hit HitStatus = HitStatusEnum.CriticalHit; return(HitStatus); } var ToHitScore = d20 + AttackScore; if (ToHitScore < DefenseScore) { AttackStatus = " misses "; // Miss HitStatus = HitStatusEnum.Miss; DamageAmount = 0; } else { // Hit HitStatus = HitStatusEnum.Hit; } return(HitStatus); }
public string DetermineCriticalMissProblem(Character attacker) { if (attacker == null) { return(" Invalid Character "); } var myReturn = " Nothing Bad Happened "; 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 = " Luckly, 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 = " Luckly, 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 = " Dropped " + droppedItem.Name + " from " + ItemLocationEnum.PrimaryHand; } break; case 5: case 6: var LocationRnd = HelperEngine.RollDice(1, ItemLocationList.GetListCharacter.Count); myReturn = " Luckly, nothing to drop from " + (ItemLocationEnum)LocationRnd; // Put on the new item, which drops the one back to the pool droppedItem = attacker.AddItem((ItemLocationEnum)LocationRnd, null); if (droppedItem != null) { // Add the dropped item to the pool ItemPool.Add(droppedItem); myReturn = " Dropped " + droppedItem.Name; } break; } return(myReturn); }