Beispiel #1
0
        public AttackCombatUnit(uint id,
                                uint battleId,
                                ITroopObject troopObject,
                                FormationType formation,
                                ushort type,
                                byte lvl,
                                ushort count,
                                UnitFactory unitFactory,
                                IBattleFormulas battleFormulas,
                                Formula formula,
                                ITileLocator tileLocator,
                                IDbManager dbManager)
            : base(id, battleId, battleFormulas, dbManager)
        {
            this.troopObject = troopObject;
            this.formation   = formation;
            this.type        = type;
            this.count       = count;
            this.formula     = formula;
            this.tileLocator = tileLocator;
            this.lvl         = lvl;

            stats          = troopObject.Stub.Template[type];
            LeftOverHp     = stats.MaxHp;
            eachUnitUpkeep = unitFactory.GetUnitStats(type, lvl).Upkeep;
        }
Beispiel #2
0
 public CityRewardStrategy(ICity city, IBattleFormulas battleFormulas, Formula formula, ILocker locker)
 {
     this.city           = city;
     this.battleFormulas = battleFormulas;
     this.formula        = formula;
     this.locker         = locker;
 }
Beispiel #3
0
        public BattleManager(uint battleId,
                             BattleLocation location,
                             BattleOwner owner,
                             IRewardStrategy rewardStrategy,
                             IDbManager dbManager,
                             IBattleReport battleReport,
                             ICombatListFactory combatListFactory,
                             IBattleFormulas battleFormulas,
                             IBattleOrder battleOrder,
                             IBattleRandom battleRandom)
        {
            groupIdGen = new LargeIdGenerator(uint.MaxValue);
            idGen      = new LargeIdGenerator(uint.MaxValue);
            // Group id 1 is always reserved for local troop
            groupIdGen.Set(1);

            BattleId     = battleId;
            Location     = location;
            Owner        = owner;
            BattleReport = battleReport;
            Attackers    = combatListFactory.GetAttackerCombatList();
            Defenders    = combatListFactory.GetDefenderCombatList();

            this.rewardStrategy = rewardStrategy;
            this.dbManager      = dbManager;
            this.battleOrder    = battleOrder;
            this.battleFormulas = battleFormulas;
            this.battleRandom   = battleRandom;
        }
Beispiel #4
0
        public DefenseCombatUnit(uint id,
                                 uint battleId,
                                 ITroopStub stub,
                                 FormationType formation,
                                 ushort type,
                                 byte lvl,
                                 ushort count,
                                 IBattleFormulas battleFormulas,
                                 Formula formula,
                                 UnitFactory unitFactory,
                                 IDbManager dbManager)
            : base(id, battleId, battleFormulas, dbManager)
        {
            troopStub      = stub;
            this.formation = formation;
            this.type      = type;
            this.count     = count;
            this.formula   = formula;
            this.lvl       = lvl;

            stats      = stub.Template[type];
            leftOverHp = stats.MaxHp;

            eachUnitUpkeep = unitFactory.GetUnitStats(type, lvl).Upkeep;
        }
Beispiel #5
0
 public CombatStructure(uint id,
                        uint battleId,
                        IStructure structure,
                        BattleStats stats,
                        decimal hp,
                        ushort type,
                        byte lvl,
                        string theme,
                        Formula formula,
                        IActionFactory actionFactory,
                        IBattleFormulas battleFormulas,
                        ITileLocator tileLocator,
                        IRegionManager regionManager,
                        IDbManager dbManager)
     : base(id, battleId, battleFormulas, dbManager)
 {
     Structure          = structure;
     this.formula       = formula;
     this.actionFactory = actionFactory;
     this.tileLocator   = tileLocator;
     this.regionManager = regionManager;
     this.stats         = stats;
     this.hp            = hp;
     this.type          = type;
     this.lvl           = lvl;
     this.Theme         = theme;
 }
Beispiel #6
0
        public CombatList(IDbManager manager, ITileLocator tileLocator, IBattleFormulas battleFormulas)
            : base(manager)
        {
            this.tileLocator    = tileLocator;
            this.battleFormulas = battleFormulas;

            ItemAdded += ObjectAdded;
        }
Beispiel #7
0
 public CityChannel(Util.IChannel channel, Procedure procedure, Formula formula, IRegionManager regionManager, IRegionLocator regionLocator, IBattleFormulas battleFormulas)
 {
     this.channel        = channel;
     this.procedure      = procedure;
     this.formula        = formula;
     this.regionManager  = regionManager;
     this.regionLocator  = regionLocator;
     this.battleFormulas = battleFormulas;
 }
Beispiel #8
0
        protected CombatObject(uint id, uint battleId, IBattleFormulas battleFormulas, IDbManager dbManager)
        {
            Id             = id;
            MinDmgDealt    = ushort.MaxValue;
            MinDmgRecv     = ushort.MaxValue;
            BattleId       = battleId;
            BattleFormulas = battleFormulas;
            this.dbManager = dbManager;

            IsWaitingToJoinBattle = true;
        }
Beispiel #9
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)
 {
 }
Beispiel #10
0
 public StrongholdEngageGateAttackPassiveAction(IBattleFormulas battleFormula,
                                                IGameObjectLocator gameObjectLocator,
                                                StrongholdBattleProcedure strongholdBattleProcedure,
                                                IDbManager dbManager,
                                                IStaminaMonitorFactory staminaMonitorFactory)
 {
     this.battleFormula             = battleFormula;
     this.gameObjectLocator         = gameObjectLocator;
     this.strongholdBattleProcedure = strongholdBattleProcedure;
     this.dbManager             = dbManager;
     this.staminaMonitorFactory = staminaMonitorFactory;
 }
Beispiel #11
0
 public PublicBattleManager(uint battleId,
                            BattleLocation location,
                            BattleOwner owner,
                            IRewardStrategy rewardStrategy,
                            IDbManager dbManager,
                            IBattleReport battleReport,
                            ICombatListFactory combatListFactory,
                            IBattleFormulas battleFormulas,
                            IBattleOrder battleOrder,
                            IBattleRandom battleRandom)
     : base(battleId, location, owner, rewardStrategy, dbManager, battleReport, combatListFactory, battleFormulas, battleOrder, battleRandom)
 {
 }
Beispiel #12
0
 public StrongholdEngageGateAttackPassiveAction(uint cityId,
                                                uint troopObjectId,
                                                uint targetStrongholdId,
                                                IBattleFormulas battleFormula,
                                                IGameObjectLocator gameObjectLocator,
                                                StrongholdBattleProcedure strongholdBattleProcedure,
                                                IDbManager dbManager,
                                                IStaminaMonitorFactory staminaMonitorFactory)
     : this(battleFormula, gameObjectLocator, strongholdBattleProcedure, dbManager, staminaMonitorFactory)
 {
     this.cityId             = cityId;
     this.troopObjectId      = troopObjectId;
     this.targetStrongholdId = targetStrongholdId;
 }
Beispiel #13
0
 public BarbarianTribeEngageAttackPassiveAction(IBattleFormulas battleFormula,
                                                IGameObjectLocator gameObjectLocator,
                                                BarbarianTribeBattleProcedure barbarianTribeBattleProcedure,
                                                Formula formula,
                                                IDbManager dbManager,
                                                IStaminaMonitorFactory staminaMonitorFactory)
 {
     this.battleFormula                 = battleFormula;
     this.gameObjectLocator             = gameObjectLocator;
     this.barbarianTribeBattleProcedure = barbarianTribeBattleProcedure;
     this.formula               = formula;
     this.dbManager             = dbManager;
     this.staminaMonitorFactory = staminaMonitorFactory;
 }
Beispiel #14
0
 public BarbarianTribeEngageAttackPassiveAction(uint cityId,
                                                uint troopObjectId,
                                                uint targetObjectId,
                                                IBattleFormulas battleFormula,
                                                IGameObjectLocator gameObjectLocator,
                                                BarbarianTribeBattleProcedure barbarianTribeBattleProcedure,
                                                Formula formula,
                                                IDbManager dbManager,
                                                IStaminaMonitorFactory staminaMonitorFactory)
     : this(battleFormula, gameObjectLocator, barbarianTribeBattleProcedure, formula, dbManager, staminaMonitorFactory)
 {
     this.cityId         = cityId;
     this.troopObjectId  = troopObjectId;
     this.targetObjectId = targetObjectId;
 }
Beispiel #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;
 }
Beispiel #16
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;
 }
Beispiel #17
0
 public StrongholdMainBattleManager(uint battleId,
                                    BattleLocation location,
                                    BattleOwner owner,
                                    IRewardStrategy rewardStrategy,
                                    IDbManager dbManager,
                                    IBattleReport battleReport,
                                    ICombatListFactory combatListFactory,
                                    IGameObjectLocator gameObjectLocator,
                                    IBattleOrder battleOrder,
                                    IBattleFormulas battleFormulas,
                                    IBattleRandom random) :
     base(battleId, location, owner, rewardStrategy, dbManager, battleReport, combatListFactory, battleFormulas, battleOrder, random)
 {
     this.gameObjectLocator = gameObjectLocator;
 }
Beispiel #18
0
 public DefenseCombatUnit(uint id,
                          uint battleId,
                          ITroopStub stub,
                          FormationType formation,
                          ushort type,
                          byte lvl,
                          ushort count,
                          decimal leftOverHp,
                          IBattleFormulas battleFormulas,
                          Formula formula,
                          UnitFactory unitFactory,
                          IDbManager dbManager)
     : this(id, battleId, stub, formation, type, lvl, count, battleFormulas, formula, unitFactory, dbManager)
 {
     this.leftOverHp = leftOverHp;
 }
Beispiel #19
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();
        }
Beispiel #20
0
        public StaminaMonitor(IBattleManager battleManager,
                              ICombatGroup combatGroup,
                              short initialStamina,
                              IBattleFormulas battleFormulas,
                              IObjectTypeFactory objectTypeFactory)
        {
            this.objectTypeFactory = objectTypeFactory;
            CombatGroup            = combatGroup;
            Stamina        = initialStamina;
            BattleFormulas = battleFormulas;

            battleManager.ActionAttacked   += BattleActionAttacked;
            battleManager.WithdrawAttacker += BattleWithdrawAttacker;
            battleManager.EnterRound       += BattleEnterRound;
            battleManager.ExitTurn         += BattleExitTurn;
        }
Beispiel #21
0
        public BattleManagerGate(uint battleId,
                                 IStronghold stronghold,
                                 BattleLocation location,
                                 BattleOwner owner,
                                 IRewardStrategy rewardStrategy,
                                 IDbManager dbManager,
                                 IBattleReport battleReport,
                                 ICombatListFactory combatListFactory,
                                 IBattleFormulas battleFormulas,
                                 IBattleOrder battleOrder,
                                 IBattleRandom battleRandom)
            : base(battleId, location, owner, rewardStrategy, dbManager, battleReport, combatListFactory, battleFormulas, battleOrder, battleRandom)
        {
            this.stronghold = stronghold;

            precision = 1m + (new Random((int)(owner.Id + battleId + location.Id)).Next(-20, 20) / 100m);
        }
Beispiel #22
0
 /// <summary>
 ///     DB loader constructor
 /// </summary>
 public AttackCombatUnit(uint id,
                         uint battleId,
                         ITroopObject troopObject,
                         FormationType formation,
                         ushort type,
                         byte lvl,
                         ushort count,
                         decimal leftOverHp,
                         Resource loot,
                         UnitFactory unitFactory,
                         IBattleFormulas battleFormulas,
                         Formula formula,
                         ITileLocator tileLocator,
                         IDbManager dbManager)
     : this(id, battleId, troopObject, formation, type, lvl, count, unitFactory, battleFormulas, formula, tileLocator, dbManager)
 {
     LeftOverHp = leftOverHp;
     this.loot  = loot;
 }
Beispiel #23
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);
        }
Beispiel #24
0
        public StrongholdCombatUnit(uint id,
                                    uint battleId,
                                    ushort type,
                                    byte lvl,
                                    ushort count,
                                    IStronghold stronghold,
                                    UnitFactory unitFactory,
                                    IBattleFormulas battleFormulas,
                                    Formula formula,
                                    IDbManager dbManager)
            : base(id, battleId, battleFormulas, dbManager)
        {
            Stronghold       = stronghold;
            this.type        = type;
            this.count       = count;
            this.unitFactory = unitFactory;
            this.lvl         = lvl;
            this.formula     = formula;

            stats      = new BattleStats(unitFactory.GetUnitStats(type, lvl).Battle);
            LeftOverHp = stats.MaxHp;
        }
Beispiel #25
0
        public BarbarianTribeCombatUnit(uint id,
                                        uint battleId,
                                        ushort type,
                                        byte lvl,
                                        ushort count,
                                        IBaseUnitStats unitBaseStats,
                                        IBarbarianTribe barbarianTribe,
                                        IBattleFormulas battleFormulas,
                                        Formula formula,
                                        IDbManager dbManager)
            : base(id, battleId, battleFormulas, dbManager)
        {
            BarbarianTribe = barbarianTribe;
            this.type      = type;
            this.count     = count;
            this.lvl       = lvl;
            this.formula   = formula;

            baseStats   = unitBaseStats;
            battleStats = new BattleStats(unitBaseStats.Battle);

            LeftOverHp = baseStats.Battle.MaxHp;
        }
Beispiel #26
0
 public CombatStructure(uint id,
                        uint battleId,
                        IStructure structure,
                        BattleStats stats,
                        Formula formula,
                        IActionFactory actionFactory,
                        IBattleFormulas battleFormulas,
                        ITileLocator tileLocator,
                        IRegionManager regionManager,
                        IDbManager dbManager)
     : base(id, battleId, battleFormulas, dbManager)
 {
     this.stats         = stats;
     this.formula       = formula;
     this.actionFactory = actionFactory;
     this.tileLocator   = tileLocator;
     this.regionManager = regionManager;
     Structure          = structure;
     type  = structure.Type;
     lvl   = structure.Lvl;
     hp    = structure.Stats.Hp;
     Theme = structure.Theme;
 }
Beispiel #27
0
        public int UpkeepForCity(ICity city, IBattleFormulas battleFormulas)
        {
            var upkeep  = 0;
            var effects = city.Technologies.GetEffects(EffectCode.UpkeepReduce);

            foreach (var stub in city.Troops.MyStubs())
            {
                foreach (var formation in stub)
                {
                    foreach (var kvp in formation)
                    {
                        decimal formationPenalty = formation.Type == FormationType.Garrison ? 1.25m : 1m;
                        int     reduceTechSum    = effects.Sum(x => battleFormulas.UnitStatModCheck(city.Template[kvp.Key].Battle,
                                                                                                    TroopBattleGroup.Any,
                                                                                                    (string)x.Value[1]) ? (int)x.Value[0] : 0);
                        decimal reductionPercentage = (100m - Math.Min(reduceTechSum, 30m)) / 100m;

                        upkeep += (int)Math.Ceiling(formationPenalty * kvp.Value * city.Template[kvp.Key].Upkeep * reductionPercentage);
                    }
                }
            }

            return(upkeep);
        }
Beispiel #28
0
        public CityPassiveAction(IObjectTypeFactory objectTypeFactory,
                                 ILocker locker,
                                 Formula formula,
                                 IActionFactory actionFactory,
                                 Procedure procedure,
                                 IGameObjectLocator locator,
                                 IBattleFormulas battleFormulas,
                                 IStructureCsvFactory structureFactory,
                                 TechnologyFactory technologyFactory,
                                 UnitFactory unitFactory)
        {
            this.objectTypeFactory = objectTypeFactory;
            this.locker            = locker;
            this.formula           = formula;
            this.actionFactory     = actionFactory;
            this.procedure         = procedure;
            this.locator           = locator;
            this.battleFormulas    = battleFormulas;
            this.structureFactory  = structureFactory;
            this.technologyFactory = technologyFactory;
            this.unitFactory       = unitFactory;

            CreateSubscriptions();
        }
Beispiel #29
0
 public TroopStub(ushort troopId, ICity city, Formula formula, IDbManager dbManager, IBattleFormulas battleFormulas)
 {
     City           = city;
     this.formula   = formula;
     this.dbManager = dbManager;
     this.troopId   = troopId;
     Template       = new TroopTemplate(this, battleFormulas);
 }
Beispiel #30
0
 public TroopTemplate(ITroopStub stub, IBattleFormulas battleFormulas)
 {
     this.stub           = stub;
     this.battleFormulas = battleFormulas;
 }