コード例 #1
0
        public void ResolveNullAttack_Throws()
        {
            var          mckRand = new MockBd2Randomiser();
            MockBd2Map   mp      = new MockBd2Map();
            bd2World     wld     = new bd2World(mp);
            var          sut     = new CombatManager(wld, mckRand);
            CombatAttack ca      = new CombatAttack();

            Assert.Throws <BdBaseException>(() => {
                var res = sut.ResolveAttack(null);
            });
        }
コード例 #2
0
        public void TileOutOfRange(int x, int y)
        {
            b.Info.Flow();

            var mp = new MockBd2Map();

            mp.Test_SetDimensions(10, 100);


            var excpt = Assert.Throws <BdBaseException>(() => {
                mp.GetTileAtPosition(new Point(x, y));
            });

            Assert.Contains("range", excpt.Message);
        }
コード例 #3
0
        public void EveryTile_RetursnDefault()
        {
            b.Info.Flow();

            var mp = new MockBd2Map();

            mp.Test_SetDimensions(100, 100);

            for (int x = 1; x <= 100; x++)
            {
                for (int y = 1; y <= 100; y++)
                {
                    var mt = mp.GetTileAtPosition(new Point(x, y));
                    Assert.Equal <MapTile>(MapTile.DefaultGround, mt);
                }
            }
        }
コード例 #4
0
        public void Resolve_NullVictim_Throws()
        {
            var        mckRand = new MockBd2Randomiser();
            MockBd2Map mp      = new MockBd2Map();
            bd2World   wld     = new bd2World(mp);
            var        sut     = new CombatManager(wld, mckRand);
            MappedBot  mb      = new MappedBot(new MockBotFactory().CreateBasicMockBot().ToBot());

            CombatAttack ca = new CombatAttack();

            ca.Attacker = mb;
            ca.Victim   = null;
            var excpt = Assert.Throws <BdBaseException>(() => {
                var res = sut.ResolveAttack(ca);
            });

            Assert.Contains("victim", excpt.Message);
        }
コード例 #5
0
        public void FullResolve_DoesHit()
        {
            b.Info.Flow();

            var mckRand = new MockBd2Randomiser();

            mckRand.Mock_SetD100Result(0);
            mckRand.Mock_SetD10Result(100);
            mckRand.Mock_SetCanTargetHit(true);

            MockBd2Map mp = new MockBd2Map();

            MockBd2World wld = new MockBd2World(mp);

            wld.Test_LOSCanHitReturn(true);
            var sut = new CombatManager(wld, mckRand);


            var mbf = new MockBotFactory();
            var atk = new MockMappedBot(mbf.CreateBasicMockBot().ToBot());

            atk.Test_Initialise();
            var vic = new MockMappedBot(mbf.CreateBasicMockBot().ToBot());

            vic.Test_Initialise();

            var          mw = new MockWeapon();
            CombatAttack ca = new CombatAttack();

            ca.Attacker                  = atk;
            ca.Victim                    = vic;
            ca.Weapon                    = mw;
            ca.WeaponInstance            = new ActiveEquipment(mw);
            ca.WeaponInstance.MountPoint = MountPoint.Turret;
            var res = sut.ResolveAttack(ca);

            Assert.NotNull(res);
            Assert.True(res.DidHit);
        }
コード例 #6
0
 public MockBd2World(MockBd2Map mp) : base(mp)
 {
 }