public PlayerEventProcessorResolver(IGame game, ILogger <PlayerEventProcessorResolver> logger)
        {
            var attackValidationRules = new List <IPlayerActionValidationRule>
            {
                new SelfAttackValidationRule(),
                new AllyAttackValidationRule(),
                new DeadTargetValidationRule(),
                new CombatRangeValidationRule()
            };

            var attackTransformationRule = new AttackLevelTransformationRule();

            var healingValidationRules = new List <IPlayerActionValidationRule>
            {
                new DeadTargetValidationRule(),
                new EnemyHealingValidationRule()
            };

            _processors =
                new Dictionary <Type, Func <IPlayerEventProcessor> >
            {
                [typeof(AttackEvent)]       = () => new AttackEventProcessor(attackValidationRules, attackTransformationRule, logger, game),
                [typeof(HealingEvent)]      = () => new HealingEventProcessor(healingValidationRules, null, logger, game),
                [typeof(JoinEvent)]         = () => new JoinEventProcessor(game, logger),
                [typeof(JoinFactionEvent)]  = () => new JoinFactionEventProcessor(game, logger),
                [typeof(LeaveFactionEvent)] = () => new LeaveFactionEventProcessor(game, logger)
            };
        }
        public void DamageShouldIncreaseIfDefenderSucks()
        {
            var rule              = new AttackLevelTransformationRule();
            var actor             = new PlayerState(1, 10, 1000, CombatType.Melee, new List <int>(), new Coordinates(0, 0));
            var target            = new PlayerState(2, 5, 1000, CombatType.Melee, new List <int>(), new Coordinates(2, 2));
            var transformedDamage = rule.Transform(5, actor, target);

            Assert.Equal(7.5, transformedDamage);
        }
Beispiel #3
0
        private static AttackEventProcessor CreateProcessor(IMock <IGame> game)
        {
            var attackValidationRules = new List <IPlayerActionValidationRule>
            {
                new SelfAttackValidationRule(),
                new DeadTargetValidationRule(),
                new CombatRangeValidationRule()
            };

            var attackTransformationRule = new AttackLevelTransformationRule();

            return(new AttackEventProcessor(attackValidationRules, attackTransformationRule, new MockLogger(), game.Object));
        }