Esempio n. 1
0
        public void RetreatUnits_RetreatsStationedUnitsThatAreNotInTribeThatOwnsStronghold(
            IStronghold stronghold, 
            [FrozenMock] IActionFactory actionFactory,
            [FrozenMock] ITroopObjectInitializerFactory troopInitializerFactory,
            ITroopObjectInitializer troopInitializer,
            ITroopStub stub,
            ITribe tribe,
            ITribe shTribe,
            RetreatChainAction retreatAction,
            StrongholdManager strongholdManager)
        {
            stub.State.Returns(TroopState.Stationed);
            stub.City.Owner.IsInTribe.Returns(true);
            stub.City.Id.Returns<uint>(1234);
            stub.TroopId.Returns<ushort>(2);
            stub.City.Owner.Tribesman.Tribe.Returns(tribe);

            stronghold.MainBattle.Returns((IBattleManager)null);
            stronghold.Tribe.Returns(shTribe);
            stronghold.Troops.StationedHere().Returns(new[] { stub });

            troopInitializerFactory.CreateStationedTroopObjectInitializer(stub).Returns(troopInitializer);
            actionFactory.CreateRetreatChainAction(stub.City.Id, troopInitializer).Returns(retreatAction);

            strongholdManager.RetreatUnits(stronghold);
            
            stub.City.Worker.Received(1).DoPassive(stub.City, retreatAction, true);
        }
Esempio n. 2
0
        public StrongholdManager(IStrongholdConfigurator strongholdConfigurator,
                                 IStrongholdFactory strongholdFactory,
                                 IRegionManager regionManager,
                                 Chat chat,
                                 IDbManager dbManager,
                                 ISimpleStubGeneratorFactory simpleStubGeneratorFactory,
                                 Formula formula,
                                 ICityManager cityManager,
                                 IActionFactory actionFactory,
                                 ITileLocator tileLocator,
                                 ITroopObjectInitializerFactory troopInitializerFactory)
        {
            idGenerator = new LargeIdGenerator(Config.stronghold_id_max, Config.stronghold_id_min);
            strongholds = new ConcurrentDictionary <uint, IStronghold>();

            this.strongholdConfigurator = strongholdConfigurator;
            this.strongholdFactory      = strongholdFactory;
            this.regionManager          = regionManager;
            this.chat                    = chat;
            this.dbManager               = dbManager;
            this.formula                 = formula;
            this.actionFactory           = actionFactory;
            this.tileLocator             = tileLocator;
            this.troopInitializerFactory = troopInitializerFactory;

            cityManager.CityAdded += CityManagerCityAdded;
            simpleStubGenerator    = simpleStubGeneratorFactory.CreateSimpleStubGenerator(formula.StrongholdUnitRatio(), formula.StrongholdUnitType());
        }
Esempio n. 3
0
 public TribeManager(IDbManager dbManager,
                     IStrongholdManager strongholdManager,
                     IActionFactory actionFactory,
                     ITribeFactory tribeFactory,
                     ITribeLogger tribeLogger, ITroopObjectInitializerFactory troopInitializerFactory)
 {
     Tribes                       = new ConcurrentDictionary <uint, ITribe>();
     this.dbManager               = dbManager;
     this.strongholdManager       = strongholdManager;
     this.actionFactory           = actionFactory;
     this.tribeFactory            = tribeFactory;
     this.tribeLogger             = tribeLogger;
     this.troopInitializerFactory = troopInitializerFactory;
 }
Esempio n. 4
0
 public TroopCommandsModule(IActionFactory actionFactory,
                            IStructureCsvFactory structureCsvFactory,
                            IGameObjectLocator gameObjectLocator,
                            Formula formula,
                            ILocker locker,
                            ITroopObjectInitializerFactory troopObjectInitializerFactory,
                            IThemeManager themeManager)
 {
     this.actionFactory       = actionFactory;
     this.structureCsvFactory = structureCsvFactory;
     this.gameObjectLocator   = gameObjectLocator;
     this.formula             = formula;
     this.locker = locker;
     this.troopObjectInitializerFactory = troopObjectInitializerFactory;
     this.themeManager = themeManager;
 }
Esempio n. 5
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. 6
0
        /// <summary>
        ///     Creates a new assignment.
        ///     NOTE: This constructor is used by the db loader. Use the other constructor when creating a new assignment from scratch.
        /// </summary>
        public Assignment(int id,
                          ITribe tribe,
                          uint x,
                          uint y,
                          ILocation target,
                          AttackMode mode,
                          DateTime targetTime,
                          uint dispatchCount,
                          string description,
                          bool isAttack,
                          Formula formula,
                          IDbManager dbManager,
                          IGameObjectLocator gameObjectLocator,
                          IScheduler scheduler,
                          Procedure procedure,
                          ITileLocator tileLocator,
                          IActionFactory actionFactory,
                          ILocker locker,
                          ITroopObjectInitializerFactory troopObjectInitializerFactory)
        {
            this.formula                       = formula;
            this.dbManager                     = dbManager;
            this.gameObjectLocator             = gameObjectLocator;
            this.scheduler                     = scheduler;
            this.procedure                     = procedure;
            this.tileLocator                   = tileLocator;
            this.actionFactory                 = actionFactory;
            this.locker                        = locker;
            this.troopObjectInitializerFactory = troopObjectInitializerFactory;

            Id            = id;
            Tribe         = tribe;
            TargetTime    = targetTime;
            Target        = target;
            X             = x;
            Y             = y;
            AttackMode    = mode;
            DispatchCount = dispatchCount;
            Description   = description;
            IsAttack      = isAttack;

            IdGen.Set((uint)id);
        }
Esempio n. 7
0
        public CityRemover(uint cityId,
                           IActionFactory actionFactory,
                           ITileLocator tileLocator,
                           IWorld world,
                           IScheduler scheduler,
                           ILocker locker,
                           IDbManager dbManager,
                           ITroopObjectInitializerFactory troopObjectInitializerFactory)
        {
            this.cityId        = cityId;
            this.actionFactory = actionFactory;

            this.world       = world;
            this.scheduler   = scheduler;
            this.locker      = locker;
            this.tileLocator = tileLocator;
            this.dbManager   = dbManager;
            this.troopObjectInitializerFactory = troopObjectInitializerFactory;
        }
Esempio n. 8
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. 9
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. 10
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);
        }