Example #1
0
        public StructureBuildActiveActionExecuteBuilder(IFixture fixture)
        {
            this.fixture = fixture;

            requirementCsvFactory = fixture.Freeze <IRequirementCsvFactory>();
            requirementCsvFactory
            .GetLayoutRequirement(Arg.Any <ushort>(), Arg.Any <byte>())
            .Validate(Arg.Any <IStructure>(), Arg.Any <ushort>(), Arg.Any <uint>(), Arg.Any <uint>(), Arg.Any <byte>())
            .Returns(true);

            structureBaseStats = fixture.Freeze <IStructureBaseStats>();
            structureBaseStats.Size.Returns <byte>(0);
            var structureCost = new Resource(1234, 8446, 1343, 1234, 1246);

            structureBaseStats.Cost.Returns(structureCost);

            var structure = fixture.Freeze <IStructure>();

            structure.Stats.Base.Returns(structureBaseStats);

            objectTypeFactory = fixture.Freeze <IObjectTypeFactory>();
            objectTypeFactory.IsObjectType("NoRoadRequired", Arg.Any <ushort>()).Returns(true);

            city = fixture.Create <ICity>();
            city.PrimaryPosition.Returns(new Position(99, 98));
            city.Radius.Returns <byte>(5);
            city.Resource.HasEnough(structureBaseStats.Cost).Returns(true);
            city.CreateStructure(Arg.Any <ushort>(), Arg.Any <byte>(), Arg.Any <uint>(), Arg.Any <uint>()).Returns(structure);

            roadPathFinder = fixture.Freeze <IRoadPathFinder>();
            roadPathFinder.CanBuild(Arg.Any <Position>(), Arg.Any <byte>(), city, Arg.Any <bool>()).Returns(Error.Ok);

            tileLocator = fixture.Freeze <ITileLocator>();
            tileLocator.TileDistance(new Position(99, 98), 1, Arg.Any <Position>(), 1).Returns(1);

            world = fixture.Freeze <IWorld>();
            ICity outCity;

            world.TryGetObjects(Arg.Any <uint>(), out outCity).Returns(x =>
            {
                x[1] = city;
                return(true);
            });
            world.Regions.GetObjectsInTile(Arg.Any <uint>(), Arg.Any <uint>()).Returns(new List <ISimpleGameObject>());
            world.Regions.IsValidXandY(0, 0).ReturnsForAnyArgs(true);
            world.Regions.Add(structure).Returns(true);

            structureCsvFactory = fixture.Freeze <IStructureCsvFactory>();
            structureCsvFactory.GetBaseStats(0, 0).ReturnsForAnyArgs(structureBaseStats);

            formula = Substitute.For <Formula>();
            formula.CityMaxConcurrentBuildActions(0, 0, null, null).ReturnsForAnyArgs(Error.Ok);
            formula.StructureCost(null, null).ReturnsForAnyArgs(structureCost);
            fixture.Register(() => formula);
        }
Example #2
0
 public RegionCommandsModule(ITileLocator tileLocator,
                             IWorld world,
                             IObjectTypeFactory objectTypeFactory,
                             IRoadPathFinder roadPathFinder,
                             ILocker locker,
                             Util.IChannel channel)
 {
     this.tileLocator       = tileLocator;
     this.world             = world;
     this.objectTypeFactory = objectTypeFactory;
     this.roadPathFinder    = roadPathFinder;
     this.locker            = locker;
     this.channel           = channel;
 }
Example #3
0
 public StructureBuildActiveAction(IObjectTypeFactory objectTypeFactory,
                                   IWorld world,
                                   Formula formula,
                                   IRequirementCsvFactory requirementCsvFactory,
                                   IStructureCsvFactory structureCsvFactory,
                                   ILocker concurrency,
                                   Procedure procedure,
                                   IRoadPathFinder roadPathFinder,
                                   ITileLocator tileLocator,
                                   CallbackProcedure callbackProcedure)
 {
     this.objectTypeFactory     = objectTypeFactory;
     this.world                 = world;
     this.formula               = formula;
     this.requirementCsvFactory = requirementCsvFactory;
     this.structureCsvFactory   = structureCsvFactory;
     this.concurrency           = concurrency;
     this.procedure             = procedure;
     this.roadPathFinder        = roadPathFinder;
     this.tileLocator           = tileLocator;
     this.callbackProcedure     = callbackProcedure;
 }
Example #4
0
 public StructureBuildActiveAction(uint cityId,
                                   ushort type,
                                   uint x,
                                   uint y,
                                   byte level,
                                   IObjectTypeFactory objectTypeFactory,
                                   IWorld world,
                                   Formula formula,
                                   IRequirementCsvFactory requirementCsvFactory,
                                   IStructureCsvFactory structureCsvFactory,
                                   ILocker concurrency,
                                   Procedure procedure,
                                   IRoadPathFinder roadPathFinder,
                                   ITileLocator tileLocator,
                                   CallbackProcedure callbackProcedure)
     : this(objectTypeFactory, world, formula, requirementCsvFactory, structureCsvFactory, concurrency, procedure, roadPathFinder, tileLocator, callbackProcedure)
 {
     this.cityId = cityId;
     this.type   = type;
     this.X      = x;
     this.Y      = y;
     this.level  = level;
 }