コード例 #1
0
        public void Callback_WhenNoStrongholdsAreInactive_ShouldNotThrowExceptionAndShouldUpdateNeutralCheckTime(
            [Frozen] ISystemVariableManager systemVariableManager,
            [Frozen] IStrongholdManager strongholdManager,
            [Frozen] IDbManager dbManager,
            IStronghold sh1,
            IStronghold sh2,
            IFixture fixture)
        {
            sh1.StrongholdState.Returns(StrongholdState.Occupied);
            sh2.StrongholdState.Returns(StrongholdState.Occupied);

            var lastCheckTime = Substitute.For <SystemVariable>();

            lastCheckTime.Value.Returns(SystemClock.Now.AddHours(-8));
            systemVariableManager["Stronghold.neutral_check"].Returns(lastCheckTime);

            var locker = new LockerStub();

            fixture.Register <ILocker>(() => locker);

            strongholdManager.GetEnumerator().Returns(_ => new List <IStronghold> {
                sh1, sh2
            }.GetEnumerator());

            var checker = fixture.Create <StrongholdActivationChecker>();

            checker.Invoking(c => c.Callback(null)).ShouldNotThrow();

            lastCheckTime.Received().Value = SystemClock.Now;
            dbManager.Received(1).Save(lastCheckTime);
        }
コード例 #2
0
        public void Callback_WhenHasNeutralStronghold_ShouldNotActivateAStronghold(
            [Frozen] ISystemVariableManager systemVariableManager,
            [Frozen] IStrongholdActivationCondition activationCondition,
            [Frozen] IStrongholdManager strongholdManager,
            IStronghold sh1,
            IStronghold sh2,
            IFixture fixture)
        {
            sh1.StrongholdState.Returns(StrongholdState.Inactive);
            sh2.StrongholdState.Returns(StrongholdState.Neutral);

            var lastCheckTime = Substitute.For <SystemVariable>();

            lastCheckTime.Value.Returns(SystemClock.Now.AddHours(-8));
            systemVariableManager["Stronghold.neutral_check"].Returns(lastCheckTime);

            var locker = new LockerStub();

            fixture.Register <ILocker>(() => locker);

            strongholdManager.GetEnumerator().Returns(_ => new List <IStronghold> {
                sh1, sh2
            }.GetEnumerator());

            var checker = fixture.Create <StrongholdActivationChecker>();

            checker.Callback(null);

            strongholdManager.DidNotReceive().Activate(sh2);
            strongholdManager.DidNotReceive().Activate(sh1);
        }
コード例 #3
0
 public Formula(IObjectTypeFactory objectTypeFactory, UnitFactory unitFactory, IStructureCsvFactory structureFactory, ISystemVariableManager systemVariableManager)
 {
     SystemVariableManager = systemVariableManager;
     ObjectTypeFactory     = objectTypeFactory;
     UnitFactory           = unitFactory;
     StructureCsvFactory   = structureFactory;
 }
コード例 #4
0
        public SystemVariablesUpdater(IWorld world,
                                      ITribeManager tribeManager,
                                      IDbManager dbManager,
                                      IScheduler scheduler,
                                      IStrongholdManager strongholdManager,
                                      IForestManager forestManager,
                                      ISystemVariableManager systemVariableManager,
                                      INetworkServer networkServer,
                                      IChannel channel,
                                      BlockingBufferManager bufferManager,
                                      SocketAwaitablePool socketAwaitablePool)
        {
            this.world                 = world;
            this.tribeManager          = tribeManager;
            this.dbManager             = dbManager;
            this.scheduler             = scheduler;
            this.strongholdManager     = strongholdManager;
            this.forestManager         = forestManager;
            this.systemVariableManager = systemVariableManager;
            this.networkServer         = networkServer;
            this.channel               = channel;
            this.bufferManager         = bufferManager;
            this.socketAwaitablePool   = socketAwaitablePool;

            if (!string.IsNullOrEmpty(Config.api_id))
            {
                graphiteKeyPrefix = string.Format("servers.{0}_tribalhero_com.tribalhero.", Config.api_id);
            }
        }
コード例 #5
0
 public Property(string name, DataType type, PropertyOrigin origin, Visibility visibility, ISystemVariableManager systemVariableManager)
 {
     this.systemVariableManager = systemVariableManager;
     Name       = name;
     Type       = type;
     Origin     = origin;
     Visibility = visibility;
 }
コード例 #6
0
        public void StrongholdMainBattleMeter_WhenNegativeTime(ISystemVariableManager systemVariableManager)
        {
            systemVariableManager["Server.date"].Returns(new SystemVariable("Server.date", DateTime.MaxValue));

            var fixture = FixtureHelper.Create();

            fixture.Register(() => systemVariableManager);
            fixture.Customize <Formula>(c => c.FromFactory(new MethodInvoker(new GreedyConstructorQuery())));

            var formula = fixture.Create <Formula>();

            SystemClock.SetClock(DateTime.MaxValue.Subtract(new TimeSpan(30, 0, 0, 0)));
            formula.StrongholdMainBattleMeter(1).Should().Be(250);
        }
コード例 #7
0
        public void StrongholdMainBattleMeter_WhenLessThanOrEqualTo30Days999Hours(ISystemVariableManager systemVariableManager)
        {
            systemVariableManager["Server.date"].Returns(new SystemVariable("Server.date", DateTime.MinValue));

            var fixture = FixtureHelper.Create();

            fixture.Register(() => systemVariableManager);
            fixture.Customize <Formula>(c => c.FromFactory(new MethodInvoker(new GreedyConstructorQuery())));

            var formula = fixture.Create <Formula>();

            SystemClock.SetClock(DateTime.MinValue.Add(new TimeSpan(30, 999, 0, 0)));
            formula.StrongholdMainBattleMeter(1).Should().Be(1996);
        }
コード例 #8
0
        public void StrongholdGateLimit_WhenMoreThan30Days1000Hours(ISystemVariableManager systemVariableManager)
        {
            systemVariableManager["Server.date"].Returns(new SystemVariable("Server.date", DateTime.MinValue));

            var fixture = FixtureHelper.Create();

            fixture.Register(() => systemVariableManager);
            fixture.Customize <Formula>(c => c.FromFactory(new MethodInvoker(new GreedyConstructorQuery())));

            var formula = fixture.Create <Formula>();

            SystemClock.SetClock(DateTime.MinValue.Add(new TimeSpan(30, 2000, 0, 0)));
            formula.StrongholdGateLimit(1).Should().Be(20000);
        }
コード例 #9
0
 public StrongholdActivationChecker(IStrongholdManager strongholdManager,
                                    IStrongholdActivationCondition strongholdActivationCondition,
                                    IScheduler scheduler,
                                    ILocker locker,
                                    ITileLocator tileLocator,
                                    ISystemVariableManager systemVariableManager,
                                    IDbManager dbManager)
 {
     this.strongholdManager             = strongholdManager;
     this.strongholdActivationCondition = strongholdActivationCondition;
     this.scheduler             = scheduler;
     this.locker                = locker;
     this.tileLocator           = tileLocator;
     this.systemVariableManager = systemVariableManager;
     this.dbManager             = dbManager;
 }
コード例 #10
0
        public void Callback_WhenInactiveStrongholdsHaveSameScore_ShouldActivateClosestToCenter(
            [Frozen] ISystemVariableManager systemVariableManager,
            [Frozen] IStrongholdActivationCondition activationCondition,
            [Frozen] IStrongholdManager strongholdManager,
            [Frozen] ITileLocator tileLocator,
            IStronghold sh1,
            IStronghold sh2,
            IFixture fixture)
        {
            sh1.StrongholdState.Returns(StrongholdState.Inactive);
            sh1.PrimaryPosition.Returns(new Position(10, 20));

            sh2.StrongholdState.Returns(StrongholdState.Inactive);
            sh2.PrimaryPosition.Returns(new Position(30, 40));

            activationCondition.Score(null).ReturnsForAnyArgs(0);

            tileLocator.TileDistance(sh1.PrimaryPosition, 1, Arg.Any <Position>(), 1)
            .Returns(10);

            tileLocator.TileDistance(sh2.PrimaryPosition, 1, Arg.Any <Position>(), 1)
            .Returns(5);

            var lastCheckTime = Substitute.For <SystemVariable>();

            lastCheckTime.Value.Returns(SystemClock.Now.AddHours(-8));
            systemVariableManager["Stronghold.neutral_check"].Returns(lastCheckTime);

            var locker = new LockerStub();

            fixture.Register <ILocker>(() => locker);

            strongholdManager.GetEnumerator().Returns(_ => new List <IStronghold> {
                sh1, sh2
            }.GetEnumerator());

            var checker = fixture.Create <StrongholdActivationChecker>();

            checker.Callback(null);

            strongholdManager.Received().Activate(sh2);
            strongholdManager.DidNotReceive().Activate(sh1);
        }
コード例 #11
0
 public MapFactory(IDbManager dbManager, ISystemVariableManager systemVariableManager, ITileLocator tileLocator)
 {
     this.dbManager             = dbManager;
     this.systemVariableManager = systemVariableManager;
     this.tileLocator           = tileLocator;
 }
コード例 #12
0
 public PropertyFactory(ISystemVariableManager systemVariableManager)
 {
     this.systemVariableManager = systemVariableManager;
 }