コード例 #1
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_DetermineCriticalMissProblem_Attacker_Null_Roll_1_Should_Return_Nothing_Broke()
        {
            MockForms.Init();

            // Turn off random numbers
            // Set random to 1, and to hit to 1
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 1);
            GameGlobals.SetForcedRandomNumbersValue(1);

            var myTurnEngine = new TurnEngine();

            var myCharacter = new Character(DefaultModels.CharacterDefault());

            myCharacter.PrimaryHand = null; // Nothing in the hand, so nothing to drop...

            var Actual = myTurnEngine.DetermineCriticalMissProblem(myCharacter);

            // Should roll for 1 item, and return it...
            var Expected = " Luckly, nothing to drop from PrimaryHand";

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
コード例 #2
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_TurnAsAttack_Monster_Attack_DefenderList_Miss_Should_Pass()
        {
            MockForms.Init();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);

            var Attacker = DefaultModels.MonsterDefault();

            Attacker.Name = "Rat";

            var myDefaultCharacter = new Character(DefaultModels.CharacterDefault());

            myDefaultCharacter.Name = "Fighter";
            myDefaultCharacter.ScaleLevel(20);

            var myTurnEngine = new TurnEngine();

            myTurnEngine.CharacterList.Add(myDefaultCharacter);

            GameGlobals.ForceToHitValue = 2; // Force a miss

            var AttackScore  = Attacker.Level + Attacker.GetAttack();
            var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level;

            var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore);

            var  Actual   = Status;
            bool Expected = true;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
コード例 #3
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_GetRandomMonsterItemDrops_1_Roll_Level_3_Good_ItemList_Should_Return_List()
        {
            MockForms.Init();

            // Turn off random numbers
            // Set random to 1, and to hit to 1
            GameGlobals.SetForcedRandomNumbersValueAndToHit(2, 1);

            var myTurnEngine = new TurnEngine();

            var roundCount = 2;

            // Make Sure Items List exists and is loaded...
            ItemsViewModel.Instance.ForceDataRefresh();

            // Don't init itemlist so exit with empty list...
            var Actual = myTurnEngine.GetRandomMonsterItemDrops(roundCount);

            // Should roll for 1 item, and return it...
            var Expected = 2;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual.Count(), "Item Count " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(roundCount, Actual.FirstOrDefault().Value, "Item Level " + TestContext.CurrentContext.Test.Name);
        }
コード例 #4
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_GetRandomMonsterItemDrops_1_Roll_Level_3_Empty_ItemList_Should_Skip()
        {
            MockForms.Init();

            // Turn off random numbers
            // Set random to 1, and to hit to 1
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 1);

            var myTurnEngine = new TurnEngine();

            // Make Sure Items List exists and is loaded...
            ItemsViewModel.Instance.ForceDataRefresh();

            // Clear the items
            MockDataStore.Instance.DeleteTables();

            var roundCount = 3;

            // Don't init itemlist so exit with empty list...
            var Actual = myTurnEngine.GetRandomMonsterItemDrops(roundCount);

            // Should roll for 1 item, and return it...
            var Expected = 1;

            // Reset
            GameGlobals.ToggleRandomState();

            // Restor the database
            MockDataStore.Instance.InitializeDatabaseNewTables();

            Assert.AreEqual(Expected, Actual.Count(), "Item Count " + TestContext.CurrentContext.Test.Name);
        }
コード例 #5
0
        public void RoundEngine_RoundNextTurn_2Characters_1Monster_Weak_Should_Take_2_Turns()
        {
            MockForms.Init();

            bool reincarnation = GameGlobals.EnableReincarnation;

            GameGlobals.EnableReincarnation = false;

            // Can create a new Round engine...
            var myRoundEngine = new RoundEngine();

            // Start
            myRoundEngine.StartRound();

            // Add moderate monsters
            // First monster
            myRoundEngine.MonsterList.Clear();  // start fresh, because it was loaded already with 6...

            var myMonsterWeak = new Monster(DefaultModels.MonsterDefault());

            myMonsterWeak.ScaleLevel(5);
            myMonsterWeak.Attribute.CurrentHealth = 7; // need to set to enough to last 2 rounds...

            myRoundEngine.MonsterList.Add(myMonsterWeak);

            // Add weak character for first...
            var myCharacterWeak = new Character(DefaultModels.CharacterDefault());

            myCharacterWeak.ScaleLevel(10);
            myRoundEngine.CharacterList.Add(myCharacterWeak);

            // Add strong character for second
            var myCharacterStrong = new Character(DefaultModels.CharacterDefault());

            myCharacterStrong.ScaleLevel(20);
            myRoundEngine.CharacterList.Add(myCharacterStrong);

            // Should be Character 20, Character 10, Monster 5

            // Force rolls to 18 for to hit...
            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 18);

            // Character, should kill the monster in the first round.
            // So the check for the second round will say Round over...
            var FirstRound  = myRoundEngine.RoundNextTurn();    // Character 20 Goes
            var SecondRound = myRoundEngine.RoundNextTurn();    // Character 10 Goes
            var Actual      = myRoundEngine.RoundNextTurn();    // Over...


            // Reset
            GameGlobals.ToggleRandomState();

            var Expected = RoundEnum.NextTurn;

            Assert.AreEqual(Expected, Actual, "Status " + TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(3, myRoundEngine.BattleScore.TurnCount, "TurnCount " + TestContext.CurrentContext.Test.Name);
            //Assert.AreEqual(4, myRoundEngine.BattleScore.RoundCount, "RoundCount " + TestContext.CurrentContext.Test.Name);
            GameGlobals.EnableReincarnation = reincarnation;
        }
コード例 #6
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_TurnAsAttack_Monster_Attack_Defender_Die_With_Item_Should_Drop()
        {
            MockForms.Init();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);

            var Attacker = DefaultModels.MonsterDefault();

            Attacker.Name = "Rat";
            Attacker.ScaleLevel(20);

            var myDefaultCharacter = new Character(DefaultModels.CharacterDefault());

            myDefaultCharacter.Name = "Fighter";
            myDefaultCharacter.ScaleLevel(1);

            // Add Uniqueitem
            var myItem = new Item
            {
                Attribute = AttributeEnum.Attack,
                Location  = ItemLocationEnum.Feet,
                Value     = 1
            };

            ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult();  // Register Item to DataSet
            myDefaultCharacter.PrimaryHand = myItem.Guid;

            var myTurnEngine = new TurnEngine();

            myTurnEngine.CharacterList.Add(myDefaultCharacter);

            // Get Score, and remember item.
            var BeforeItemDropList = myTurnEngine.BattleScore.ItemsDroppedList;

            GameGlobals.ForceToHitValue = 20; // Force a hit

            // Should Kill because level 20 hit on level 1 Character for Critical is more damage than health...
            var AttackScore  = Attacker.Level + Attacker.GetAttack();
            var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level;

            var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore);


            // Item should drop...

            // Reset
            GameGlobals.ToggleRandomState();

            // Need to get Score
            // See if Item is now in the score list...
            var AfterItemDropList = myTurnEngine.BattleScore.ItemsDroppedList;

            Assert.AreNotEqual(BeforeItemDropList, AfterItemDropList, TestContext.CurrentContext.Test.Name);
        }
コード例 #7
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_TakeTurn_Attack_Valid_Defender_Valid_Defender_Should_Die()
        {
            MockForms.Init();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);

            var Attacker = DefaultModels.CharacterDefault();

            Attacker.Name = "Fighter";
            Attacker.ScaleLevel(20);

            var myDefaultMonster = new Monster(DefaultModels.MonsterDefault());

            myDefaultMonster.Name = "Rat";
            myDefaultMonster.ScaleLevel(1);

            // Add Uniqueitem
            var myItem = new Item
            {
                Attribute = AttributeEnum.Attack,
                Location  = ItemLocationEnum.Feet,
                Value     = 1
            };

            ItemsViewModel.Instance.AddAsync(myItem).GetAwaiter().GetResult();  // Register Item to DataSet
            myDefaultMonster.UniqueItem = myItem.Guid;

            var myTurnEngine = new TurnEngine();

            myTurnEngine.MonsterList.Add(myDefaultMonster);

            // Get Score, and remember item.
            var BeforeItemDropList = myTurnEngine.BattleScore.ItemsDroppedList;

            GameGlobals.ForceToHitValue = 20; // Force a hit

            var BeforeMonsterList = myTurnEngine.MonsterList.Count();

            // Instead of calling TurnAsAttack, call TakeTurn...
            var Status = myTurnEngine.TakeTurn(Attacker);

            var AfterMonsterList = myTurnEngine.MonsterList.Count();

            // Item should drop...
            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(BeforeMonsterList - 1, AfterMonsterList, TestContext.CurrentContext.Test.Name);
        }
コード例 #8
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_TurnAsAttack_Monster_Attack_Null_Should_Skip()
        {
            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);

            var myDefaultMonster = new Character();

            var myTurnEngine = new TurnEngine();

            var  Status   = myTurnEngine.TurnAsAttack((Monster)null, 1, myDefaultMonster, 1);
            var  Actual   = Status;
            bool Expected = false;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
コード例 #9
0
        public void RoundEngine_RoundNextTurn_Characters_MonstersDead_Should_Return_NewRound()
        {
            MockForms.Init();

            // No characters, so return should be game over...

            // Can create a new Round engine...
            var myRoundEngine = new RoundEngine();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);

            // Start
            myRoundEngine.StartRound();
            // Clear the monster list

            // Add weak monsters
            var myMonsterWeak = new Monster(DefaultModels.MonsterDefault());

            myMonsterWeak.ScaleLevel(1);

            myRoundEngine.MonsterList.Clear();  // start fresh, because it was loaded already with 6...
            myRoundEngine.MonsterList.Add(myMonsterWeak);

            // Add strong character
            var myCharacterStrong = new Character(DefaultModels.CharacterDefault());

            myCharacterStrong.ScaleLevel(20);
            myRoundEngine.CharacterList.Add(myCharacterStrong);

            // Character, should kill the monster in the first round.
            // So the check for the second round will say Round over...
            var FirstRound = myRoundEngine.RoundNextTurn();
            var Actual     = myRoundEngine.RoundNextTurn();

            var Expected = RoundEnum.NewRound;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(RoundEnum.NextTurn, FirstRound, TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
コード例 #10
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_RollToHitTarget_Attacker_Lower_Than_Defender_Roll_20_Should_CriticalHit()
        {
            MockForms.Init();

            // Turn off random numbers
            // Set random to 1, and to hit to 1
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);

            var myTurnEngine = new TurnEngine();

            var Attacker = 1;
            var Defender = 10;

            var Actual   = myTurnEngine.RollToHitTarget(Attacker, Defender);
            var Expected = HitStatusEnum.CriticalHit;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
コード例 #11
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_DetermineCriticalMissProblem_Attacker_Null_Should_Return_Invalid()
        {
            MockForms.Init();

            // Turn off random numbers
            // Set random to 1, and to hit to 1
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 1);
            GameGlobals.SetForcedRandomNumbersValue(1);

            var myTurnEngine = new TurnEngine();

            var Actual = myTurnEngine.DetermineCriticalMissProblem(null);

            // Should roll for 1 item, and return it...
            var Expected = " Invalid Character ";

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
コード例 #12
0
        public void Model_Item_ScaleLevel_With_NoRandom_Values_Should_Pass()
        {
            MockForms.Init();

            // Turn off random numbers
            // Set random to 1, and to hit to 1
            GameGlobals.SetForcedRandomNumbersValueAndToHit(3, 1);

            var myItem = new Item();

            myItem.ScaleLevel(2);

            var Actual = myItem.Value;

            // Should roll for 1 item, and return it...
            var Expected = 2;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
        }
コード例 #13
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_TurnAsAttack_Monster_Attack_Defender_CriticalHit_PowerfullHit_Should_Kill()
        {
            MockForms.Init();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);

            var Attacker = DefaultModels.MonsterDefault();

            Attacker.Name = "Rat";
            Attacker.ScaleLevel(20);

            var myDefaultCharacter = new Character(DefaultModels.CharacterDefault());

            myDefaultCharacter.Name = "Fighter";
            myDefaultCharacter.ScaleLevel(1);

            var myTurnEngine = new TurnEngine();

            myTurnEngine.CharacterList.Add(myDefaultCharacter);

            GameGlobals.ForceToHitValue = 20; // Force a hit

            // Should Kill because level 20 hit on level 1 Character for Critical is more damage than health...

            var AttackScore  = Attacker.Level + Attacker.GetAttack();
            var DefenseScore = myDefaultCharacter.GetDefense() + myDefaultCharacter.Level;

            var Status = myTurnEngine.TurnAsAttack(Attacker, AttackScore, myDefaultCharacter, DefenseScore);

            var  Actual   = Status;
            bool Expected = true;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
            Assert.AreEqual(false, myDefaultCharacter.Alive, TestContext.CurrentContext.Test.Name);
        }
コード例 #14
0
        public void RoundEngine_RoundNextTurn_Characters_MonstersDead_Should_Return_NewRound()
        {
            MockForms.Init();

            var myRoundEngine = new RoundEngine();

            // Turn off random numbers
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 20);
            bool reincarnation = GameGlobals.EnableReincarnation;

            GameGlobals.EnableReincarnation = false;

            // Start
            myRoundEngine.StartRound();
            // Clear the monster list

            // Add weak monsters
            var myMonsterWeak = new Monster(DefaultModels.MonsterDefault());

            myMonsterWeak.ScaleLevel(1);

            myRoundEngine.MonsterList.Clear();  // start fresh, because it was loaded already with 6...
            myRoundEngine.MonsterList.Add(myMonsterWeak);

            // Add strong character
            var myCharacterStrong = new Character(DefaultModels.CharacterDefault());

            myCharacterStrong.ScaleLevel(20);
            myRoundEngine.CharacterList.Add(myCharacterStrong);

            var Expected = RoundEnum.NextTurn;
            var Actual   = myRoundEngine.RoundStateEnum;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual, TestContext.CurrentContext.Test.Name);
            GameGlobals.EnableReincarnation = reincarnation;
        }
コード例 #15
0
ファイル: TurnEngineUnitTests.cs プロジェクト: loleeta/TRP
        public void TurnEngine_GetRandomMonsterItemDrops_1_Roll_Should_Return_List()
        {
            MockForms.Init();

            // Turn off random numbers
            // Set random to 1, and to hit to 1
            GameGlobals.SetForcedRandomNumbersValueAndToHit(1, 1);
            GameGlobals.SetForcedRandomNumbersValue(1);

            var myTurnEngine = new TurnEngine();

            var roundCount = 1;

            var Actual = myTurnEngine.GetRandomMonsterItemDrops(roundCount);

            // Should roll for 1 item, and return it...
            var Expected = 1;

            // Reset
            GameGlobals.ToggleRandomState();

            Assert.AreEqual(Expected, Actual.Count(), TestContext.CurrentContext.Test.Name);
        }