/// <summary> /// Calculates the strength of the Ritimba republic in a scenario of war. /// </summary> /// <returns>The total strength of Ritimba in a scenario of war.</returns> public int CalculateRitimbaStrength() { int totalStrength = 0; Group[] groups = groupService.GetGroups(); // Sum the strength of the army, peasants and landowners if they have minimal popularity for (int i = 0; i < 3; i++) { if (groups[i].Popularity > governmentService.GetMonthlyMinimalPopularityAndStrength()) { totalStrength += groups[i].Strength; } } Group secretPoliceGroup = groupService.GetGroupByType(GroupType.SecretPolice); // Add the strength of the secret police strength if they have minimal popularity if (secretPoliceGroup.Popularity > governmentService.GetMonthlyMinimalPopularityAndStrength()) { totalStrength += secretPoliceGroup.Strength; } // Add the strength of the player to the total totalStrength += governmentService.GetPlayerStrength(); return(totalStrength); }
/// <summary> /// Determines if the popularity with the secret police is less or equal to the minimum required monthly popularity. /// </summary> /// <returns><c>true</c> if the player is not popular enough with the secret police; otherwise, <c>false</c>.</returns> private bool DoesPoliceHatePlayer() { Group police = groupService.GetGroupByType(GroupType.SecretPolice); if (police.Popularity <= governmentService.GetMonthlyMinimalPopularityAndStrength()) { return(true); } return(false); }
/// <summary> /// Finds the groups that can be possible allies of a player in a revolution. /// </summary> /// <returns>A dictionary containing the groups that can be possible allies with their respective ids.</returns> public Dictionary <int, Group> FindPossibleAllies() { Group[] groups = groupService.GetGroups(); Dictionary <int, Group> possibleAllies = new Dictionary <int, Group>(); for (int i = 0; i < 6; i++) { if (groups[i].Popularity > governmentService.GetMonthlyMinimalPopularityAndStrength()) { possibleAllies.Add(i + 1, groups[i]); } } return(possibleAllies); }
/// <summary> /// Asks for foreign aid in the form of a loan to either America or Russia. /// </summary> /// <param name="country">The country to which the loan request will be made.</param> /// <returns>The loan application result that includes if the loan has been approved or refused.</returns> public LoanApplicationResult AskForLoan(LenderCountry country) { LoanApplicationResult loanApplicationResult = new LoanApplicationResult { Country = country }; if (IsTooEarlyForLoan()) { loanApplicationResult.IsAccepted = false; loanApplicationResult.RefusalType = LoanApplicationRefusalType.TooEarly; return(loanApplicationResult); } if (HasLoanBeenGrantedPreviously(country)) { loanApplicationResult.IsAccepted = false; loanApplicationResult.RefusalType = LoanApplicationRefusalType.AlreadyUsed; return(loanApplicationResult); } GroupType groupType = groupService.GetGroupTypeByCountry(country); Group group = groupService.GetGroupByType(groupType); loanApplicationResult.GroupName = group.Name; if (group.Popularity <= governmentService.GetMonthlyMinimalPopularityAndStrength()) { loanApplicationResult.IsAccepted = false; loanApplicationResult.RefusalType = LoanApplicationRefusalType.NotPopularEnough; } else { loanApplicationResult.IsAccepted = true; loanApplicationResult.RefusalType = LoanApplicationRefusalType.None; loanApplicationResult.Amount = CalculateLoanAmount(group); accountService.ChangeTreasuryBalance(loanApplicationResult.Amount); } return(loanApplicationResult); }
/// <summary> /// Checks for the required conditions and changes que appropriate group status /// to the revolution and assassination modes. /// </summary> public void Plot() { // Do not trigger assassinations or revolutions after failed revolution if (governmentService.GetMonth() < governmentService.GetPlotBonus()) { return; } // Do not trigger assassinations or revolutions in the first 2 months of government if (governmentService.GetMonth() > 2) { groupService.ResetStatusAndAllies(); Group[] groups = groupService.GetGroups(); int monthlyMinimalPopularityAndStrength = governmentService.GetMonthlyMinimalPopularityAndStrength(); int monthlyRevolutionStrength = governmentService.GetMonthlyRevolutionStrength(); // Perform internal plot logic ExecutePlot(groups, monthlyMinimalPopularityAndStrength, monthlyRevolutionStrength); } }
/// <summary> /// Determines if the player is popular with the secret police. /// </summary> /// <returns><c>true</c> if the player is popular with the secret police; otherwise, <c>false</c>.</returns> private bool IsPlayerPopularWithSecretPolice() { int secretPolicePopularity = groupService.GetPopularityByGroupType(GroupType.SecretPolice); return(secretPolicePopularity > governmentService.GetMonthlyMinimalPopularityAndStrength()); }