Ejemplo n.º 1
0
        public void RangedInRangeTest()
        {
            var rangeActorConfig = new Mock <IBsActorConfig>();

            rangeActorConfig.Setup(x => x.AttackType()).Returns(ActorAttackType.Range);

            _actor1.Setup(x => x.Config()).Returns(rangeActorConfig.Object);
            var model = new BsRange(_board.Object, _config.Object);

            for (int i = 1; i <= 20; i = i << 1)
            {
                var res = new BsActionResult();
                _board.Setup(x => x.Distance(It.IsAny <IBsActor>(), It.IsAny <IBsActor>())).Returns(i);
                model.CheckAttackDst(_actor1.Object, _actor2.Object, res);
                Assert.IsTrue(res.Ok);
            }

            for (int i = 21; i < 100; i = i << 1)
            {
                var res = new BsActionResult();
                _board.Setup(x => x.Distance(It.IsAny <IBsActor>(), It.IsAny <IBsActor>())).Returns(i);
                model.CheckAttackDst(_actor1.Object, _actor2.Object, res);
                Assert.IsFalse(res.Ok);
            }
        }
Ejemplo n.º 2
0
        internal static string FormatValue(object valRange)
        {
            var range      = new BsRange <DateTime>();
            var type       = ReflectionHelpers.GetDeclaringType(range, x => x.From);
            var finalType  = type.GenericTypeArguments[0];
            var isNullable = finalType.InheritsOrImplements(typeof(Nullable <>));

            var valFormated = string.Empty;

            if (valRange != null)
            {
                //apply Datetime ISO format
                if (valRange.GetType() == typeof(Nullable <DateTime>))
                {
                    var date = (DateTime?)valRange;
                    valFormated = date.Value.ToString("O");
                }
                else if (valRange.GetType() == typeof(DateTime))
                {
                    var date = (DateTime)valRange;
                    valFormated = date.ToString("O");
                }
                else
                {
                    valFormated = valRange.ToString();
                }
            }
            return(valFormated);
        }
Ejemplo n.º 3
0
        public override void DidEnter(IState state)
        {
            // Setup the board
            var board = new BsBoard2D(10, 10);

            // Create actors and add them to the board
            var actors = new BsActorCollection();
            var red1   = actors.Add(_config.Fighter);
            var red2   = actors.Add(_config.Fighter);
            var red3   = actors.Add(_config.Fighter);
            var blue1  = actors.Add(_config.Archer);
            var blue2  = actors.Add(_config.Fighter);
            var blue3  = actors.Add(_config.Archer);

            board.Add(red1, 0);
            board.Add(red2, 5);
            board.Add(red3, 9);
            board.Add(blue1, 90);
            board.Add(blue2, 95);
            board.Add(blue3, 99);


            // Setup models
            var levels   = new BsLevels(actors);
            var stats    = new BsStatsModel(levels);
            var health   = new BsHealthModel(actors, stats);
            var range    = new BsRange(board, _config.DstConfig);
            var factions = new BsFactions(actors);

            // Add actors to factions
            factions.Add(red1, BsFaction.Red);
            factions.Add(red2, BsFaction.Red);
            factions.Add(red3, BsFaction.Red);
            factions.Add(blue1, BsFaction.Blue);
            factions.Add(blue2, BsFaction.Blue);
            factions.Add(blue3, BsFaction.Blue);

            // Setup levels
            levels.AddLevel(actors.Actor(1), 5);
            levels.AddLevel(actors.Actor(2), 10);
            levels.AddLevel(actors.Actor(3), 15);
            levels.AddLevel(actors.Actor(4), 20);

            // Facade model
            var model = new BsModel(actors);

            model.AddSubmodel(health);
            model.AddSubmodel(board);
            model.AddSubmodel(levels);
            model.AddSubmodel(range);
            model.AddSubmodel(factions);
            _model = model;

            // Presenter
            _presenter = new BsPresenter(_view, _hudView, _model, _input, _logger);
            _presenter.Init();

            _logger.Log("Battle Simulation Ready");
        }
Ejemplo n.º 4
0
        public void MeleeInRangeTest()
        {
            var model = new BsRange(_board.Object, _config.Object);

            for (int i = 0; i <= 2; i++)
            {
                var res = new BsActionResult();
                _board.Setup(x => x.Distance(It.IsAny <IBsActor>(), It.IsAny <IBsActor>())).Returns(i);
                model.CheckAttackDst(_actor1.Object, _actor2.Object, res);
                Assert.IsTrue(res.Ok);
            }

            for (int i = 3; i < 25; i = i << 1)
            {
                var res = new BsActionResult();
                _board.Setup(x => x.Distance(It.IsAny <IBsActor>(), It.IsAny <IBsActor>())).Returns(i);
                model.CheckAttackDst(_actor1.Object, _actor2.Object, res);
                Assert.IsFalse(res.Ok);
            }
        }
Ejemplo n.º 5
0
 public UserSearchModel()
 {
     AgeRange = new BsRange <int?>
     {
         From = new BsRangeItem <int?>
         {
             ItemValue = 1,
             MinValue  = 1,
             TextValue = "1"
         },
         To = new BsRangeItem <int?>
         {
             ItemValue = 2,
             MaxValue  = 120,
             TextValue = "2",
         },
         TextValue = Resource.Choose
     };
     CitizenshipDropdown = new BsSelectList <int?>();
 }