Exemplo n.º 1
0
        public WorldService(ICompanyEmployeeRepository companyEmployeeRepository, IContractRepository contractRepository, IContractService contractService,
                            ICitizenRepository citizenRepository, IConfigurationRepository configurationRepository, IEquipmentRepository equipmentRepository,
                            IPartyService partyService, ICongressCandidateService congressCandidateService, ICongressVotingService congressVotingService,
                            ICountryService countryService, IBattleService battleService, IRegionService regionService, ICompanyService companyService,
                            IEmbargoService embargoService, IWarService warService, IEmployeeService employeeService, IMPPService mppService, IWalletService walletService,
                            INewDayRepository newDayRepository, IHotelService hotelService, IHouseService houseService)
        {
            this.citizenRepository         = citizenRepository;
            this.configurationRepository   = configurationRepository;
            this.equipmentRepository       = equipmentRepository;
            this.companyEmployeeRepository = companyEmployeeRepository;
            this.contractRepository        = contractRepository;
            this.contractService           = contractService;
            this.partyService             = partyService;
            this.congressCandidateService = congressCandidateService;
            this.congressVotingService    = congressVotingService;
            this.countryService           = countryService;
            this.battleService            = battleService;
            this.regionService            = regionService;
            this.companyService           = companyService;
            this.embargoService           = embargoService;
            this.warService       = warService;
            this.employeeService  = employeeService;
            this.mppService       = mppService;
            this.walletService    = Attach(walletService);
            this.newDayRepository = newDayRepository;
            this.hotelService     = hotelService;
            this.houseService     = houseService;

            citizenRepository.SetTimeout(300);
            equipmentRepository.SetTimeout(300);
        }
Exemplo n.º 2
0
 public Engine(
     IAccountService accountService,
     IGovernmentService governmentService,
     IGroupService groupService,
     IReportService reportService,
     IPlotService plotService,
     IDecisionService decisionService,
     IAudienceService audienceService,
     INewsService newsService,
     IRevolutionService revolutionService,
     IScoreService scoreService,
     IEscapeService escapeService,
     IAssassinationService assassinationService,
     ILoanService loanService,
     IWarService warService)
 {
     this.accountService       = accountService;
     this.governmentService    = governmentService;
     this.groupService         = groupService;
     this.reportService        = reportService;
     this.plotService          = plotService;
     this.decisionService      = decisionService;
     this.audienceService      = audienceService;
     this.newsService          = newsService;
     this.revolutionService    = revolutionService;
     this.scoreService         = scoreService;
     this.escapeService        = escapeService;
     this.assassinationService = assassinationService;
     this.loanService          = loanService;
     this.warService           = warService;
 }
Exemplo n.º 3
0
        public TransactionResult PayForWar(Country attacker, Country defender, IWarService warService)
        {
            var adminCurrency = Persistent.Currencies.Gold;
            var attEntity     = attacker.Entity;
            var defEntity     = defender.Entity;

            var adminMoney = new Money()
            {
                Amount   = (decimal)warService.GetNeededGoldToStartWar(attacker, defender),
                Currency = adminCurrency
            };


            var adminTransaction = new Transaction()
            {
                Arg1 = "War fee",
                Arg2 = string.Format("{0}({1}) Attacked {2}({3})", attEntity.Name, attEntity.EntityID, defEntity.Name, defEntity.EntityID),
                DestinationEntityID = null,
                Money           = adminMoney,
                SourceEntityID  = attEntity.EntityID,
                TransactionType = TransactionTypeEnum.WarFee
            };

            return(MakeTransaction(adminTransaction));
        }
Exemplo n.º 4
0
        private void initCanFight(Entities.Battle battle, IWarService warService)
        {
            bool canFight = SessionHelper.CurrentEntity.GetEntityType() == Entities.enums.EntityTypeEnum.Citizen && SessionHelper.CurrentEntity.Citizen.HitPoints > 5;

            if (canFight)
            {
                var fightingSide = warService.GetFightingSide(battle.War, SessionHelper.CurrentEntity.Citizen);

                if (fightingSide == Entities.enums.WarSideEnum.Attacker)
                {
                    CanFightAsAttacker = true;
                }
                else if (fightingSide == Entities.enums.WarSideEnum.Defender)
                {
                    CanFighstAsDefender = true;
                }
                else
                {
                    if (battle.RegionID == SessionHelper.CurrentEntity.GetCurrentRegion().ID)
                    {
                        CanFighstAsDefender = CanFightAsAttacker = true;
                    }
                }

                if (!battle.AttackerInitiatedBattle)
                {
                    var att = CanFightAsAttacker;
                    CanFightAsAttacker  = CanFighstAsDefender;
                    CanFighstAsDefender = att;
                }
            }
        }
Exemplo n.º 5
0
 public CountryController(ICountryRepository countryRepository, ICountryService countryService, IPresidentVotingRepository presidentVotingRepository, IWarService warService,
                          ITransactionsService transactionService, IWarRepository warRepository, IRegionService regionService, IRegionRepository regionRepository, IEmbargoService embargoService,
                          IEmbargoRepository embargoRepository, IWalletRepository walletRepository, IPopupService popupService, ICountryTreasureService countryTreasureService,
                          IWalletService walletService, ICompanyService companyService, IMPPService mppService, IMilitaryProtectionPactRepository mppRepository,
                          IMilitaryProtectionPactOfferRepository mppOfferRepository, ITransactionScopeProvider transactionScopeProvider, IConstructionRepository constructionRepository,
                          IConstructionService constructionService) : base(popupService)
 {
     this.countryRepository         = countryRepository;
     this.countryService            = countryService;
     this.presidentVotingRepository = presidentVotingRepository;
     this.warService               = warService;
     this.transactionService       = transactionService;
     this.warRepository            = warRepository;
     this.regionService            = regionService;
     this.regionRepository         = regionRepository;
     this.embargoService           = embargoService;
     this.embargoRepository        = embargoRepository;
     this.walletRepository         = walletRepository;
     this.countryTreasureService   = countryTreasureService;
     this.walletService            = walletService;
     this.companyService           = companyService;
     this.mppService               = mppService;
     this.mppRepository            = mppRepository;
     this.mppOfferRepository       = mppOfferRepository;
     this.transactionScopeProvider = transactionScopeProvider;
     this.constructionRepository   = constructionRepository;
     this.constructionService      = constructionService;
 }
Exemplo n.º 6
0
        public WarViewModel(Entities.War war, IWarService warService, IWarRepository warRepository)
        {
            Info = new WarInfoViewModel(war, warRepository, warService);

            foreach (var battle in war.Battles.OrderByDescending(b => b.Active).ThenByDescending(b => b.ID).ToList())
            {
                ActiveBattles.Add(new SummaryBattleViewModel(battle));
            }
        }
Exemplo n.º 7
0
 public BattleController(IBattleRepository battleRepository, IBattleService battleService, IWarRepository warRepository, IWarService warService,
                         IProductRepository productRepository, IEquipmentRepository equipmentRepository, IPopupService popupService) : base(popupService)
 {
     this.battleRepository    = battleRepository;
     this.battleService       = battleService;
     this.warRepository       = warRepository;
     this.warService          = warService;
     this.productRepository   = productRepository;
     this.equipmentRepository = equipmentRepository;
 }
Exemplo n.º 8
0
 public WarController(IWarRepository warRepository, IWarService warService, IBattleService battleService, ICountryRepository countryRepository, IRegionRepository regionRepository,
                      Entities.Repository.IWalletRepository walletRepository, IPopupService popupService) : base(popupService)
 {
     this.warRepository     = warRepository;
     this.warService        = warService;
     this.battleService     = battleService;
     this.countryRepository = countryRepository;
     this.regionRepository  = regionRepository;
     this.walletRepository  = walletRepository;
 }
Exemplo n.º 9
0
 public MPPService(ICountryService countryService, IWalletService walletService, IWarService warService,
                   IMilitaryProtectionPactOfferRepository militaryProtectionPactOfferRepository, ITransactionsService transactionsService,
                   IWarningService warningService, IMilitaryProtectionPactRepository militaryProtectionPactRepository)
 {
     this.countryService = countryService;
     this.walletService  = walletService;
     this.warService     = warService;
     this.militaryProtectionPactOfferRepository = militaryProtectionPactOfferRepository;
     this.transactionsService = transactionsService;
     this.warningService      = warningService;
     this.militaryProtectionPactRepository = militaryProtectionPactRepository;
 }
Exemplo n.º 10
0
 public GameController(IWorldService worldService, IWalletService walletService, ICurrencyRepository currencyRepository, IDebugDayChangeRepository debugDayChangeRepository
                       , IPopupService popupService, ICitizenRepository citizenRepository, IWarService warService, IEntityRepository entityRepository,
                       IBattleService battleService, IBattleRepository battleRepository) : base(popupService)
 {
     this.worldService             = worldService;
     this.walletService            = walletService;
     this.currencyRepository       = currencyRepository;
     this.debugDayChangeRepository = debugDayChangeRepository;
     this.citizenRepository        = citizenRepository;
     this.warService       = warService;
     this.entityRepository = entityRepository;
     this.battleRepository = battleRepository;
     this.battleService    = battleService;
 }
Exemplo n.º 11
0
 public GameOfWarService(
     ILogger <GameOfWarService> logger,
     IConfiguration config,
     IDealCardsService dealCardsService,
     IWinnerService winnerService,
     IPlayerFactory playerFactory,
     IWarService warService, IDrawService drawService)
 {
     _logger           = logger;
     _config           = config;
     _dealCardsService = dealCardsService;
     _winnerService    = winnerService;
     _playerFactory    = playerFactory;
     _warService       = warService;
     _drawService      = drawService;
 }
Exemplo n.º 12
0
 public BattleService(IBattleRepository battleRepository, IRegionRepository regionRepository, IWarService warService, IEquipmentRepository equipmentRepository,
                      IWarningService warningService, ICountryRepository countryRepository, ITransactionsService transactionService, IRegionService regionService,
                      IWarRepository warRepository, ICitizenRepository citizenRepository, ICitizenService citizenService, IEntityRepository entityRepository,
                      IBattleEventService battleEventService)
 {
     this.battleRepository    = battleRepository;
     this.regionRepository    = regionRepository;
     this.warService          = Attach(warService);
     this.equipmentRepository = equipmentRepository;
     this.warningService      = Attach(warningService);
     this.countryRepository   = countryRepository;
     this.transactionService  = Attach(transactionService);
     this.regionService       = Attach(regionService);
     this.warRepository       = warRepository;
     this.citizenRepository   = citizenRepository;
     this.citizenService      = citizenService;
     this.entityRepository    = entityRepository;
     this.battleEventService  = battleEventService;
 }
Exemplo n.º 13
0
        public Game(
            IDealCardsService dealCardsService,
            IWinnerService winnerService,
            IPlayerFactory playerFactory,
            IWarService warService,
            IDrawService drawService,
            Func <string> inputProvider,
            Action <string> outputProvider,
            int playerCount)
        {
            _dealCardsService = dealCardsService;
            _winnerService    = winnerService;
            _inputProvider    = inputProvider;
            _outputProvider   = outputProvider;
            _drawService      = drawService;
            _warService       = warService;

            Players = playerFactory.CreatePlayers(playerCount);
        }
Exemplo n.º 14
0
        public StartBattleViewModel(Entities.War war, IWarRepository warRepository, IWarService warSerivce)
        {
            Info = new WarInfoViewModel(war, warRepository, warSerivce);

            var warSide = warSerivce.GetWarSide(war, SessionHelper.CurrentEntity);

            ConquerableRegions.Add(new SelectListItem()
            {
                Value = "null",
                Text  = "-- Select region --"
            });

            ConquerableRegions.AddRange(warRepository.GetAttackableRegions(war.ID, warSide == WarSideEnum.Attacker)
                                        .Select(r => new { Name = r.Name, ID = r.ID })
                                        .ToList()
                                        .Select(r => new SelectListItem()
            {
                Value = r.ID.ToString(), Text = r.Name
            })
                                        .ToList());
        }
Exemplo n.º 15
0
        public WarInfoViewModel(Entities.War war, IWarRepository warRepository, IWarService warService)
        {
            Info = new ShortWarInfoViewModel(war, warService);

            Active = war.Active;

            var countriesInWar = warRepository.GetCountriesInWar(war.ID);

            var countries = new
            {
                Attackers = countriesInWar.
                            Where(ciw => ciw.IsAttacker)
                            .Select(ciw => ciw.Country)
                            .ToList(),
                Defenders = countriesInWar
                            .Where(ciw => ciw.IsAttacker == false)
                            .Select(ciw => ciw.Country)
                            .ToList()
            };

            IsRessistance = war.IsRessistanceWar;

            foreach (var attacker in countries.Attackers)
            {
                AttackerAllies.Add(new ShortWarCountryInfoViewModel(attacker));
            }
            foreach (var defender in countries.Defenders)
            {
                DefendedAllies.Add(new ShortWarCountryInfoViewModel(defender));
            }

            var entity          = SessionHelper.CurrentEntity;
            var operatedCountry = warService.GetControlledCountryInWar(entity, war);

            CanInitiateBattle    = warService.CanStartBattle(entity, operatedCountry, war).isSuccess;
            CanInitiateSurrender = warService.CanSurrenderWar(war, entity).isSuccess;

            if (Active)
            {
                WarStateText = "Active";
                if (war.AttackerOfferedSurrender == true)
                {
                    WarStateText = "Attacker offered surrender";
                }
                else if (war.AttackerOfferedSurrender == false)
                {
                    WarStateText = "Defender offered surrender";
                }
            }
            else
            {
                WarStateText = "Inactive";
            }

            var warSide = warService.GetWarSide(war, SessionHelper.CurrentEntity);

            if (war.AttackerOfferedSurrender.HasValue == false && CanInitiateSurrender)
            {
                SurrenderText = "Send surrender offer";
            }
            if (((war.AttackerOfferedSurrender == true && warSide == WarSideEnum.Defender) || (war.AttackerOfferedSurrender == false && warSide == WarSideEnum.Attacker)) &&
                CanInitiateSurrender)
            {
                SurrenderText = "Accept surrender";
            }


            CanCancelSurrender = warService.CanCancelSurrender(war, SessionHelper.CurrentEntity).isSuccess;


            var attackerHero = warService.GetWarHero(war, true);
            var defenderHero = warService.GetWarHero(war, false);

            if (attackerHero != null)
            {
                AttackerHero = new ShortBattleParticipantViewModel(attackerHero);
            }
            if (defenderHero != null)
            {
                DefenderHero = new ShortBattleParticipantViewModel(defenderHero);
            }

            if (war.IsTrainingWar)
            {
                AttackerAllies = new List <ShortWarCountryInfoViewModel>();
                DefendedAllies = new List <ShortWarCountryInfoViewModel>();

                CanCancelSurrender = CanInitiateBattle = CanInitiateSurrender = false;
            }

            //testAddAllies(war);

            createMenu();
        }
 public WarsController(IWarService warService, ILogger <TransformerController> logger)
 {
     _warService = warService;
     _logger     = logger;
 }
Exemplo n.º 17
0
        public TransactionResult PayForResistanceBattle(Citizen attacker, Region defenderRegion, IWarService warService)
        {
            var adminCurrency = Persistent.Currencies.Gold;
            var defEntity     = defenderRegion.Country.Entity;
            var attEntity     = attacker.Entity;

            var adminMoney = warService.GetMoneyNeededToStartResistanceBattle(defenderRegion);

            var adminTransaction = new Transaction()
            {
                Arg1 = "Ressistance war fee",
                Arg2 = string.Format("{0}({1}) Attacked {2}({3})", attEntity.Name, attEntity.EntityID, defEntity.Name, defEntity.EntityID),
                DestinationEntityID = null,
                Money           = adminMoney,
                SourceEntityID  = attEntity.EntityID,
                TransactionType = TransactionTypeEnum.RessistanceWar
            };

            return(MakeTransaction(adminTransaction, useTransaction: false));
        }
Exemplo n.º 18
0
        public BattleViewModel(Entities.Battle battle, IBattleRepository battleRepository, IBattleService battleService, IWarRepository warRepository, IWarService warService)
        {
            Info = new WarInfoViewModel(battle.War, warRepository, warService);

            initBasic(battle);
            initCanFight(battle, warService);
            initTime(battle);

            IsActive = battle.Active;
            CanFight = (CanFighstAsDefender || CanFightAsAttacker) && IsActive && WaitingForResolve == false;
            if (IsActive == false)
            {
                AttackerWon = battle.WonByAttacker;
                GoldTaken   = (double?)battle.GoldTaken;
            }
            addRealLastParticipants(battle);
            addDummiesIfNeeded();
            AttackerInitiated = battle.AttackerInitiatedBattle;

            var attackerHero = battleService.GetBattleHero(battle, true);
            var defenderHero = battleService.GetBattleHero(battle, false);

            if (attackerHero != null)
            {
                AttackerHero = new ShortBattleParticipantViewModel(attackerHero);
            }
            if (defenderHero != null)
            {
                DefenderHero = new ShortBattleParticipantViewModel(defenderHero);
            }

            if (battle.War.IsTrainingWar)
            {
                CanFighstAsDefender = true;
                CanFight            = SessionHelper.CurrentEntity.Is(EntityTypeEnum.Citizen);
                CanFightAsAttacker  = true;
                RegionName          = "Edge of the Earth";
                TimeLeft            = "";
                WaitingForResolve   = false;
            }
            if (CanFight)
            {
                AvailableWeaponQualities = battleService.GetUsableQualitiesOfWeapons(SessionHelper.LoggedCitizen);
            }

            AttackerName = Info.Info.Attacker.Name;
            DefenderName = Info.Info.Defender.Name;

            if (battle.AttackerInitiatedBattle == false)
            {
                AttackerName = Info.Info.Defender.Name;
                DefenderName = Info.Info.Attacker.Name;
            }
        }
Exemplo n.º 19
0
        public CountryWarsViewModel(IQueryable <Entities.War> wars, Entities.Country country, PagingParam pagingParam, IWarService warService)
        {
            Info        = new CountryInfoViewModel(country);
            PagingParam = pagingParam;

            foreach (var war in wars.Apply(pagingParam).ToList())
            {
                WarsInfo.Add(new ShortWarInfoViewModel(war, warService));
            }
        }
Exemplo n.º 20
0
        public ShortWarInfoViewModel(Entities.War war, IWarService warService)
        {
            WarID      = war.ID;
            StatusName = war.Active ? "On going" : "Finished";
            Attacker   = new ShortWarCountryInfoViewModel()
            {
                AllyCount = war.CountryInWars.Where(ciw => ciw.IsAttacker).Count(),
                Flag      = Images.GetCountryFlag(war.Attacker.Entity.Name).VM,
                Name      = war.Attacker.Entity.Name
            };

            Defender = new ShortWarCountryInfoViewModel()
            {
                AllyCount = war.CountryInWars.Where(ciw => ciw.IsAttacker == false).Count(),
                Flag      = Images.GetCountryFlag(war.Defender.Entity.Name).VM,
                Name      = war.Defender.Entity.Name
            };

            StartDay = war.StartDay;
            EndDay   = war.EndDay;

            Duration = string.Format("{0} - {1}", war.StartDay, war.EndDay?.ToString() ?? "?");

            var entity          = SessionHelper.CurrentEntity;
            var operatedCountry = warService.GetControlledCountryInWar(entity, war);

            CanInitiateBattle    = warService.CanStartBattle(entity, operatedCountry, war).isSuccess;
            CanInitiateSurrender = warService.CanSurrenderWar(war, entity).isSuccess;

            var warSide = warService.GetWarSide(war, SessionHelper.CurrentEntity);

            if (war.AttackerOfferedSurrender.HasValue == false && CanInitiateSurrender)
            {
                SurrenderText = "Send surrender offer";
            }
            if (((war.AttackerOfferedSurrender == true && warSide == WarSideEnum.Defender) || (war.AttackerOfferedSurrender == false && warSide == WarSideEnum.Attacker)) &&
                CanInitiateSurrender)
            {
                SurrenderText = "Accept surrender";
            }
            else if (CanInitiateSurrender == false && war.AttackerOfferedSurrender.HasValue && warSide != WarSideEnum.None && war.Active)
            {
                ShowAfterSurrenderText = true;
                AfterSurrenderText     = "Surrender sent";
                CanInitiateBattle      = false;
            }

            CanCancelSurrender = warService.CanCancelSurrender(war, SessionHelper.CurrentEntity).isSuccess;

            AttackerBattleWon = war.Battles.Where(b => b.Active == false && b.WonByAttacker == true).Count();
            DefenderBattleWon = war.Battles.Where(b => b.Active == false && b.WonByAttacker == false).Count();

            if (war.IsTrainingWar)
            {
                Attacker = new ShortWarCountryInfoViewModel()
                {
                    AllyCount = 0,
                    Flag      = Images.Placeholder.VM,
                    Name      = "Chuck Norris"
                };
                Defender = new ShortWarCountryInfoViewModel()
                {
                    AllyCount = 0,
                    Flag      = Images.Placeholder.VM,
                    Name      = "Bruce Lee"
                };

                CanCancelSurrender = CanInitiateBattle = CanInitiateSurrender = false;
            }
        }