//constructor of Monster Model class public MonsterModel() { this.Name = "this is Name"; this.Description = "this is Monster Description"; DropItems = new List <ItemModel>(); this.MaxHealth = DiceHelper.RollDice((int)Level, 10); }
/// <summary> /// Decide to use an Ability or not /// /// Set the Ability /// </summary> /// <param name="Attacker"></param> /// <returns></returns> public override bool ChooseToUseAbility(PlayerInfoModel Attacker) { // See if healing is needed. EngineSettings.CurrentActionAbility = Attacker.SelectHealingAbility(); if (EngineSettings.CurrentActionAbility != AbilityEnum.Unknown) { EngineSettings.CurrentAction = ActionEnum.Ability; return(true); } // If not needed, then role dice to see if other ability should be used // <30% chance if (DiceHelper.RollDice(1, 10) < 3) { EngineSettings.CurrentActionAbility = Attacker.SelectAbilityToUse(); if (EngineSettings.CurrentActionAbility != AbilityEnum.Unknown) { // Ability can , switch to unknown to exit EngineSettings.CurrentAction = ActionEnum.Ability; return(true); } // No ability available return(false); } // Don't try return(false); }
/// <summary> /// Randomly set the Character Job /// </summary> /// <returns></returns> public static CharacterJobEnum GetCharacterJob() { var dice = DiceHelper.RollDice(1, 3); var result = CharacterJobEnumHelper.GetCharacterJobByPosition(dice); return(result); }
/// <summary> /// Randomly set the Monster Type /// </summary> /// <returns></returns> public static MonsterTypeEnum GetMonsterType() { var dice = DiceHelper.RollDice(1, 3); var result = MonsterTypeEnumHelper.GetMonsterTypeByPosition(dice); return(result); }
/// <summary> /// Create Random Character for the battle /// </summary> /// <param name="MaxLevel"></param> /// <returns></returns> public static MonsterModel GetRandomMonster(int MaxLevel, bool Items = false) { var result = new MonsterModel() { Level = DiceHelper.RollDice(1, MaxLevel), // Randomize Name Name = GetMonsterName(), Description = GetMonsterDescription(), // Randomize the Attributes Attack = GetAbilityValue(), Speed = GetAbilityValue(), Defense = GetAbilityValue(), ImageURI = GetMonsterImage(), Difficulty = GetMonsterDifficultyValue() }; // Adjust values based on Difficulty result.Attack = result.Difficulty.ToModifier(result.Attack); result.Defense = result.Difficulty.ToModifier(result.Defense); result.Speed = result.Difficulty.ToModifier(result.Speed); result.Level = result.Difficulty.ToModifier(result.Level); // Get the new Max Health result.MaxHealth = DiceHelper.RollDice(result.Level, 10); // Adjust the health, If the new Max Health is above the rule for the level, use the original var MaxHealthAdjusted = result.Difficulty.ToModifier(result.MaxHealth); if (MaxHealthAdjusted < result.Level * 10) { result.MaxHealth = MaxHealthAdjusted; } // Level up to the new level result.LevelUpToValue(result.Level); // Set ExperienceRemaining so Monsters can both use this method result.ExperienceRemaining = LevelTableHelper.LevelDetailsList[result.Level + 1].Experience; // Enter Battle at full health result.CurrentHealth = result.MaxHealth; // Monsters can have weapons too.... if (Items) { result.Head = GetItem(ItemLocationEnum.Head); result.Necklass = GetItem(ItemLocationEnum.Necklass); result.PrimaryHand = GetItem(ItemLocationEnum.PrimaryHand); result.OffHand = GetItem(ItemLocationEnum.OffHand); result.RightFinger = GetItem(ItemLocationEnum.Finger); result.LeftFinger = GetItem(ItemLocationEnum.Finger); result.Feet = GetItem(ItemLocationEnum.Feet); } return(result); }
/// <summary> /// Get A Random Difficulty /// </summary> /// <returns></returns> public static string GetMonsterUniqueItem() { var itemIndex = DiceHelper.RollDice(1, ItemIndexViewModel.Instance.Dataset.Count()) - 1; var result = ItemIndexViewModel.Instance.Dataset.ElementAt(itemIndex).Id; return(result); }
/// <summary> /// Will drop between 1 and 4 items from the ItemModel set... /// </summary> public override List <ItemModel> GetRandomMonsterItemDrops(int round) { // Teams, You need to implement your own modification to the Logic cannot use mine as is. // You decide how to drop monster items, level, etc. // The Number drop can be Up to the Round Count, but may be less. // Negative results in nothing dropped /* * Once monster is killed for the round, they will drop their item. * 1. find which monsters were killed * 2. see if they have drop item * 3. move that item to the list. make a copy of it. * * We added in another method for helper. * */ var NumberToDrop = (DiceHelper.RollDice(1, round + 1) - 1); var result = new List <ItemModel>(); for (var i = 0; i < NumberToDrop; i++) { // Get a random Unique Item var data = ItemIndexViewModel.Instance.GetItem(RandomPlayerHelper.GetMonsterUniqueItem()); result.Add(data); } return(result); }
/// <summary> /// Call to make a new set of monsters... /// </summary> /// <returns></returns> public bool NewRound() { // End the existing round EndRound(); // Populate New Monsters... AddMonstersToRound(); // Make the PlayerList MakePlayerList(); //populate the potions for the round populatePotionsList(); // Set Order for the Round OrderPlayerListByTurnOrder(); for (int i = 0; i < PlayerList.Count; i++) { if (PlayerList[i].PlayerType == PlayerTypeEnum.Character && PlayerList[i].Name == "Mike") { Debug.WriteLine("Mike Has Died"); PlayerList[i].Alive = false; } } // Update Score for the RoundCount BattleScore.RoundCount++; //Roll for Hack 48 condition deathRollHack48 = DiceHelper.RollDice(1, 20); return(true); }
/// <summary> /// Get a Random Item for the Location /// /// Return the String for the ID /// </summary> /// <param name="location"></param> /// <returns></returns> public static string GetItem(ItemLocationEnum location) { var ItemList = ItemIndexViewModel.Instance.GetLocationItems(location); if (ItemList.Count == 0) { return(null); } // Add None to the list ItemList.Insert(0, new ItemModel { Id = null, Name = "None" }); var result = ItemList.First().Id; var index = DiceHelper.RollDice(1, ItemList.Count()) - 1; if (index < ItemList.Count) { result = ItemList.ElementAt(index).Id; } return(result); }
/// <summary> /// Level Up /// </summary> /// <returns></returns> public bool LevelUp() { for (var i = LevelTableHelper.Instance.LevelDetailsList.Count - 1; i > 0; i--) { // Check the Level // If the Level is > Experience for the Index, increment the Level. if (LevelTableHelper.Instance.LevelDetailsList[i].Experience <= Experience) { var NewLevel = LevelTableHelper.Instance.LevelDetailsList[i].Level; // When leveling up, the current health is adjusted up by an offset of the MaxHealth, rather than full restore var OldCurrentHealth = CurrentHealth; var OldMaxHealth = MaxHealth; // Set new Health // New health, is d10 of the new level. So leveling up 1 level is 1 d10, leveling up 2 levels is 2 d10. var NewHealthAddition = DiceHelper.RollDice(NewLevel - Level, 10); // Increment the Max health MaxHealth += NewHealthAddition; // Calculate new current health // old max was 10, current health 8, new max is 15 so (15-(10-8)) = current health CurrentHealth = (MaxHealth - (OldMaxHealth - OldCurrentHealth)); // Set the new level Level = NewLevel; // Done, exit return(true); } } return(false); }
/// <summary> /// Roll the Damage Dice, and add to the Damage /// </summary> /// <returns></returns> public int GetDamageRollValue() { var myReturn = 0; var myItem = ItemIndexViewModel.Instance.GetItem(PrimaryHand); // Also equipt with item picked during game var attackItem = ItemIndexViewModel.Instance.GetItem(AttackItem); // add in the attack item to damage if (attackItem != null) { // Dice of the weapon. So sword of Damage 10 is d10 myReturn += DiceHelper.RollDice(1, attackItem.Damage); } // add in the damage to primary hand IF attackitem is not picked. if (myItem != null && attackItem == null) { // Dice of the weapon. So sword of Damage 10 is d10 myReturn += DiceHelper.RollDice(1, myItem.Damage); } // Add in the Level as extra damage per game rules myReturn += GetDamageLevelBonus; return(myReturn); }
/// <summary> /// Add Monsters to the Round /// /// Because Monsters can be duplicated, will add 1, 2, 3 to their name /// /* * Hint: * I don't have crudi monsters yet so will add 6 new ones... * If you have crudi monsters, then pick from the list * Consdier how you will scale the monsters up to be appropriate for the characters to fight * */ /// </summary> /// <returns></returns> public int AddMonstersToRound() { var monsterModel = MonsterIndexViewModel.Instance; Random rnd = new Random(); int TargetLevel = 1; int MaxLevel = 20; if (CharacterList.Count() > 0) { // Get the Min Character Level (linq is soo cool....) TargetLevel = Convert.ToInt32(CharacterList.Min(m => m.Level)); MaxLevel = Convert.ToInt32(CharacterList.Max(m => m.Level)); } /* Hack 31 has been implemented. If the round count is > 100 * then the monster's speed, defense, attack, current health, and max health * are buffed 10x */ for (var i = 0; i < MaxNumberPartyMonsters; i++) { int index = rnd.Next(0, MaxNumberPartyMonsters - 1); var data = monsterModel.Dataset[index]; data.Level = TargetLevel; data.Speed = getAttributeLevel(); data.Defense = getAttributeLevel(); data.Attack = getAttributeLevel(); data.MaxHealth = DiceHelper.RollDice(TargetLevel, 10); data.CurrentHealth = data.MaxHealth; MonsterList.Add(new PlayerInfoModel(data)); } return(MonsterList.Count()); }
/// <summary> /// Attempts to change the level of the monster to the /// level provided. /// </summary> /// <param name="Level"></param> /// <returns></returns> public new bool ChangeLevel(int levelValue) { // level cannot be less than 1 if (levelValue < 1) { return(false); } // level cannot be greater than 20 if (levelValue > 20) { return(false); } // obtain attributes of level == value var NewLevelAttributes = LevelAttributesHelper.Instance.LevelAttributesList[levelValue]; // set Level and attributes Level = NewLevelAttributes.Level; Attack = NewLevelAttributes.Attack; Defense = NewLevelAttributes.Defense; Speed = NewLevelAttributes.Speed; ExperienceGiven = NewLevelAttributes.Experience; Range = NewLevelAttributes.Range; // calculate new health based on dice roll // set CurrentHealth as MaxHealth, since this method is used for scaling monsters up or down (rather than leveling up only) MaxHealth = CurrentHealth = DiceHelper.RollDice(levelValue, 10); // attributes successfully set return(true); }
// Call to make a new set of monsters... public bool NewRound() { // End the existing round EndRound(); // Populate New Monsters... AddMonstersToRound(); // Make the PlayerList MakePlayerList(); // Set Order for the Round OrderPlayerListByTurnOrder(); // Populate MapModel with Characters and Monsters MapModel.PopulateMapModel(PlayerList); // Update Score for the RoundCount BattleScore.RoundCount++; if (EnableConfusionRound && DiceHelper.RollDice(1, 20) > 10) { // Roll Confusion Round or not IsConfusionRound = true; } return(true); }
/// <summary> /// Roll To Hit /// </summary> /// <param name="AttackScore"></param> /// <param name="DefenseScore"></param> /// <returns></returns> public HitStatusEnum RollToHitTarget(int AttackScore, int DefenseScore) { var d20 = DiceHelper.RollDice(1, 20); if (d20 == 1) { // Force Miss BattleMessagesModel.HitStatus = HitStatusEnum.Miss; return(BattleMessagesModel.HitStatus); } if (d20 == 20) { // Force Hit BattleMessagesModel.HitStatus = HitStatusEnum.Hit; return(BattleMessagesModel.HitStatus); } var ToHitScore = d20 + AttackScore; if (ToHitScore < DefenseScore) { BattleMessagesModel.AttackStatus = " misses "; // Miss BattleMessagesModel.HitStatus = HitStatusEnum.Miss; BattleMessagesModel.DamageAmount = 0; return(BattleMessagesModel.HitStatus); } // Hit BattleMessagesModel.HitStatus = HitStatusEnum.Hit; return(BattleMessagesModel.HitStatus); }
/// <summary> /// Roll the Damage Dice, and add to the Damage /// </summary> /// <returns></returns> public int GetDamageRollValue() { var myReturn = 0; // Roll the dice for item damage, which are the damages from primary hand and Pokeball var itemDamage = GetDamageItemBonus; if (itemDamage != 0) { myReturn += DiceHelper.RollDice(1, itemDamage); } // Roll the dice for Pokedex damage var pokedexDamage = GetDamagePokedexBonus; if (pokedexDamage != 0) { myReturn += DiceHelper.RollDice(1, pokedexDamage); } // Add in the Level as extra damage per game rules myReturn += GetDamageLevelBonus; return(myReturn); }
/// <summary> /// Catch the change to the Stepper for Level /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Level_OnStepperValueChanged(object sender, ValueChangedEventArgs e) { var level = e.NewValue; LevelValue.Text = level.ToString(); ViewModel.Data.MaxHealth = DiceHelper.RollDice((int)level, 10); HealthValue.Text = string.Format(" : {0:G}", ViewModel.Data.MaxHealth); }
/// <summary> /// Calculates the health based on level /// </summary> /// <param name="level"></param> /// <returns></returns> public int GetPlayerMaxHealth(int level) { if (level < 0) { return(0); } // Roll the Dice and reset the Health return(DiceHelper.RollDice(level, 10)); }
/// <summary> /// Get Description /// /// Return a random description /// </summary> /// <returns></returns> public static string GetCharacterDescription() { List <String> StringList = new List <String> { "the terrible", "the awesome", "the lost", "the old", "the younger", "the quiet", "the loud", "the helpless", "the happy", "the sleepy", "the angry", "the clever" }; var result = StringList.ElementAt(DiceHelper.RollDice(1, StringList.Count()) - 1); return(result); }
/// <summary> /// Create Random monster for the Escaping school game. /// </summary> /// <param name="MaxLevel"></param> /// <returns></returns> public static MonsterModel GetRandomMonsterEscapingSchool(int MaxLevel) { var type = DiceHelper.RollDice(1, 2); if (type % 2 == 0) { return(GetRandomMonsterAdministrator(MaxLevel)); } return(GetRandomMonsterFaculty(MaxLevel)); }
/// <summary> /// Get Description /// /// Return a random description /// </summary> /// <returns></returns> public static string GetMonsterDescription() { List <String> StringList = new List <String> { "eats Elf", "the Elf hater", "Elf destoryer", "Elf Hunter", "Elf Killer", "Can't we all get along?" }; var result = StringList.ElementAt(DiceHelper.RollDice(1, StringList.Count()) - 1); return(result); }
/// <summary> /// Get Name /// /// Return a Random Name /// </summary> /// <returns></returns> public static string GetCharacterName() { List <String> FirstNameList = new List <String> { "Mike", "Doug", "Jea", "Sue", "Tim", "Daren", "Dani", "Mami", "Mari", "Ryu", "Hucky", "Peanut", "Sumi", "Apple", "Ami", "Honami", "Sonomi", "Pat", "Sakue", "Isamu" }; var result = FirstNameList.ElementAt(DiceHelper.RollDice(1, FirstNameList.Count()) - 1); return(result); }
public void RollDice_Invalid_Roll_1_Dice_0_Should_Return_Zero() { // Arrange // Act var result = DiceHelper.RollDice(1, 0); // Reset // Assert Assert.AreEqual(0, result); }
/// <summary> /// Create Random Character for Escaping School /// </summary> /// <param name="MaxLevel"></param> /// <returns></returns> public static CharacterModel GetRandomCharacterEscapingSchool(int MaxLevel) { var type = DiceHelper.RollDice(1, 2); if (type % 2 == 0) { return(GetRandomCharacterParent(MaxLevel)); } return(GetRandomCharacterStudent(MaxLevel)); }
/// <summary> /// Get Name /// /// Return a Random Name /// </summary> /// <returns></returns> public static string GetMonsterName() { List <String> FirstNameList = new List <String> { "Arg", "Deg", "Ase", "Xes", "Zez", "Klk", "Oi", "Oni", "Tanu" }; var result = FirstNameList.ElementAt(DiceHelper.RollDice(1, FirstNameList.Count()) - 1); return(result); }
/// <summary> /// Get Random Image /// </summary> /// <returns></returns> public static string GetCharacterImage() { List <String> FirstNameList = new List <String> { "item.png", "item.png", "item.png", "item.png", "item.png", "item.png", "item.png" }; var result = FirstNameList.ElementAt(DiceHelper.RollDice(1, FirstNameList.Count()) - 1); return(result); }
/// <summary> /// Get A Random Difficulty /// </summary> /// <returns></returns> public static DifficultyEnum GetMonsterDifficultyValue() { var DifficultyList = DifficultyEnumHelper.GetListMonster; var RandomDifficulty = DifficultyList.ElementAt(DiceHelper.RollDice(1, DifficultyList.Count()) - 1); var result = DifficultyEnumHelper.ConvertStringToEnum(RandomDifficulty); return(result); }
public void RollDice_Valid_Roll_1_Dice_6_Should_Return_Between_1_And_6() { // Arrange // Act var result = DiceHelper.RollDice(1, 6); // Reset // Assert Assert.AreEqual(true, result >= 1); Assert.AreEqual(true, result <= 6); }
public void RollDice_Valid_Roll_2_Dice_6_Should_Return_Between_2_And_12() { // Arrange // Act var result = DiceHelper.RollDice(2, 6); // Reset // Assert Assert.AreEqual(true, result >= 2); Assert.AreEqual(true, result <= 12); }
/// <summary> /// Roll To Hit /// </summary> /// <param name="AttackScore"></param> /// <param name="DefenseScore"></param> /// <returns></returns> public virtual HitStatusEnum RollToHitTarget(int AttackScore, int DefenseScore) { // Roll a 20 sided dice var d20 = DiceHelper.RollDice(1, 20); // if dice roll is 1, automatic miss if (d20 == 1) { EngineSettings.BattleMessagesModel.HitStatus = HitStatusEnum.Miss; EngineSettings.BattleMessagesModel.AttackStatus = " rolls 1 to miss "; if (EngineSettings.BattleSettingsModel.AllowCriticalMiss) { EngineSettings.BattleMessagesModel.AttackStatus = " rolls 1 to completly miss "; EngineSettings.BattleMessagesModel.HitStatus = HitStatusEnum.CriticalMiss; } return(EngineSettings.BattleMessagesModel.HitStatus); } // if dice is 20, automatic hit if (d20 == 20) { EngineSettings.BattleMessagesModel.AttackStatus = " rolls 20 for hit "; EngineSettings.BattleMessagesModel.HitStatus = HitStatusEnum.Hit; if (EngineSettings.BattleSettingsModel.AllowCriticalHit) { EngineSettings.BattleMessagesModel.AttackStatus = " rolls 20 for lucky hit "; EngineSettings.BattleMessagesModel.HitStatus = HitStatusEnum.CriticalHit; } return(EngineSettings.BattleMessagesModel.HitStatus); } // if hit score is less than defense, it's a miss var ToHitScore = d20 + AttackScore; if (ToHitScore < DefenseScore) { EngineSettings.BattleMessagesModel.AttackStatus = " rolls " + d20 + " and misses "; // Miss EngineSettings.BattleMessagesModel.HitStatus = HitStatusEnum.Miss; EngineSettings.BattleMessagesModel.DamageAmount = 0; return(EngineSettings.BattleMessagesModel.HitStatus); } EngineSettings.BattleMessagesModel.AttackStatus = " rolls " + d20 + " and hits "; // Hit EngineSettings.BattleMessagesModel.HitStatus = HitStatusEnum.Hit; return(EngineSettings.BattleMessagesModel.HitStatus); }