Example #1
0
        public virtual decimal CalculateTotalCityExpense(ICity city, IStructureCsvFactory structureFactory, TechnologyFactory technologyFactory, UnitFactory unitFactory)
        {
            decimal expenses = 0m;

            Func <Resource, decimal> calculateCost = resource => resource.Crop + resource.Wood + resource.Gold * 2 + resource.Iron * 5 + resource.Labor * 100;

            foreach (var structure in city)
            {
                for (var lvl = 0; lvl <= structure.Lvl; lvl++)
                {
                    expenses += calculateCost(structureFactory.GetCost(structure.Type, lvl));
                }

                foreach (var technology in structure.Technologies)
                {
                    for (var lvl = 0; lvl <= technology.Level; lvl++)
                    {
                        expenses += calculateCost(technologyFactory.GetTechnology(technology.Type, (byte)lvl).TechBase.Resources);
                    }
                }
            }

            foreach (var unit in city.Template)
            {
                for (var lvl = 1; lvl <= unit.Value.Lvl; lvl++)
                {
                    expenses += calculateCost(unitFactory.GetUpgradeCost(unit.Value.Type, lvl));
                }
            }

            return(expenses);
        }
Example #2
0
 public Formula(IObjectTypeFactory objectTypeFactory, UnitFactory unitFactory, IStructureCsvFactory structureFactory, ISystemVariableManager systemVariableManager)
 {
     SystemVariableManager = systemVariableManager;
     ObjectTypeFactory     = objectTypeFactory;
     UnitFactory           = unitFactory;
     StructureCsvFactory   = structureFactory;
 }
Example #3
0
        public GameObjectFactory(IKernel kernel, IStructureCsvFactory structureCsvFactory, ITechnologyManagerFactory technologyManagerFactory)
        {
            this.kernel = kernel;
            this.structureCsvFactory      = structureCsvFactory;
            this.technologyManagerFactory = technologyManagerFactory;

            dbManager = kernel.Get <IDbManager>();
        }
Example #4
0
 public StructureDowngradePassiveAction(ILocker locker,
                                        IStructureCsvFactory structureCsvFactory,
                                        Procedure procedure,
                                        CallbackProcedure callbackProcedure)
 {
     this.callbackProcedure   = callbackProcedure;
     this.locker              = locker;
     this.structureCsvFactory = structureCsvFactory;
     this.procedure           = procedure;
 }
Example #5
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 #6
0
 public StructureDowngradePassiveAction(uint cityId,
                                        uint structureId,
                                        ILocker locker,
                                        IStructureCsvFactory structureCsvFactory,
                                        Procedure procedure,
                                        CallbackProcedure callbackProcedure)
     : this(locker, structureCsvFactory, procedure, callbackProcedure)
 {
     this.cityId      = cityId;
     this.structureId = structureId;
 }
Example #7
0
 public StructureDowngradeActiveAction(IObjectTypeFactory objectTypeFactory,
                                       IStructureCsvFactory structureCsvFactory,
                                       IWorld world,
                                       ILocker locker,
                                       Formula formula)
 {
     this.objectTypeFactory   = objectTypeFactory;
     this.structureCsvFactory = structureCsvFactory;
     this.world   = world;
     this.locker  = locker;
     this.formula = formula;
 }
Example #8
0
 public StrongholdCombatGate(uint id,
                             uint battleId,
                             ushort type,
                             byte lvl,
                             decimal hp,
                             IStronghold stronghold,
                             IStructureCsvFactory structureCsvFactory,
                             IBattleFormulas battleFormulas,
                             IDbManager dbManager)
     : base(id, battleId, type, lvl, hp, stronghold, structureCsvFactory, battleFormulas, dbManager)
 {
 }
Example #9
0
 public PlayerCommandsModule(ILocker locker,
                             IWorld world,
                             IDbManager dbManager,
                             IActionFactory actionFactory,
                             IStructureCsvFactory structureCsvFactory)
 {
     this.locker              = locker;
     this.world               = world;
     this.dbManager           = dbManager;
     this.actionFactory       = actionFactory;
     this.structureCsvFactory = structureCsvFactory;
 }
Example #10
0
 public StructureDowngradeActiveAction(uint cityId,
                                       uint structureId,
                                       IObjectTypeFactory objectTypeFactory,
                                       IStructureCsvFactory structureCsvFactory,
                                       IWorld world,
                                       ILocker locker,
                                       Formula formula)
     : this(objectTypeFactory, structureCsvFactory, world, locker, formula)
 {
     this.cityId      = cityId;
     this.structureId = structureId;
 }
Example #11
0
 public BattleViewer(IBattleManager battle, UnitFactory unitFactory, IStructureCsvFactory structureCsvFactory)
 {
     battle.EnterBattle      += BattleEnterBattle;
     battle.ExitBattle       += BattleExitBattle;
     battle.ExitTurn         += BattleExitTurn;
     battle.UnitKilled       += BattleUnitKilled;
     battle.ActionAttacked   += BattleActionAttacked;
     battle.SkippedAttacker  += BattleSkippedAttacker;
     battle.EnterRound       += BattleEnterRound;
     battleManager            = battle;
     this.unitFactory         = unitFactory;
     this.structureCsvFactory = structureCsvFactory;
 }
Example #12
0
 public StructureChangeActiveAction(IStructureCsvFactory structureCsvFactory,
                                    Formula formula,
                                    IWorld world,
                                    Procedure procedure,
                                    ILocker locker,
                                    CallbackProcedure callbackProcedure)
 {
     this.structureCsvFactory = structureCsvFactory;
     this.formula             = formula;
     this.world             = world;
     this.procedure         = procedure;
     this.locker            = locker;
     this.callbackProcedure = callbackProcedure;
 }
Example #13
0
 public CityPassiveAction(uint cityId,
                          IObjectTypeFactory objectTypeFactory,
                          ILocker locker,
                          Formula formula,
                          IActionFactory actionFactory,
                          Procedure procedure,
                          IGameObjectLocator locator,
                          IBattleFormulas battleFormulas,
                          IStructureCsvFactory structureFactory,
                          TechnologyFactory technologyFactory,
                          UnitFactory unitFactory)
     : this(objectTypeFactory, locker, formula, actionFactory, procedure, locator, battleFormulas, structureFactory, technologyFactory, unitFactory)
 {
     this.cityId = cityId;
 }
Example #14
0
 public StructureUpgradeActiveAction(uint cityId,
                                     uint structureId,
                                     IStructureCsvFactory structureCsvFactory,
                                     Formula formula,
                                     IWorld world,
                                     Procedure procedure,
                                     ILocker locker,
                                     IRequirementCsvFactory requirementCsvFactory,
                                     IObjectTypeFactory objectTypeFactory,
                                     CallbackProcedure callbackProcedure)
     : this(structureCsvFactory, formula, world, procedure, locker, requirementCsvFactory, objectTypeFactory, callbackProcedure)
 {
     this.cityId      = cityId;
     this.structureId = structureId;
 }
Example #15
0
 public CityEngageAttackPassiveAction(uint cityId,
                                      uint troopObjectId,
                                      uint targetCityId,
                                      IBattleFormulas battleFormula,
                                      IGameObjectLocator gameObjectLocator,
                                      CityBattleProcedure cityBattleProcedure,
                                      IStructureCsvFactory structureCsvFactory,
                                      IDbManager dbManager,
                                      IStaminaMonitorFactory staminaMonitorFactory)
     : this(battleFormula, gameObjectLocator, cityBattleProcedure, structureCsvFactory, dbManager, staminaMonitorFactory)
 {
     this.cityId        = cityId;
     this.troopObjectId = troopObjectId;
     this.targetCityId  = targetCityId;
 }
Example #16
0
 public TribesmanCommandsModule(IActionFactory actionFactory,
                                IStructureCsvFactory structureCsvFactory,
                                ILocker locker,
                                IWorld world,
                                IDbManager dbManager,
                                IStrongholdManager strongholdManager,
                                ITribeManager tribeManager)
 {
     this.actionFactory       = actionFactory;
     this.structureCsvFactory = structureCsvFactory;
     this.locker            = locker;
     this.world             = world;
     this.dbManager         = dbManager;
     this.strongholdManager = strongholdManager;
     this.tribeManager      = tribeManager;
 }
Example #17
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;
 }
Example #18
0
        public CityEngageAttackPassiveAction(IBattleFormulas battleFormula,
                                             IGameObjectLocator gameObjectLocator,
                                             CityBattleProcedure cityBattleProcedure,
                                             IStructureCsvFactory structureCsvFactory,
                                             IDbManager dbManager,
                                             IStaminaMonitorFactory staminaMonitorFactory)
        {
            this.battleFormula         = battleFormula;
            this.gameObjectLocator     = gameObjectLocator;
            this.cityBattleProcedure   = cityBattleProcedure;
            this.structureCsvFactory   = structureCsvFactory;
            this.dbManager             = dbManager;
            this.staminaMonitorFactory = staminaMonitorFactory;

            bonus = new Resource();
        }
Example #19
0
 public StructureChangeActiveAction(uint cityId,
                                    uint structureId,
                                    uint type,
                                    byte lvl,
                                    IStructureCsvFactory structureCsvFactory,
                                    Formula formula,
                                    IWorld world,
                                    Procedure procedure,
                                    ILocker locker,
                                    CallbackProcedure callbackProcedure)
     : this(structureCsvFactory, formula, world, procedure, locker, callbackProcedure)
 {
     this.cityId      = cityId;
     this.structureId = structureId;
     this.type        = type;
     this.lvl         = lvl;
 }
Example #20
0
 public StructureUpgradeActiveAction(IStructureCsvFactory structureCsvFactory,
                                     Formula formula,
                                     IWorld world,
                                     Procedure procedure,
                                     ILocker locker,
                                     IRequirementCsvFactory requirementCsvFactory,
                                     IObjectTypeFactory objectTypeFactory,
                                     CallbackProcedure callbackProcedure)
 {
     this.structureCsvFactory = structureCsvFactory;
     this.formula             = formula;
     this.world                 = world;
     this.procedure             = procedure;
     this.locker                = locker;
     this.requirementCsvFactory = requirementCsvFactory;
     this.objectTypeFactory     = objectTypeFactory;
     this.callbackProcedure     = callbackProcedure;
 }
Example #21
0
 public StructureCommandsModule(IActionFactory actionFactory,
                                IStructureCsvFactory structureCsvFactory,
                                IObjectTypeFactory objectTypeFactory,
                                PropertyFactory propertyFactory,
                                IForestManager forestManager,
                                IThemeManager themeManager,
                                IWorld world,
                                ILocker locker)
 {
     this.actionFactory       = actionFactory;
     this.structureCsvFactory = structureCsvFactory;
     this.objectTypeFactory   = objectTypeFactory;
     this.propertyFactory     = propertyFactory;
     this.forestManager       = forestManager;
     this.themeManager        = themeManager;
     this.world  = world;
     this.locker = locker;
 }
Example #22
0
 public ForestCampBuildActiveAction(Formula formula,
                                    IWorld world,
                                    IObjectTypeFactory objectTypeFactory,
                                    IStructureCsvFactory structureCsvFactory,
                                    IForestManager forestManager,
                                    ILocker locker,
                                    ITileLocator tileLocator,
                                    CallbackProcedure callbackProcedure)
 {
     this.formula             = formula;
     this.world               = world;
     this.objectTypeFactory   = objectTypeFactory;
     this.structureCsvFactory = structureCsvFactory;
     this.forestManager       = forestManager;
     this.locker              = locker;
     this.tileLocator         = tileLocator;
     this.callbackProcedure   = callbackProcedure;
 }
Example #23
0
 public StructureChangePassiveAction(uint cityId,
                                     uint objectId,
                                     int seconds,
                                     ushort newType,
                                     byte newLvl,
                                     Formula formula,
                                     IWorld world,
                                     ILocker locker,
                                     Procedure procedure,
                                     CallbackProcedure callbackProcedure,
                                     IStructureCsvFactory structureCsvFactory) :
     this(formula, world, locker, procedure, callbackProcedure, structureCsvFactory)
 {
     this.cityId   = cityId;
     this.objectId = objectId;
     ts            = TimeSpan.FromSeconds(seconds);
     type          = newType;
     lvl           = newLvl;
 }
Example #24
0
        protected StrongholdCombatStructure(uint id,
                                            uint battleId,
                                            ushort type,
                                            byte lvl,
                                            decimal hp,
                                            IStronghold stronghold,
                                            IStructureCsvFactory structureCsvFactory,
                                            IBattleFormulas battleFormulas,
                                            IDbManager dbManager)
            : base(id, battleId, battleFormulas, dbManager)
        {
            Stronghold = stronghold;
            this.type  = type;
            this.lvl   = lvl;
            this.hp    = hp;

            structureBaseStats = structureCsvFactory.GetBaseStats(type, lvl);
            stats = new BattleStats(structureBaseStats.Battle);
        }
Example #25
0
 public ForestCampBuildActiveAction(uint cityId,
                                    uint lumbermillId,
                                    uint forestId,
                                    ushort campType,
                                    ushort labors,
                                    Formula formula,
                                    IWorld world,
                                    IObjectTypeFactory objectTypeFactory,
                                    IStructureCsvFactory structureCsvFactory,
                                    IForestManager forestManager,
                                    ILocker locker,
                                    ITileLocator tileLocator,
                                    CallbackProcedure callbackProcedure)
     : this(formula, world, objectTypeFactory, structureCsvFactory, forestManager, locker, tileLocator, callbackProcedure)
 {
     this.cityId       = cityId;
     this.lumbermillId = lumbermillId;
     this.forestId     = forestId;
     this.labors       = labors;
     this.campType     = campType;
 }
Example #26
0
 public CityCreatePassiveAction(uint cityId,
                                uint x,
                                uint y,
                                string cityName,
                                IActionFactory actionFactory,
                                ICityRemoverFactory cityRemoverFactory,
                                Formula formula,
                                IWorld world,
                                ILocker locker,
                                IObjectTypeFactory objectTypeFactory,
                                IStructureCsvFactory structureCsvFactory,
                                ICityFactory cityFactory,
                                Procedure procedure,
                                IBarbarianTribeManager barbarianTribeManager,
                                CallbackProcedure callbackProcedure)
     : this(actionFactory, cityRemoverFactory, formula, world, locker, objectTypeFactory, structureCsvFactory, cityFactory, procedure, barbarianTribeManager, callbackProcedure)
 {
     this.cityId   = cityId;
     this.x        = x;
     this.y        = y;
     this.cityName = cityName;
 }
Example #27
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 #28
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;
 }
Example #29
0
 public PlayerCommandLineModule(IPlayersRemoverFactory playerRemoverFactory,
                                IPlayerSelectorFactory playerSelectorFactory,
                                ICityRemoverFactory cityRemoverFactory,
                                Chat chat,
                                IDbManager dbManager,
                                ITribeManager tribeManager,
                                IWorld world,
                                ILocker locker,
                                IStructureCsvFactory structureFactory,
                                UnitFactory unitFactory,
                                TechnologyFactory technologyFactory)
 {
     this.playerRemoverFactory  = playerRemoverFactory;
     this.playerSelectorFactory = playerSelectorFactory;
     this.cityRemoverFactory    = cityRemoverFactory;
     this.chat              = chat;
     this.dbManager         = dbManager;
     this.tribeManager      = tribeManager;
     this.world             = world;
     this.locker            = locker;
     this.structureFactory  = structureFactory;
     this.unitFactory       = unitFactory;
     this.technologyFactory = technologyFactory;
 }
Example #30
0
 public FactoriesInitializer(ActionRequirementFactory actionRequirementFactory,
                             IStructureCsvFactory structureCsvFactory,
                             EffectRequirementFactory effectRequirementFactory,
                             InitFactory initFactory,
                             PropertyFactory propertyFactory,
                             IRequirementCsvFactory requirementCsvFactory,
                             TechnologyFactory technologyFactory,
                             UnitFactory unitFactory,
                             IObjectTypeFactory objectTypeFactory,
                             UnitModFactory unitModFactory,
                             MapFactory mapFactory)
 {
     this.actionRequirementFactory = actionRequirementFactory;
     this.structureCsvFactory      = structureCsvFactory;
     this.effectRequirementFactory = effectRequirementFactory;
     this.initFactory           = initFactory;
     this.propertyFactory       = propertyFactory;
     this.requirementCsvFactory = requirementCsvFactory;
     this.technologyFactory     = technologyFactory;
     this.unitFactory           = unitFactory;
     this.objectTypeFactory     = objectTypeFactory;
     this.unitModFactory        = unitModFactory;
     this.mapFactory            = mapFactory;
 }