Esempio n. 1
0
        public void SenseOfUrgency_WhenCityHasMultipleSenseOfUrgencyTechnologies_ShouldStackUpTo100Percent(
            ICity city,
            IStructure structure,
            BattleProcedure battleProcedure)
        {
            structure.State = GameObjectStateFactory.NormalState();
            structure.Stats.Hp.Returns(50m);
            structure.Stats.Base.Battle.MaxHp.Returns(200m);

            city.GetEnumerator().Returns(x =>
                                         new List <IStructure> {
                structure
            }.GetEnumerator());
            city.Technologies.GetEffects(EffectCode.SenseOfUrgency).Returns(new List <Effect>
            {
                new Effect {
                    Id = EffectCode.SenseOfUrgency, Value = new object[] { 50 }
                },
                new Effect {
                    Id = EffectCode.SenseOfUrgency, Value = new object[] { 25 }
                },
                new Effect {
                    Id = EffectCode.SenseOfUrgency, Value = new object[] { 50 }
                }
            });

            battleProcedure.SenseOfUrgency(city, 50);

            structure.Stats.Hp.Should().Be(100m);
        }
Esempio n. 2
0
 public CityEngageDefensePassiveAction(BattleProcedure battleProcedure,
                                       CityBattleProcedure cityBattleProcedure,
                                       IGameObjectLocator gameObjectLocator)
 {
     this.battleProcedure     = battleProcedure;
     this.cityBattleProcedure = cityBattleProcedure;
     this.gameObjectLocator   = gameObjectLocator;
 }
Esempio n. 3
0
        public void SenseOfUrgency_WhenCityHasNoSenseOfUrgencyTechnologies_DoesntHealStructures(
            ICity city,
            BattleProcedure battleProcedure)
        {
            city.Technologies.GetEffects(EffectCode.SenseOfUrgency).Returns(new List <Effect>());

            battleProcedure.SenseOfUrgency(city, 1000);

            city.Received(0).GetEnumerator();
        }
Esempio n. 4
0
 public CityEngageDefensePassiveAction(uint cityId,
                                       uint troopObjectId,
                                       FormationType formationType,
                                       BattleProcedure battleProcedure,
                                       CityBattleProcedure cityBattleProcedure,
                                       IGameObjectLocator gameObjectLocator)
     : this(battleProcedure, cityBattleProcedure, gameObjectLocator)
 {
     this.cityId        = cityId;
     this.troopObjectId = troopObjectId;
     this.formationType = formationType;
 }
Esempio n. 5
0
 public BarbarianTribeAttackChainAction(IActionFactory actionFactory,
                                        Procedure procedure,
                                        ILocker locker,
                                        IGameObjectLocator gameObjectLocator,
                                        BattleProcedure battleProcedure)
 {
     this.actionFactory     = actionFactory;
     this.procedure         = procedure;
     this.locker            = locker;
     this.gameObjectLocator = gameObjectLocator;
     this.battleProcedure   = battleProcedure;
 }
Esempio n. 6
0
 public AssignmentCommandsModule(BattleProcedure battleProcedure,
                                 IGameObjectLocator gameObjectLocator,
                                 ILocker locker,
                                 IStrongholdManager strongholdManager,
                                 ICityManager cityManager)
 {
     this.battleProcedure   = battleProcedure;
     this.gameObjectLocator = gameObjectLocator;
     this.locker            = locker;
     this.strongholdManager = strongholdManager;
     this.cityManager       = cityManager;
 }
Esempio n. 7
0
 public CityDefenseChainAction(BattleProcedure battleProcedure,
                               IActionFactory actionFactory,
                               ILocker locker,
                               IWorld world,
                               Procedure procedure)
 {
     this.battleProcedure = battleProcedure;
     this.actionFactory   = actionFactory;
     this.locker          = locker;
     this.world           = world;
     this.procedure       = procedure;
 }
Esempio n. 8
0
 public StrongholdDefenseChainAction(IActionFactory actionFactory,
                                     Procedure procedure,
                                     ILocker locker,
                                     IGameObjectLocator gameObjectLocator,
                                     BattleProcedure battleProcedure,
                                     StrongholdBattleProcedure strongholdBattleProcedure)
 {
     this.actionFactory             = actionFactory;
     this.procedure                 = procedure;
     this.locker                    = locker;
     this.gameObjectLocator         = gameObjectLocator;
     this.battleProcedure           = battleProcedure;
     this.strongholdBattleProcedure = strongholdBattleProcedure;
 }
Esempio n. 9
0
 public BarbarianTribeAttackChainAction(uint cityId,
                                        uint targetObjectId,
                                        ITroopObjectInitializer troopObjectInitializer,
                                        IActionFactory actionFactory,
                                        Procedure procedure,
                                        ILocker locker,
                                        IGameObjectLocator gameObjectLocator,
                                        BattleProcedure battleProcedure)
     : this(actionFactory, procedure, locker, gameObjectLocator, battleProcedure)
 {
     this.troopObjectInitializer = troopObjectInitializer;
     this.cityId         = cityId;
     this.targetObjectId = targetObjectId;
 }
Esempio n. 10
0
 public CityDefenseChainAction(uint cityId,
                               ITroopObjectInitializer troopObjectInitializer,
                               uint targetCityId,
                               BattleProcedure battleProcedure,
                               IActionFactory actionFactory,
                               ILocker locker,
                               IWorld world,
                               Procedure procedure)
     : this(battleProcedure, actionFactory, locker, world, procedure)
 {
     this.cityId = cityId;
     this.troopObjectInitializer = troopObjectInitializer;
     this.targetCityId           = targetCityId;
 }
Esempio n. 11
0
 public StrongholdDefenseChainAction(uint cityId,
                                     ITroopObjectInitializer troopObjectInitializer,
                                     uint targetStrongholdId,
                                     IActionFactory actionFactory,
                                     Procedure procedure,
                                     ILocker locker,
                                     IGameObjectLocator gameObjectLocator,
                                     BattleProcedure battleProcedure,
                                     StrongholdBattleProcedure strongholdBattleProcedure)
     : this(actionFactory, procedure, locker, gameObjectLocator, battleProcedure, strongholdBattleProcedure)
 {
     this.cityId                 = cityId;
     this.targetStrongholdId     = targetStrongholdId;
     this.troopObjectInitializer = troopObjectInitializer;
 }
Esempio n. 12
0
        public CityBattlePassiveAction(uint cityId,
                                       IActionFactory actionFactory,
                                       BattleProcedure battleProcedure,
                                       ILocker locker,
                                       IGameObjectLocator gameObjectLocator,
                                       IDbManager dbManager,
                                       Formula formula,
                                       CityBattleProcedure cityBattleProcedure,
                                       IWorld world,
                                       ITroopObjectInitializerFactory troopInitializerFactory)
            : this(actionFactory, battleProcedure, locker, gameObjectLocator, dbManager, formula, cityBattleProcedure, world, troopInitializerFactory)
        {
            this.cityId = cityId;

            RegisterCityBattleEvents();
        }
Esempio n. 13
0
 public CityAttackChainAction(IActionFactory actionFactory,
                              Procedure procedure,
                              ILocker locker,
                              IGameObjectLocator gameObjectLocator,
                              CityBattleProcedure cityBattleProcedure,
                              BattleProcedure battleProcedure,
                              Formula formula)
 {
     this.actionFactory       = actionFactory;
     this.procedure           = procedure;
     this.locker              = locker;
     this.gameObjectLocator   = gameObjectLocator;
     this.cityBattleProcedure = cityBattleProcedure;
     this.battleProcedure     = battleProcedure;
     this.formula             = formula;
 }
Esempio n. 14
0
        public void SenseOfUrgency_WhenCityHasNoSenseOfUrgencyTechnologies_HealsHurtStructuresThatArentInBattle(
            ICity city,
            IStructure inBattleStructure,
            IStructure fullyHealedStructure,
            IStructure hurtStructure,
            BattleProcedure battleProcedure)
        {
            inBattleStructure.State = GameObjectStateFactory.BattleState(0);
            inBattleStructure.Stats.Hp.Returns(50m);
            inBattleStructure.Stats.Base.Battle.MaxHp.Returns(100m);

            fullyHealedStructure.State = GameObjectStateFactory.NormalState();
            fullyHealedStructure.Stats.Hp.Returns(75m);
            fullyHealedStructure.Stats.Base.Battle.MaxHp.Returns(75m);

            hurtStructure.State = GameObjectStateFactory.NormalState();
            hurtStructure.Stats.Hp.Returns(100m);
            hurtStructure.Stats.Base.Battle.MaxHp.Returns(200m);

            city.GetEnumerator().Returns(x =>
                                         new List <IStructure> {
                inBattleStructure, fullyHealedStructure, hurtStructure
            }.GetEnumerator());
            city.Technologies.GetEffects(EffectCode.SenseOfUrgency).Returns(new List <Effect>
            {
                new Effect {
                    Id = EffectCode.SenseOfUrgency, Value = new object[] { 50 }
                }
            });

            battleProcedure.SenseOfUrgency(city, 50);

            inBattleStructure.Stats.Hp.Should().Be(50m);
            hurtStructure.Stats.Hp.Should().Be(125m);
            fullyHealedStructure.Stats.Hp.Should().Be(75m);

            hurtStructure.Received(1).BeginUpdate();
            hurtStructure.Received(1).EndUpdate();

            fullyHealedStructure.Received(0).BeginUpdate();
            fullyHealedStructure.Received(0).EndUpdate();

            inBattleStructure.Received(0).BeginUpdate();
            inBattleStructure.Received(0).EndUpdate();
        }
Esempio n. 15
0
 public CityAttackChainAction(uint cityId,
                              ITroopObjectInitializer troopObjectInitializer,
                              uint targetCityId,
                              Position target,
                              IActionFactory actionFactory,
                              Procedure procedure,
                              ILocker locker,
                              IGameObjectLocator gameObjectLocator,
                              CityBattleProcedure cityBattleProcedure,
                              BattleProcedure battleProcedure,
                              Formula formula)
     : this(actionFactory, procedure, locker, gameObjectLocator, cityBattleProcedure, battleProcedure, formula)
 {
     this.tmpTarget = target;
     this.cityId    = cityId;
     this.troopObjectInitializer = troopObjectInitializer;
     this.targetCityId           = targetCityId;
 }
Esempio n. 16
0
 public CityBattlePassiveAction(IActionFactory actionFactory,
                                BattleProcedure battleProcedure,
                                ILocker locker,
                                IGameObjectLocator gameObjectLocator,
                                IDbManager dbManager,
                                Formula formula,
                                CityBattleProcedure cityBattleProcedure,
                                IWorld world,
                                ITroopObjectInitializerFactory troopInitializerFactory)
 {
     this.actionFactory       = actionFactory;
     this.battleProcedure     = battleProcedure;
     this.locker              = locker;
     this.gameObjectLocator   = gameObjectLocator;
     this.dbManager           = dbManager;
     this.formula             = formula;
     this.cityBattleProcedure = cityBattleProcedure;
     this.world = world;
     this.troopInitializerFactory = troopInitializerFactory;
 }
Esempio n. 17
0
 public StrongholdMainBattlePassiveAction(BattleProcedure battleProcedure,
                                          StrongholdBattleProcedure strongholdBattleProcedure,
                                          ILocker locker,
                                          IGameObjectLocator gameObjectLocator,
                                          IDbManager dbManager,
                                          Formula formula,
                                          IWorld world,
                                          IStrongholdManager strongholdManager,
                                          IActionFactory actionFactory,
                                          ITroopObjectInitializerFactory troopInitializerFactory)
 {
     this.battleProcedure           = battleProcedure;
     this.strongholdBattleProcedure = strongholdBattleProcedure;
     this.locker                  = locker;
     this.gameObjectLocator       = gameObjectLocator;
     this.dbManager               = dbManager;
     this.formula                 = formula;
     this.world                   = world;
     this.strongholdManager       = strongholdManager;
     this.actionFactory           = actionFactory;
     this.troopInitializerFactory = troopInitializerFactory;
 }
Esempio n. 18
0
        public StrongholdMainBattlePassiveAction(uint strongholdId,
                                                 BattleProcedure battleProcedure,
                                                 StrongholdBattleProcedure strongholdBattleProcedure,
                                                 ILocker locker,
                                                 IGameObjectLocator gameObjectLocator,
                                                 IDbManager dbManager,
                                                 Formula formula,
                                                 IWorld world,
                                                 IStrongholdManager strongholdManager,
                                                 IActionFactory actionFactory,
                                                 ITroopObjectInitializerFactory troopInitializerFactory)
            : this(battleProcedure, strongholdBattleProcedure, locker, gameObjectLocator, dbManager, formula, world, strongholdManager, actionFactory, troopInitializerFactory)
        {
            this.strongholdId = strongholdId;

            IStronghold stronghold;

            if (!gameObjectLocator.TryGetObjects(strongholdId, out stronghold))
            {
                throw new Exception("Did not find stronghold that was supposed to be having a battle");
            }

            RegisterBattleListeners(stronghold);
        }
Esempio n. 19
0
        public City(uint id,
                    IPlayer owner,
                    string name,
                    Position position,
                    ILazyResource resource,
                    byte radius,
                    decimal ap,
                    string defaultTheme,
                    string roadTheme,
                    string troopTheme,
                    string wallTheme,
                    IActionWorker worker,
                    CityNotificationManager notifications,
                    IReferenceManager references,
                    ITechnologyManager technologies,
                    ITroopManager troops,
                    IUnitTemplate template,
                    ITroopStubFactory troopStubFactory,
                    IDbManager dbManager,
                    IGameObjectFactory gameObjectFactory,
                    IActionFactory actionFactory,
                    BattleProcedure battleProcedure)
        {
            Id                     = id;
            Owner                  = owner;
            this.name              = name;
            this.radius            = radius;
            this.troopStubFactory  = troopStubFactory;
            this.dbManager         = dbManager;
            this.gameObjectFactory = gameObjectFactory;
            this.actionFactory     = actionFactory;
            this.battleProcedure   = battleProcedure;

            PrimaryPosition = position;
            AlignmentPoint  = ap;
            DefaultTheme    = defaultTheme;
            RoadTheme       = roadTheme;
            WallTheme       = wallTheme;
            TroopTheme      = troopTheme;
            Resource        = resource;

            Worker        = worker;
            Notifications = notifications;
            References    = references;
            Technologies  = technologies;
            Troops        = troops;
            Template      = template;

            #region Event Proxies

            Template.UnitUpdated += evtTemplate =>
            {
                if (Global.Current.FireEvents && DbPersisted)
                {
                    dbManager.Save(evtTemplate);
                }

                UnitTemplateUpdated(this, new EventArgs());
            };

            Troops.TroopAdded += stub => TroopAdded(this, new TroopStubEventArgs {
                Stub = stub
            });
            Troops.TroopRemoved += stub => TroopRemoved(this, new TroopStubEventArgs {
                Stub = stub
            });
            Troops.TroopUpdated += stub => TroopUpdated(this, new TroopStubEventArgs {
                Stub = stub
            });
            Troops.TroopUnitUpdated += stub => TroopUnitUpdated(this, new TroopStubEventArgs {
                Stub = stub
            });

            Worker.ActionRemoved += (stub, state) => ActionRemoved(this, new ActionWorkerEventArgs {
                State = state, Stub = stub
            });
            Worker.ActionStarted += (stub, state) => ActionStarted(this, new ActionWorkerEventArgs {
                State = state, Stub = stub
            });
            Worker.ActionRescheduled += (stub, state) => ActionRescheduled(this, new ActionWorkerEventArgs {
                State = state, Stub = stub
            });

            Resource.ResourcesUpdate += () =>
            {
                CheckUpdateMode();
                ResourcesUpdated(this, new EventArgs());
            };

            Technologies.TechnologyCleared  += OnTechnologyCleared;
            Technologies.TechnologyAdded    += OnTechnologyAdded;
            Technologies.TechnologyRemoved  += OnTechnologyRemoved;
            Technologies.TechnologyUpgraded += OnTechnologyUpgraded;

            References.ReferenceAdded   += (sender, args) => ReferenceAdded(this, args);
            References.ReferenceRemoved += (sender, args) => ReferenceRemoved(this, args);

            #endregion
        }