public void HackathonScenario_Scenario_30_Second_Character_Should__Not_Have_Buff() { /* * Scenario Number: * 30 * * Description: * The first player in the player list gets their base attack, speed, defense * values buffed by 2X for the first time they are first in the list. * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * See Defualt Test * * Test Algrorithm: * Create 2 Characters named Bugs and Michael. * Add them to the Player List. * Order the Player List. * Test Conditions: * Control Dice roll so natural hit * Test with Character of not named Bob * * Validation * Verify Enum is Hit * */ //Arrange // Set Character Conditions BattleEngine.MaxNumberPartyCharacters = 2; int tempSpeed = 200; int tempAttack = 1; int tempDefense = 1; var CharacterPlayer1 = new PlayerInfoModel( new CharacterModel { Speed = 200, Level = 1, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Defense = 1, Attack = 1, Name = "Bugs", }); var CharacterPlayer2 = new PlayerInfoModel( new CharacterModel { Speed = 200, Level = 1, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Attack = 1, Defense = 1, Name = "Michael", }); BattleEngine.PlayerList.Add(CharacterPlayer1); BattleEngine.PlayerList.Add(CharacterPlayer2); //Act var result = BattleEngine.OrderPlayerListByTurnOrder(); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(((tempSpeed + result[1].GetSpeedLevelBonus)), result[1].Speed); Assert.AreEqual(((tempAttack + result[1].GetAttackLevelBonus)), result[1].Attack); Assert.AreEqual(((tempDefense + result[1].GetDefenseLevelBonus)), result[1].Defense); }
public async Task AutoBattleEngine_RunAutoBattle_InValid_Trun_Loop_Should_Fail() { /* * Test infinate turn. * * Monsters overpower Characters game never ends * * 1 Character * Speed low * Hit weak * Health low * * 6 Monsters * Speed High * Hit strong * Health High * * Rolls for always Miss * * Should never end * * Inifinite Loop Check should stop the game * */ //Arrange // Add Characters AutoBattle.Battle.EngineSettings.MaxNumberPartyCharacters = 1; var CharacterPlayerMike = new PlayerInfoModel( new CharacterModel { Speed = 1, Level = 1, MaxHealth = 1, CurrentHealth = 1, }); AutoBattle.Battle.EngineSettings.CharacterList.Add(CharacterPlayerMike); // Add Monsters AutoBattle.Battle.EngineSettings.MaxNumberPartyMonsters = 6; // Controll Rolls, Always Miss DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(1); //Act var result = await AutoBattle.RunAutoBattle(); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(false, result); Assert.AreEqual(true, AutoBattle.Battle.EngineSettings.BattleScore.TurnCount > AutoBattle.Battle.EngineSettings.MaxTurnCount); Assert.AreEqual(true, AutoBattle.Battle.EngineSettings.BattleScore.RoundCount < AutoBattle.Battle.EngineSettings.MaxRoundCount); }
/// <summary> /// Run Auto Battle /// </summary> /// <returns></returns> public async Task <bool> RunAutoBattle() { RoundEnum RoundCondition; Debug.WriteLine("Auto Battle Starting"); // Auto Battle, does all the steps that a human would do. // Prepare for Battle bool Ifeelgood = false; var d20 = DiceHelper.RollDice(1, 20); if (d20 < 10) { //Do not Use Special Ability Ifeelgood = false; } CreateCharacterParty(Ifeelgood); // Start Battle in AutoBattle mode StartBattle(true); // Fight Loop. Continue until Game is Over... do { // Check for excessive duration. if (DetectInfinateLoop()) { Debug.WriteLine("Aborting, More than Max Rounds"); EndBattle(); return(false); } Debug.WriteLine("Next Turn"); // Do the turn... // If the round is over start a new one... RoundCondition = RoundNextTurn(); if (RoundCondition == RoundEnum.NewRound) { NewRound(); Debug.WriteLine("New Round"); //if round is 2 reincarnate any character if (BattleScore.RoundCount == 2) { if (BattleScore.CharacterModelDeathList.Count > 0) { BattleScore.CharacterModelDeathList[0].Alive = true; CharacterList.Add(BattleScore.CharacterModelDeathList[0]); BattleMessagesModel.ReincarnatedCharName = BattleScore.CharacterModelDeathList[0].Name; Debug.WriteLine(BattleMessagesModel.GetReincarnatedPlayerMessage()); WasReincarnated = true; } } } } while (RoundCondition != RoundEnum.GameOver); Debug.WriteLine("Game Over"); // Wrap up EndBattle(); return(true); }
/// <summary> /// CharacterModel Attacks... /// </summary> /// <param name="Attacker"></param> /// <returns></returns> public virtual bool TakeTurn(PlayerInfoModel Attacker) { // Choose Action. Such as Move, Attack etc. // INFO: Teams, if you have other actions they would go here. bool result = false; // If the action is not set, then try to set it or use Attact if (EngineSettings.CurrentAction == ActionEnum.Unknown) { // Set the action if one is not set EngineSettings.CurrentAction = DetermineActionChoice(Attacker); // When in doubt, attack... if (EngineSettings.CurrentAction == ActionEnum.Unknown) { EngineSettings.CurrentAction = ActionEnum.Attack; } } // Check to see if hackathon scenarios should be enabled. if (BattleEngineViewModel.Instance.Engine.EngineSettings.HackathonDebug && Attacker.WantsToRest) { var num = DiceHelper.RollDice(1, 2); // Randomize whether character will keep its current action or rest as its move. if (num % 2 == 0) { EngineSettings.CurrentAction = ActionEnum.Rest; } } // Check to see if hackathon scenarios should be enabled. if (BattleEngineViewModel.Instance.Engine.EngineSettings.HackathonDebug && BattleEngineViewModel.Instance.Engine.EngineSettings.SeattleWinter && Attacker.PlayerType == PlayerTypeEnum.Character) { var randomInt = DiceHelper.RollDice(1, 100); var percentage = BattleEngineViewModel.Instance.Engine.EngineSettings.SeattleWinterLikelihood; // Randomize whether character will keep its current action or rest as its move. if (randomInt <= percentage) { EngineSettings.CurrentAction = ActionEnum.Slip; } } switch (EngineSettings.CurrentAction) { case ActionEnum.Attack: result = Attack(Attacker); break; case ActionEnum.Ability: result = UseAbility(Attacker); break; case ActionEnum.Move: result = MoveAsTurn(Attacker); break; case ActionEnum.Rest: result = RestAsTurn(Attacker); break; case ActionEnum.Slip: result = SlipAsTurn(Attacker); break; case ActionEnum.SpecialAbility: result = UseSpecialAbility(Attacker); break; } EngineSettings.BattleScore.TurnCount++; // Save the Previous Action off EngineSettings.PreviousAction = EngineSettings.CurrentAction; // Reset the Action to unknown for next time EngineSettings.CurrentAction = ActionEnum.Unknown; return(result); }
private void _battleActionListBox_SelectionChanged(object sender, BattleActions action) { _battleActionListBox.ClearSelection(); bool playerIsDefending = false; var playerCombatProfile = GameManager.Instance.State.GetPlayerCombatProfile(); //TODO: Take equipped items into consideration switch (action) { case BattleActions.Attack: var result = CombatHelper.ResolveAttack(playerCombatProfile, _currentEnemy); switch (result.Result) { case AttackResultCode.Missed: _outputBox.AddOutput($"Player attack missed enemy {_currentEnemy.Name}"); break; case AttackResultCode.ArmorBlocked: _outputBox.AddOutput($"Enemy {_currentEnemy.Name}'s armor blocked the attack"); break; case AttackResultCode.DidDamage: _outputBox.AddOutput($"Player did {result.DamageDone} damage to {_currentEnemy.Name}"); _currentEnemy.Health -= result.DamageDone; SetHealth(_enemyHealth, Math.Max(0, _currentEnemy.Health), false); break; } break; case BattleActions.Defend: playerIsDefending = true; playerCombatProfile.Defense = Convert.ToInt32(playerCombatProfile.Defense * 1.3); playerCombatProfile.Armor = Convert.ToInt32(playerCombatProfile.Armor * 1.2); _outputBox.AddOutput("Player is defending"); break; case BattleActions.Run: if (!string.IsNullOrEmpty(_encounter.RunConditional)) { var conditionalResult = EmbeddedFunctionsHelper.Conditional(_encounter.RunConditional); if (!string.IsNullOrEmpty(conditionalResult.Output)) { _outputBox.AddOutput(conditionalResult.Output); } if (conditionalResult.Success) { TriggerContinue(EncounterState.RunAway); } } else { TriggerContinue(EncounterState.RunAway); } return; case BattleActions.Continue: switch (_encounterState) { case EncounterState.Default: break; case EncounterState.RunAway: EncounterManager.Instance.Exit(); break; case EncounterState.PlayerWon: EncounterManager.Instance.PlayerWon(_encounter); break; case EncounterState.PlayerDied: EncounterManager.Instance.PlayerDied(_encounter); break; } return; } if (_currentEnemy.Health > 0) { if (!_enemyIsStunned) { var result = CombatHelper.ResolveAttack(_currentEnemy, playerCombatProfile); switch (result.Result) { case AttackResultCode.Missed: _outputBox.AddOutput($"{_currentEnemy.Name}'s attack missed player"); break; case AttackResultCode.ArmorBlocked: _outputBox.AddOutput($"Player's armor blocked the attack"); break; case AttackResultCode.DidDamage: _outputBox.AddOutput($"{_currentEnemy.Name} did {result.DamageDone} damage to player"); GameManager.Instance.State.Health -= result.DamageDone; SetHealth(_playerHealth, GameManager.Instance.State.Health, false); break; } } { _enemyIsStunned = false; _outputBox.AddOutput($"{_currentEnemy.Name}'s was temporarily stunned"); } if (playerIsDefending && DiceHelper.RollD6() >= 5) { _enemyIsStunned = true; _outputBox.AddOutput($"{_currentEnemy.Name}'s is stunned"); } } else { _outputBox.AddOutput($"{_currentEnemy.Name} died!"); if (_encounter.Enemies.Any()) { NextEnemy(); _outputBox.AddOutput($"New enemy {_currentEnemy.Name} appeared!"); } else { _outputBox.AddOutput($"Victory! Player successfully defeated encounter!"); TriggerContinue(EncounterState.PlayerWon); } } if (GameManager.Instance.State.Health <= 0) { GameManager.Instance.State.Health = 0; SetHealth(_playerHealth, GameManager.Instance.State.Health, false); _outputBox.AddOutput("Player died :'("); TriggerContinue(EncounterState.PlayerDied); } }
public void HackathonScenario_Scenario_2_Character_Bob_Should_Miss() { /* * Scenario Number: * 2 * * Description: * Make a Character called Bob * Bob Always Misses * Other Characters Always Hit * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * Change to Turn Engine * Changed TurnAsAttack method * Check for Name of Bob and return miss * * Test Algrorithm: * Create Character named Bob * Create Monster * Call TurnAsAttack * * Test Conditions: * Test with Character of Named Bob * Test with Character of any other name * * Validation: * Verify Enum is Miss * */ //Arrange // Set Character Conditions EngineViewModel.Engine.MaxNumberPartyCharacters = 1; var CharacterPlayer = new PlayerInfoModel( new BaseCharacter { Speed = 200, Level = 10, CurrHealth = 100, Experience = 100, ExperienceRemaining = 1, Name = "Bob", }); EngineViewModel.Engine.CharacterList.Add(CharacterPlayer); // Set Monster Conditions // Add a monster to attack EngineViewModel.Engine.MaxNumberPartyCharacters = 1; var MonsterPlayer = new PlayerInfoModel( new BaseMonster { Speed = 1, Level = 1, CurrHealth = 1, Experience = 1, ExperienceRemaining = 1, Name = "Monster", }); EngineViewModel.Engine.CharacterList.Add(MonsterPlayer); // Have dice rull 19 DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(19); //Act var result = EngineViewModel.Engine.TurnAsAttack(CharacterPlayer, MonsterPlayer); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(true, result); Assert.AreEqual(HitStatusEnum.Miss, EngineViewModel.Engine.BattleMessagesModel.HitStatus); }
public async Task HackathonScenario_Scenario_1_Valid_Default_Should_Pass() { /* * Scenario Number: * 1 * * Description: * Make a Character called Mike, who dies in the first round * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * No Code changes requied * * Test Algrorithm: * Create Character named Mike * Set speed to -1 so he is really slow * Set Max health to 1 so he is weak * Set Current Health to 1 so he is weak * * Startup Battle * Run Auto Battle * * Test Conditions: * Default condition is sufficient * * Validation: * Verify Battle Returned True * Verify Mike is not in the Player List * Verify Round Count is 1 * */ //Arrange // Set Character Conditions EngineViewModel.Engine.EngineSettings.MaxNumberPartyCharacters = 1; var CharacterPlayerMike = new PlayerInfoModel( new CharacterModel { Speed = -1, // Will go last... Level = 1, CurrentHealth = 1, ExperienceTotal = 1, ExperienceRemaining = 1, Name = "Mike", }); EngineViewModel.Engine.EngineSettings.CharacterList.Add(CharacterPlayerMike); // Set Monster Conditions // Auto Battle will add the monsters // Monsters always hit EngineViewModel.Engine.EngineSettings.BattleSettingsModel.MonsterHitEnum = HitStatusEnum.Hit; DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(3); //Act var result = await EngineViewModel.AutoBattleEngine.RunAutoBattle(); //Reset EngineViewModel.Engine.EngineSettings.CharacterList.Clear(); EngineViewModel.Engine.EngineSettings.PlayerList.Clear(); EngineViewModel.Engine.EngineSettings.BattleSettingsModel.MonsterHitEnum = HitStatusEnum.Default; DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(true, result); Assert.AreEqual(null, EngineViewModel.Engine.EngineSettings.PlayerList.Find(m => m.Name.Equals("Mike"))); Assert.AreEqual(1, EngineViewModel.Engine.EngineSettings.BattleScore.RoundCount); }
int getAttributeLevel() { return(DiceHelper.RollDice(1, 10) - 1); }
/// <summary> /// Hack #48 /// Gets a number from roll dice of D20 /// </summary> public void GenerateSecretNumber() { SecretNumber = DiceHelper.RollDice(1, 20); }
/// <summary> /// // MonsterModel Attacks CharacterModel /// </summary> public override bool TurnAsAttack(PlayerInfoModel Attacker, PlayerInfoModel Target) { // Check Null inputs if (Attacker == null) { return(false); } if (Target == null) { return(false); } // Set Messages to empty EngineSettings.BattleMessagesModel.ClearMessages(); // Do the Attack CalculateAttackStatus(Attacker, Target); // See if the Battle Settings Overrides the Roll EngineSettings.BattleMessagesModel.HitStatus = BattleSettingsOverride(Attacker); if (Attacker.Name == "Bob") { EngineSettings.BattleMessagesModel.HitStatus = HitStatusEnum.Miss; EngineSettings.BattleMessagesModel.AttackStatus = " rolls 1 to miss "; } switch (EngineSettings.BattleMessagesModel.HitStatus) { case HitStatusEnum.Miss: // It's a Miss break; case HitStatusEnum.CriticalMiss: // It's a Critical Miss, so Bad things may happen DetermineCriticalMissProblem(Attacker); break; case HitStatusEnum.CriticalHit: case HitStatusEnum.Hit: // It's a Hit // Calculate Damage EngineSettings.BattleMessagesModel.DamageAmount = Attacker.GetDamageRollValue(); // If Quick Attacker, 50% chance to deal critical Hit, double the damage if (Attacker.PlayerType == PlayerTypeEnum.Character && Attacker.Job == CharacterJobEnum.QuickAttacker) { // Roll Dice var d = DiceHelper.RollDice(1, 10); // 50% to double the damage if (d <= 5) { EngineSettings.BattleMessagesModel.DamageAmount *= 2; } } // Apply the Damage ApplyDamage(Target); EngineSettings.BattleMessagesModel.TurnMessageSpecial = EngineSettings.BattleMessagesModel.GetCurrentHealthMessage(); // Check if Dead and Remove RemoveIfDead(Target); // If it is a character apply the experience earned CalculateExperience(Attacker, Target); break; } // Turn Message EngineSettings.BattleMessagesModel.TurnMessage = Attacker.Name + EngineSettings.BattleMessagesModel.AttackStatus + Target.Name + EngineSettings.BattleMessagesModel.TurnMessageSpecial + EngineSettings.BattleMessagesModel.ExperienceEarned; Debug.WriteLine(EngineSettings.BattleMessagesModel.TurnMessage); return(true); }
private DieRoll GetRoll() { return(DiceHelper.GetRoll()); }
public void HackathonScenario_Scenario_33_Characters_Should_NOT_Lose_Health() { /* * Scenario Number: * 33 * * Description: * Check the round number. If it is round 13, then bad things happen to characters. * They will randomly drop items, loose heath, may even fall over dead. * You decide how unlucky their day will be. * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * See Default Test * * Test Algrorithm: * Create 2 Characters. * Add them to the Player List. * Initiate a new Round * Test Conditions: * Test Character's Current Health change. * RoundCount is 13. * * Validation * Verify Characters do not lose 13 Current Health points. * */ //Arrange // Set Round Count BattleEngine.BattleScore.RoundCount = 12; // Set Character Conditions BattleEngine.MaxNumberPartyCharacters = 2; int tempCurrentHealth = 100; var CharacterPlayer1 = new PlayerInfoModel( new CharacterModel { Speed = 100, Level = 1, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Defense = 1, Attack = 1, Name = "Bugs", }); var CharacterPlayer2 = new PlayerInfoModel( new CharacterModel { Speed = 100, Level = 1, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Defense = 1, Attack = 1, Name = "Daffy", }); BattleEngine.PlayerList.Add(CharacterPlayer1); BattleEngine.PlayerList.Add(CharacterPlayer2); //Act var result = BattleEngine.OrderPlayerListByTurnOrder(); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(tempCurrentHealth, result[0].GetCurrentHealthTotal); Assert.AreEqual(tempCurrentHealth, result[1].GetCurrentHealthTotal); }
public void HackathonScenario_Scenario_31_Monsters_Should_Not_Be_Buffed() { /* * Scenario Number: * 31 * * Description: * After round 100, the monster's attributes should be buffed 10x what they normally are. * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * See Default Test * * Test Algrorithm: * Create 1 Character and 1 Monster. * Add them to the Player List. * Order the Player List. * Test Conditions: * Test with Characters with low speed and Monsters with high speed. * RoundCount is 5. * * Validation * Verify Monsters come before Characters in the PlayerList. * */ //Arrange // Set Round Count int tempSpeed = 200; int tempAttack = 1; int tempDefense = 1; int tempCurrentHealth = 100; int maxHealth = 1000; BattleEngine.MaxNumberPartyMonsters = 2; BattleEngine.BattleScore.RoundCount = 99; // Set Monster Conditions var MonsterPlayer1 = new PlayerInfoModel( new MonsterModel { Speed = 200, Level = 1, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Defense = 1, Attack = 1, MaxHealth = 1000, Name = "Daffy", }); var MonsterPlayer2 = new PlayerInfoModel( new MonsterModel { Speed = 200, Level = 1, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Defense = 1, Attack = 1, MaxHealth = 1000, Name = "Duck", }); BattleEngine.PlayerList.Add(MonsterPlayer1); BattleEngine.PlayerList.Add(MonsterPlayer2); //Act var result = BattleEngine.OrderPlayerListByTurnOrder(); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(((tempSpeed + result[1].GetSpeedLevelBonus)), result[1].Speed); Assert.AreEqual(((tempAttack + result[1].GetAttackLevelBonus)), result[1].Attack); Assert.AreEqual(((tempDefense + result[1].GetDefenseLevelBonus)), result[1].Defense); Assert.AreEqual((tempCurrentHealth), result[1].CurrentHealth); Assert.AreEqual((maxHealth), result[1].MaxHealth); }
public void HackathonScenario_Scenario_32_First_Player_Should_Not_Be_Character() { /* * Scenario Number: * 32 * * Description: * Every 5th round, the sort order for turn order changes and list is sorted by Characters first, * then lowest health, then lowest speed. * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * See Default Test * * Test Algrorithm: * Create 1 Character and 1 Monster. * Add them to the Player List. * Order the Player List. * Test Conditions: * Test with Characters with low speed and Monsters with high speed. * RoundCount is 5. * * Validation * Verify Monsters come before Characters in the PlayerList. * */ //Arrange // Set Round Count BattleEngine.BattleScore.RoundCount = 4; // Set Character Conditions BattleEngine.MaxNumberPartyCharacters = 2; var CharacterPlayer = new PlayerInfoModel( new CharacterModel { Speed = 100, Level = 1, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Defense = 1, Attack = 1, Name = "Bugs", }); BattleEngine.PlayerList.Add(CharacterPlayer); // Set Monster Conditions var MonsterPlayer = new PlayerInfoModel( new MonsterModel { Speed = 500, Level = 1, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Defense = 1, Attack = 1, Name = "Daffy", }); BattleEngine.PlayerList.Add(MonsterPlayer); //Act var result = BattleEngine.OrderPlayerListByTurnOrder(); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(PlayerTypeEnum.Monster, result[0].PlayerType); }
/// <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); //Hack #3, Sets the attaker with a HitValue if (CurrentAttacker.PlayerType == PlayerTypeEnum.Character && this.CharacterHitValue != 0) { d20 = this.CharacterHitValue; } if (CurrentAttacker.PlayerType == PlayerTypeEnum.Monster && this.MonsterHitValue != 0) { d20 = this.MonsterHitValue; } // Hack #48 When roll matches secret number, Character should die /* * if (d20 == SecretNumber) * { * CurrentAttacker.Alive = false; * BattleMessagesModel.AttackStatus = " rolls " + d20; * return HitStatusEnum.Unknown; * * } */ // Hack changes ended if (d20 == 1) { BattleMessagesModel.AttackStatus = " rolls 1 to completly miss "; // Force Miss BattleMessagesModel.HitStatus = HitStatusEnum.Miss; return(BattleMessagesModel.HitStatus); } if (d20 == 20) { BattleMessagesModel.AttackStatus = " rolls 20 for lucky hit "; // Force Hit BattleMessagesModel.HitStatus = HitStatusEnum.Hit; return(BattleMessagesModel.HitStatus); } var ToHitScore = d20 + AttackScore; if (ToHitScore < DefenseScore) { BattleMessagesModel.AttackStatus = " rolls " + d20 + " and misses "; // Miss BattleMessagesModel.HitStatus = HitStatusEnum.Miss; BattleMessagesModel.DamageAmount = 0; return(BattleMessagesModel.HitStatus); } BattleMessagesModel.AttackStatus = " rolls " + d20 + " and hits "; // Hit BattleMessagesModel.HitStatus = HitStatusEnum.Hit; return(BattleMessagesModel.HitStatus); }
/// <summary> /// Get Health /// </summary> /// <param name="level"></param> /// <returns></returns> public static int GetHealth(int level) { // Roll the Dice and reset the Health return(DiceHelper.RollDice(level, 10)); }
// Attack or Move // Roll To Hit // Decide Hit or Miss // Decide Damage // Death // Drop Items // Turn Over #endregion Algrorithm /// <summary> /// CharacterModel Attacks... /// </summary> /// <param name="Attacker"></param> /// <returns></returns> public bool TakeTurn(EntityInfoModel Attacker) { // Choose Action. Such as Move, Attack etc. // INFO: Teams, if you have other actions they would go here. bool result = false; // Check for confusion round or not, if it is confusion round and rolled confusion, skip turn if (EnableConfusionRound && IsConfusionRound && DiceHelper.RollDice(1, 20) - Attacker.Level > 0) { BattleMessageModel.TurnMessage = Attacker.Name + " is confused."; Debug.WriteLine(BattleMessageModel.TurnMessage); return(true); } if (Attacker.PlayerType == PlayerTypeEnum.Monster) { if (BattleScore.TurnCount >= PlayerList.Count) { Awake = true; } /* * Order of Priority * If can attack Then Attack * Next use Ability or Move */ // Assume Move if nothing else happens CurrentAction = ActionEnum.Move; Debug.WriteLine(BattleScore.TurnCount); if (!Awake) { CurrentAction = ActionEnum.Sleep; } // See if Desired Target is within Range, and if so attack away else if (MapModel.IsTargetInRange(Attacker, AttackChoice(Attacker))) { CurrentAction = ActionEnum.Attack; } } else { if (SLEEPINGTEST) { int listNo = Attacker.ListOrder; if ((listNo * 2 + 1) == BattleScore.RoundCount) { foreach (var player in PlayerList) { if (player.PlayerType == PlayerTypeEnum.Monster) { player.FallAsleep(); } } Awake = false; } } if (false) { if (BattleScore.AutoBattle) { /* * Order of Priority * If can attack Then Attack * Next use Ability or Move */ // Assume Move if nothing else happens CurrentAction = ActionEnum.Move; // See if Desired Target is within Range, and if so attack away if (MapModel.IsTargetInRange(Attacker, AttackChoice(Attacker))) { CurrentAction = ActionEnum.Attack; } // Simple Logic is Roll to Try Ability. 50% says try else if (DiceHelper.RollDice(1, 10) > 5) { CurrentAction = ActionEnum.Ability; } } } } switch (CurrentAction) { case ActionEnum.Unknown: case ActionEnum.Attack: result = Attack(Attacker); break; case ActionEnum.Ability: result = UseAbility(Attacker); break; case ActionEnum.Sleep: result = FallAsleep(Attacker); break; case ActionEnum.Move: result = MoveAsTurn(Attacker, TargetLocation); break; } BattleScore.TurnCount++; return(result); //return result; }
/// <summary> /// Get Random Ability Number /// </summary> /// <returns></returns> public static int GetAbilityValue() { // 0 to 9, not 1-10 return(DiceHelper.RollDice(1, 10) - 1); }
public async Task HackathonScenario_Scenario_9_Valid_Perfect_Items_Should_Not_Deliver() { /* * Scenario Number: * 9 * * Description: * 9. Just in Time Delivery * * Changes Required (Classes, Methods etc.) : * Modifies EndRound() in RoundEngine.cs * * Test Algrorithm: * Add one character with 8 items, all with value 20 * Run 1 round to try to have deliver * Startup Battle * Run Auto Battle * * Test Conditions: * Number of items in ItemsViewModel * * Validation: * Number of items in ItemsViewModel should not change */ //Arrange // Max Character Size is 1 EngineViewModel.Engine.EngineSettings.MaxNumberPartyCharacters = 1; // Make sure all items (except Pokeball) are delivered EngineViewModel.Engine.EngineSettings.MaxRoundCount = 1; // Monster always miss EngineViewModel.Engine.EngineSettings.BattleSettingsModel.MonsterHitEnum = HitStatusEnum.Miss; // Amazon delivers EngineViewModel.Engine.EngineSettings.BattleSettingsModel.AllowAmazonDelivery = true; // Add Items var FeetItem = new ItemModel { Name = "Test", Location = ItemLocationEnum.Feet, Attribute = AttributeEnum.Attack, Value = 20 }; var NeckItem = new ItemModel { Name = "Test", Location = ItemLocationEnum.Necklass, Attribute = AttributeEnum.Attack, Value = 20 }; var PHandItem = new ItemModel { Name = "Test", Location = ItemLocationEnum.PrimaryHand, Attribute = AttributeEnum.Attack, Value = 20 }; var OHandItem = new ItemModel { Name = "Test", Location = ItemLocationEnum.OffHand, Attribute = AttributeEnum.Attack, Value = 20 }; var LFingerItem = new ItemModel { Name = "Test", Location = ItemLocationEnum.Finger, Attribute = AttributeEnum.Attack, Value = 20 }; var RFingerItem = new ItemModel { Name = "Test", Location = ItemLocationEnum.Finger, Attribute = AttributeEnum.Attack, Value = 20 }; var PokeballItem = new ItemModel { Name = "Test", Location = ItemLocationEnum.Pokeball, Attribute = AttributeEnum.Attack, Value = 20 }; var HeadItem = new ItemModel { Name = "Test", Location = ItemLocationEnum.Head, Attribute = AttributeEnum.Attack, Value = 20 }; await ItemIndexViewModel.Instance.CreateAsync(FeetItem); await ItemIndexViewModel.Instance.CreateAsync(NeckItem); await ItemIndexViewModel.Instance.CreateAsync(PHandItem); await ItemIndexViewModel.Instance.CreateAsync(OHandItem); await ItemIndexViewModel.Instance.CreateAsync(LFingerItem); await ItemIndexViewModel.Instance.CreateAsync(RFingerItem); await ItemIndexViewModel.Instance.CreateAsync(PokeballItem); await ItemIndexViewModel.Instance.CreateAsync(HeadItem); ItemIndexViewModel.Instance.SetNeedsRefresh(true); // Add Character var CharacterPlayer = new PlayerInfoModel(new CharacterModel { Speed = 10, Level = 20, CurrentHealth = 1000, ExperienceTotal = 4, ExperienceRemaining = 5, Name = "Test", Feet = FeetItem.Id, Necklass = NeckItem.Id, PrimaryHand = PHandItem.Id, OffHand = OHandItem.Id, LeftFinger = LFingerItem.Id, RightFinger = RFingerItem.Id, Pokeball = PokeballItem.Id, Head = HeadItem.Id }); EngineViewModel.Engine.EngineSettings.CharacterList.Add(CharacterPlayer); EngineViewModel.Engine.EngineSettings.PlayerList.Add(CharacterPlayer); // Dice for monster drop, set to 0 so monster does not drop items DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(1); //Act var OldItemsCount = ItemIndexViewModel.Instance.Dataset.Count(); await EngineViewModel.AutoBattleEngine.RunAutoBattle(); var NewItemsCount = ItemIndexViewModel.Instance.Dataset.Count(); //Reset EngineViewModel.Engine.EngineSettings.CharacterList.Clear(); EngineViewModel.Engine.EngineSettings.PlayerList.Clear(); EngineViewModel.Engine.EngineSettings.MaxRoundCount = 100; EngineViewModel.Engine.EngineSettings.BattleSettingsModel.MonsterHitEnum = HitStatusEnum.Default; DiceHelper.DisableForcedRolls(); await ItemIndexViewModel.Instance.DeleteAsync(FeetItem); await ItemIndexViewModel.Instance.DeleteAsync(NeckItem); await ItemIndexViewModel.Instance.DeleteAsync(PHandItem); await ItemIndexViewModel.Instance.DeleteAsync(OHandItem); await ItemIndexViewModel.Instance.DeleteAsync(LFingerItem); await ItemIndexViewModel.Instance.DeleteAsync(RFingerItem); await ItemIndexViewModel.Instance.DeleteAsync(PokeballItem); await ItemIndexViewModel.Instance.DeleteAsync(HeadItem); EngineViewModel.Engine.EngineSettings.BattleSettingsModel.AllowAmazonDelivery = false; //Assert Assert.AreEqual(NewItemsCount, OldItemsCount); }
/// <summary> /// Get a Random Level /// </summary> /// <returns></returns> public static int GetLevel() { // 1-20 return(DiceHelper.RollDice(1, 20)); }
/// <summary> /// Attack the Target this Turn /// </summary> /// <param name="Attacker"></param> /// <param name="AttackScore"></param> /// <param name="Target"></param> /// <param name="DefenseScore"></param> /// <returns></returns> public bool TurnAsAttack(PlayerInfoModel Attacker, PlayerInfoModel Target) { if (Attacker == null) { return(false); } if (Target == null) { return(false); } BattleMessagesModel.TurnMessage = string.Empty; BattleMessagesModel.TurnMessageSpecial = string.Empty; BattleMessagesModel.AttackStatus = string.Empty; BattleMessagesModel.PlayerType = PersonTypeEnum.Monster; var AttackScore = Attacker.Level + Attacker.CurrentStrength; var DefenseScore = Target.CurrentThiccness + Target.Level; // Choose who to attack BattleMessagesModel.TargetName = Target.Name; BattleMessagesModel.AttackerName = Attacker.Name; // Hack #47: Character Attribute equal Prime should deal Max damage if (isTotalPrime(Attacker) == true) { BattleMessagesModel.HitStatus = HitStatusEnum.Hit; } else { BattleMessagesModel.HitStatus = RollToHitTarget(AttackScore, DefenseScore); } // Hackathon #2: Characters named Bob should miss if (Attacker.Name.Contains("Bob")) { BattleMessagesModel.HitStatus = HitStatusEnum.Miss; } Debug.WriteLine(BattleMessagesModel.GetTurnMessage()); // It's a Miss if (BattleMessagesModel.HitStatus == HitStatusEnum.Miss) { return(true); } // It's a Hit if (BattleMessagesModel.HitStatus == HitStatusEnum.Hit) { int Damage = Attacker.CurrentStrength; //Calculate Damage if (Attacker.Head != null) { Damage = CalculateDamage(Attacker); // Hack 47: Continued Damage = isPrime(Attacker, Damage); // Hackathon 43: Go SU RedHawks //if (ItemIndexViewModel.Instance.GetItem(Attacker.ItemOne).Description == "Go SU RedHawks") //{ // // Inflict 2x damage // Damage = Attacker.CurrentStrength + (2 * (ItemIndexViewModel.Instance.GetItem(Attacker.ItemOne).Value)); // Debug.WriteLine("Go SU!"); //} //else //{ // Damage = Attacker.CurrentStrength + ItemIndexViewModel.Instance.GetItem(Attacker.ItemOne).Value; //} } BattleMessagesModel.DamageAmount = Damage; Target.TakeDamage(BattleMessagesModel.DamageAmount); // Hackathon 25: Rebound Damage float chance = DiceHelper.RollDice(1, 100) / 100f; if (SettingsHelper.ReboundEnabled && chance <= SettingsHelper.REBOUND_CHANCE) { int ReboundDamage = (int)(Damage / 2); // Don't allow the player to die from rebound damage, leave them with at least 1 hit point if (Attacker.CurrentHitPoints - ReboundDamage <= 0) { ReboundDamage = Attacker.CurrentHitPoints - 1; } Debug.WriteLine("The attack rebounded! Took " + ReboundDamage + " damage!"); Attacker.TakeDamage(ReboundDamage); } // Hackathon 24: Rental Insurance (Break Item) chance = DiceHelper.RollDice(1, 100) / 100f; if (SettingsHelper.RentalInsuranceEnabled && chance <= SettingsHelper.RENTAL_INSURANCE_TEST) { Debug.WriteLine(Attacker.Name + "'s " + ItemIndexViewModel.Instance.GetItem(Attacker.Head).Name + " broke!"); Attacker.Head = null; } } BattleMessagesModel.CurrentHealth = Target.CurrentHitPoints; BattleMessagesModel.TurnMessageSpecial = BattleMessagesModel.GetCurrentHealthMessage(); //Check if Target is dead RemoveIfDead(Target); BattleMessagesModel.TurnMessage = Attacker.Name + BattleMessagesModel.AttackStatus + Target.Name + BattleMessagesModel.TurnMessageSpecial; Debug.WriteLine(BattleMessagesModel.TurnMessage); return(true); }
/// <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 Type MonsterType = GetMonsterType(), // Randomize the Attributes Attack = GetAbilityValue(), Speed = GetAbilityValue(), Defense = GetAbilityValue(), SpecialAttack = 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); }
//constructor of the class public CharacterModel() { this.Name = "this is Name"; this.Description = "this is Character Description"; this.MaxHealth = DiceHelper.RollDice((int)Level, 10); }
/// <summary> /// Character experience a critical miss. /// After rolling a critical miss. Roll a 10 sided dice. The following things can happen. /// Roll Value /// 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 /// </summary> /// <param name="character"></param> /// <returns></returns> public bool CharacterCriticalMiss(CharacterModel character) { // roll dice to determine event var d10 = DiceHelper.RollDice(1, 10); // Primary Hand Item breaks if (d10 == 1) { character.RemoveItem(ItemLocationEnum.PrimaryHand); BattleMessages.CriticalMissMessage = "Critical miss! Item in primary hand broke!"; return(true); } // Character Drops the Primary Hand Item back into the item pool if (d10 >= 2 && d10 <= 4) { var item = character.RemoveItem(ItemLocationEnum.PrimaryHand); if (item != null) { BattleMessages.CriticalMissMessage = "Critical miss! " + character.Name + " dropped " + item.Name + " in item pool!"; ItemPool.Add(item); return(true); } } // Character drops a random equipped item back into the item pool if (d10 >= 5 && d10 <= 6) { // check where character has items equipped var equipped = new List <ItemLocationEnum>(); var item = character.GetItemByLocation(ItemLocationEnum.Head); if (item != null) { equipped.Add(ItemLocationEnum.Head); } item = character.GetItemByLocation(ItemLocationEnum.Necklass); if (item != null) { equipped.Add(ItemLocationEnum.Necklass); } item = character.GetItemByLocation(ItemLocationEnum.Feet); if (item != null) { equipped.Add(ItemLocationEnum.Feet); } item = character.GetItemByLocation(ItemLocationEnum.PrimaryHand); if (item != null) { equipped.Add(ItemLocationEnum.PrimaryHand); } item = character.GetItemByLocation(ItemLocationEnum.OffHand); if (item != null) { equipped.Add(ItemLocationEnum.OffHand); } item = character.GetItemByLocation(ItemLocationEnum.RightFinger); if (item != null) { equipped.Add(ItemLocationEnum.RightFinger); } item = character.GetItemByLocation(ItemLocationEnum.LeftFinger); if (item != null) { equipped.Add(ItemLocationEnum.LeftFinger); } // no items equipped if (equipped.Count() <= 0) { return(true); } var unequip = DiceHelper.RollDice(1, equipped.Count()) - 1; // check that dice roll was valid (in case forced rolls are being used) if (unequip < 0 || unequip >= equipped.Count()) { return(false); // did not remove an item } item = character.RemoveItem(equipped.ElementAt(unequip)); ItemPool.Add(item); BattleMessages.CriticalMissMessage = "Critical miss! " + character.Name + " dropped " + item.Name + " in item pool!"; } return(true); }
public async Task AutoBattleEngine_RunAutoBattle_InValid_Round_Loop_Should_Fail() { /* * Test infinate rounds. * * Characters overpower monsters, game never ends * * 6 Character * Speed high * Hit Hard * High health * * 1 Monsters * Slow * Weak Hit * Weak health * * Should never end * * Inifinite Loop Check should stop the game * */ //Arrange // Add Characters AutoBattle.Battle.EngineSettings.MaxNumberPartyCharacters = 6; var CharacterPlayer = new PlayerInfoModel( new CharacterModel { Speed = 100, Level = 5, MaxHealth = 200, CurrentHealth = 200, ExperienceTotal = 1, }); var CharacterPlayerMin = new PlayerInfoModel( new CharacterModel { Speed = 99, Level = 1, MaxHealth = 200, CurrentHealth = 200, ExperienceTotal = 1, }); AutoBattle.Battle.EngineSettings.CharacterList.Add(CharacterPlayer); AutoBattle.Battle.EngineSettings.CharacterList.Add(CharacterPlayer); AutoBattle.Battle.EngineSettings.CharacterList.Add(CharacterPlayer); AutoBattle.Battle.EngineSettings.CharacterList.Add(CharacterPlayer); AutoBattle.Battle.EngineSettings.CharacterList.Add(CharacterPlayer); AutoBattle.Battle.EngineSettings.CharacterList.Add(CharacterPlayerMin); // Add Monsters AutoBattle.Battle.EngineSettings.MaxNumberPartyMonsters = 1; // Controll Rolls, Hit is always a 3 DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(3); //Act var result = await AutoBattle.RunAutoBattle(); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(false, result); Assert.AreEqual(true, AutoBattle.Battle.EngineSettings.BattleScore.RoundCount > AutoBattle.Battle.EngineSettings.MaxRoundCount); }
public void HackathonScenario_Scenario_14_If_Confusion_Turn_Character_Should_Skip() { /* * Scenario Number: * 14 * * Description: * Confusion, have % chance to occuring each round. * If happens, then confusion occurs for each monster and character for that round * Each party member rolls a chance of being confused. * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * Change to Turn Engine, Take Turn method, added switch check and dice roll * Changed BaseEngine, added boolean switch for enabling confusion, and is confusion turn or not. * Check for Experience gained is 0 * * Test Algrorithm: * Create Character named Bob * Create Monster * Call TakeTurn * * Test Conditions: * Test with Character of Named ConfusionCharacter * * Validation: * Verify Experience gained is 0 * */ //Arrange DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(0); // Set Character Conditions BattleEngine.MaxNumberPartyCharacters = 1; var TestSword = ItemViewModel.Dataset.Where(a => a.Location == ItemLocationEnum.PrimaryHand).FirstOrDefault(); var CharacterPlayer = new EntityInfoModel( new CharacterModel { Level = 10, CurrentHealth = 200, MaxHealth = 200, //TestDamage = 123, Experience = 100, Name = "Confused Character", }); CharacterPlayer.Attack = 25; CharacterPlayer.Speed = 20; CharacterPlayer.Defense = 25; CharacterPlayer.AddItem(ItemLocationEnum.PrimaryHand, TestSword.Id); BattleEngine.CharacterList.Add(CharacterPlayer); // Set Monster Conditions // Add a monster to attack BattleEngine.MaxNumberPartyCharacters = 1; var MonsterPlayer = new EntityInfoModel( new MonsterModel { Speed = 10, Level = 10, CurrentHealth = 100, Experience = 100, Name = "Monster", }); BattleEngine.CharacterList.Add(MonsterPlayer); // Have dice roll to 20 DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(20); // EnableConfusionRounds BattleEngine.EnableConfusionRound = true; BattleEngine.NewRound(); //Act var result = BattleEngine.TakeTurn(CharacterPlayer); //Reset DiceHelper.DisableForcedRolls(); BattleEngine.EnableConfusionRound = false; //Assert Assert.AreEqual(true, result); Assert.AreEqual(AutoBattleEngine.BattleScore.ExperienceGainedTotal, 0); }
/// <summary> /// Constructor /// </summary> public BattlePage() { InitializeComponent(); // Set initial State to Starting EngineViewModel.Engine.BattleStateEnum = BattleStateEnum.Starting; // Set up the UI to Defaults BindingContext = EngineViewModel; if (EngineViewModel.Engine.BattleScore.RoundCount < 1) { // Start the Battle Engine EngineViewModel.Engine.StartBattle(false); } else { EngineViewModel.Engine.EndRound(); // Populate New Monsters... EngineViewModel.Engine.AddMonstersToRound(); EngineViewModel.Engine.populatePotionsList(); var ListOrder = 0; foreach (var data in EngineViewModel.Engine.MonsterList) { if (data.Alive) { EngineViewModel.Engine.PlayerList.Add( new PlayerInfoModel(data) { // Remember the order ListOrder = ListOrder }); ListOrder++; } } // Set Order for the Round EngineViewModel.Engine.OrderPlayerListByTurnOrder(); for (int i = 0; i < EngineViewModel.Engine.PlayerList.Count; i++) { if (EngineViewModel.Engine.PlayerList[i].PlayerType == PlayerTypeEnum.Character && EngineViewModel.Engine.PlayerList[i].Name == "Mike") { Debug.WriteLine("Mike Has Died"); EngineViewModel.Engine.PlayerList[i].Alive = false; } } // Update Score for the RoundCount EngineViewModel.Engine.BattleScore.RoundCount++; //Roll for Hack 48 condition EngineViewModel.Engine.deathRollHack48 = DiceHelper.RollDice(1, 20); } // Ask the Game engine to select who goes first EngineViewModel.Engine.CurrentAttacker = null; // Add Players to Display DrawGameAttackerDefenderBoard(); BattlePlayerBoxVersus.Text = "Click a monster to attack it next!"; BattlePlayerBox.IsVisible = true; // Set the Battle Mode ShowBattleMode(); }
public void HackathonScenario_Scenario_7_If_Sleep_Monster_Should_Sleep() { /* * Scenario Number: * 7 * * Description: * The n Character can sleep monsters at (n-1)*2 + 1 Round * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * Change to Turn Engine, Take Turn method, added switch check * Changed BaseEngine, added boolean switch for enabling Sleep, Added Awake to check if Monster is asleep * * Test Algrorithm: * Create Character * Call TakeTurn * * Test Conditions: * Test with Character Sleep Character * * Validation: * Verify Awake is false * */ //Arrange DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(0); // Set Character Conditions BattleEngine.MaxNumberPartyCharacters = 1; var TestSword = ItemViewModel.Dataset.Where(a => a.Location == ItemLocationEnum.PrimaryHand).FirstOrDefault(); var CharacterPlayer = new EntityInfoModel( new CharacterModel { Level = 10, CurrentHealth = 200, MaxHealth = 200, //TestDamage = 123, Experience = 100, Name = "Sleep Character", }); BattleEngine.CharacterList.Add(CharacterPlayer); // Set Monster Conditions // Add a monster to attack BattleEngine.MaxNumberPartyCharacters = 1; var MonsterPlayer = new EntityInfoModel( new MonsterModel { Speed = 1, Level = 10, CurrentHealth = 100, Experience = 100, Name = "Monster", }); BattleEngine.MonsterList.Add(MonsterPlayer); BattleEngine.SLEEPINGTEST = true; // Have dice roll to 20 DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(20); // EnableConfusionRounds BattleEngine.EnableConfusionRound = false; //BattleEngine.NewRound(); //Act var sleep = BattleEngine.TakeTurn(CharacterPlayer); //var result = BattleEngine.TakeTurn(MonsterPlayer); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(true, sleep); //Assert.IsTrue(BattleEngine.EnableConfusionRound); Assert.IsFalse(BattleEngine.Awake); }
/// <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 override int AddMonstersToRound() { // Teams, You need to implement your own Logic can not use mine. /* * Ideas for adding monsters to round: * 1. check what levels are in character list, maybe take it as an average of the levels. * 2. add in the monsters similar to base by adding in random monster, except we * add them based on specific monster type. then adjust the values based on average level of monster. * 3. if any character is on level 18+, they will need to fight the Graduation Office Administrator * which will hold Graduation cap and robe. */ int TargetLevel = 1; bool ContainHighLevelCharacter = false; int MaxParty = EngineSettings.MaxNumberPartyMonsters; // get the average level of characters if (EngineSettings.CharacterList.Count() > 0) { // Get the average TargetLevel = Convert.ToInt32(EngineSettings.CharacterList.Average(m => m.Level)); // if character list contains level higher than 17 if (EngineSettings.CharacterList.Find(m => (m.Level > 17)) != null) { ContainHighLevelCharacter = true; // Add graduate monster MaxParty--; } } // load the monsters list for (var i = 0; i < MaxParty; i++) { var data = RandomPlayerHelper.GetRandomMonsterEscapingSchool(TargetLevel); // Help identify which Monster it is data.Name += " " + EngineSettings.MonsterList.Count() + 1; EngineSettings.MonsterList.Add(new PlayerInfoModel(data)); } // if the character contains level higher than 17+ then we add a big boss monster // if player beats this monster the student will graduate! if (ContainHighLevelCharacter) { MonsterModel BigBoss = ViewModels.MonsterIndexViewModel.Instance.GetDefaultMonster(SpecificMonsterTypeEnum.GraduationOfficeAdministrator); if (BigBoss == null) { var Item = ViewModels.ItemIndexViewModel.Instance.GetDefaultItemTypeItem(ItemTypeEnum.GraduationCapAndRobe); BigBoss = new MonsterModel { PlayerType = PlayerTypeEnum.Monster, MonsterTypeEnum = MonsterTypeEnum.Administrator, SpecificMonsterTypeEnum = SpecificMonsterTypeEnum.GraduationOfficeAdministrator, Name = "Mr. Smith", Description = "You have graduated!!!", Attack = 8, Difficulty = DifficultyEnum.Difficult, UniqueDropItem = Item.Id, ImageURI = Constants.SpecificMonsterTypeGraduationOfficeAdministratorImageURI }; } EngineSettings.MonsterList.Add(new PlayerInfoModel(BigBoss)); // Add MaxNumberPartyMonster back. MaxParty++; } if (EngineSettingsModel.Instance.HackathonDebug == true) { var d2 = DiceHelper.RollDice(1, 100); // 50/50 chance of it occuring with boss battle var percentage = EngineSettingsModel.Instance.BossBattleLikelihood; if (d2 >= percentage) { // clear the monster list EngineSettings.MonsterList.Clear(); // add in the new badass monster MonsterModel BigBoss = new MonsterModel { PlayerType = PlayerTypeEnum.Monster, MonsterTypeEnum = MonsterTypeEnum.Faculty, SpecificMonsterTypeEnum = SpecificMonsterTypeEnum.Professor, Name = "Mike Koenig", Description = "You will never graduate!!!", Attack = 10, Range = 5, Level = 20, Difficulty = DifficultyEnum.Difficult, ImageURI = Constants.SpecificMonsterTypeProfessorImageURI, }; EngineSettings.MonsterList.Add(new PlayerInfoModel(BigBoss)); } } return(EngineSettings.MonsterList.Count()); }
public void HackathonScenario_Scenario_2_Character_Not_Bob_Should_Hit() { /* * Scenario Number: * 2 * * Description: * See Default Test * * Changes Required (Classes, Methods etc.) List Files, Methods, and Describe Changes: * See Defualt Test * * Test Algrorithm: * Create Character named Mike * Create Monster * Call TurnAsAttack so Mike can attack Monster * * Test Conditions: * Control Dice roll so natural hit * Test with Character of not named Bob * * Validation * Verify Enum is Hit * */ //Arrange // Set Character Conditions BattleEngine.MaxNumberPartyCharacters = 1; var CharacterPlayer = new PlayerInfoModel( new CharacterModel { Speed = 200, Level = 10, CurrentHealth = 100, ExperienceTotal = 100, ExperienceRemaining = 1, Name = "Mike", }); BattleEngine.CharacterList.Add(CharacterPlayer); // Set Monster Conditions // Add a monster to attack BattleEngine.MaxNumberPartyCharacters = 1; var MonsterPlayer = new PlayerInfoModel( new MonsterModel { Speed = 1, Level = 1, CurrentHealth = 1, ExperienceTotal = 1, ExperienceRemaining = 1, Name = "Monster", }); BattleEngine.CharacterList.Add(MonsterPlayer); // Have dice roll 20 DiceHelper.EnableForcedRolls(); DiceHelper.SetForcedRollValue(20); //Act var result = BattleEngine.TurnAsAttack(CharacterPlayer, MonsterPlayer); //Reset DiceHelper.DisableForcedRolls(); //Assert Assert.AreEqual(true, result); Assert.AreEqual(HitStatusEnum.Hit, BattleEngine.BattleMessagesModel.HitStatus); }