Skip to content

Commit

Permalink
Merge branch 'master' of /~https://github.com/xdnw/locutus
Browse files Browse the repository at this point in the history
  • Loading branch information
xdnw committed Feb 23, 2025
2 parents 8bbfdba + 849d0ac commit 5c0a7fa
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1475,7 +1475,8 @@ else if (!bypass_checks) {
@Command(desc = "Get a sheet of members and their revenue (compared to optimal city builds)", viewable = true)
@RolePermission(value = {Roles.ECON_STAFF, Roles.ECON})
@IsAlliance
public String revenueSheet(@Me IMessageIO io, @Me GuildDB db, NationList nations, @Switch("s") SpreadSheet sheet, @Switch("t") @Timestamp Long snapshotTime) throws GeneralSecurityException, IOException, ExecutionException, InterruptedException {
public String revenueSheet(@Me IMessageIO io, @Me GuildDB db, NationList nations, @Switch("s") SpreadSheet sheet, @Switch("i") boolean include_untaxable,
@Switch("t") @Timestamp Long snapshotTime) throws GeneralSecurityException, IOException, ExecutionException, InterruptedException {
Set<DBNation> nationSet = PW.getNationsSnapshot(nations.getNations(), nations.getFilter(), snapshotTime, db.getGuild());
if (sheet == null) {
sheet = SpreadSheet.create(db, SheetKey.REVENUE_SHEET);
Expand All @@ -1484,10 +1485,19 @@ public String revenueSheet(@Me IMessageIO io, @Me GuildDB db, NationList nations
Set<Integer> ids = db.getAllianceIds(false);
int sizeOriginal = nationSet.size();
nationSet.removeIf(f -> f.getPosition() <= Rank.APPLICANT.id || !ids.contains(f.getAlliance_id()));
nationSet.removeIf(f -> f.active_m() > 7200 || f.isGray() || f.isBeige() || f.getVm_turns() > 0);
int numRemoved = sizeOriginal - nationSet.size();
int numRemovedNotAA = sizeOriginal - (sizeOriginal = nationSet.size());
nationSet.removeIf(f -> f.getVm_turns() > 0);
int numRemovedVM = sizeOriginal - (sizeOriginal = nationSet.size());
if (!include_untaxable) nationSet.removeIf(f -> !f.isTaxable());
int numRemovedUntaxable = sizeOriginal - (sizeOriginal = nationSet.size());

List<String> footer = new ArrayList<>();
if (numRemovedNotAA > 0) footer.add(numRemovedNotAA + " nations were removed for not being members of the guild's alliances");
if (numRemovedVM > 0) footer.add(numRemovedVM + " nations were removed for being in vacation mode");
if (numRemovedUntaxable > 0) footer.add(numRemovedUntaxable + " nations were removed for being untaxable");

if (nationSet.isEmpty()) {
return "No nations to process. " + numRemoved + " nations were removed from the list. Please ensure they are members of your alliance";
return "No nations to process." + StringMan.join(footer, "\n");
}

List<String> header = new ArrayList<>(Arrays.asList(
Expand Down Expand Up @@ -1604,7 +1614,7 @@ public String revenueSheet(@Me IMessageIO io, @Me GuildDB db, NationList nations
sheet.updateClearCurrentTab();
sheet.updateWrite();

sheet.attach(io.create(), "revenue").send();
sheet.attach(io.create(), "revenue").append(StringMan.join(footer, "\n")).send();
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2560,6 +2560,7 @@ public static String vmHistory(@Me IMessageIO io, @Me GuildDB db, Set<DBNation>
public String allianceCost(@Me IMessageIO channel, @Me GuildDB db,
NationList nations, @Switch("u") boolean update,
@Switch("p") @Arg("Only include the cost of specific projects") Set<Project> includeProjects,
@Switch("nc") @Arg("Use the new city cost formula") boolean new_city_formula,
@Switch("s") @Timestamp Long snapshotDate) {
Set<DBNation> nationSet = PW.getNationsSnapshot(nations.getNations(), nations.getFilter(), snapshotDate, db.getGuild());
double infraCost = 0;
Expand All @@ -2573,6 +2574,11 @@ public String allianceCost(@Me IMessageIO channel, @Me GuildDB db,
cityProjectRefund += PW.City.getCostReduction(nation::hasProject);
Set<Project> projects = nation.getProjects();
for (Project project : projects) {
if (new_city_formula) {
if (project == Projects.URBAN_PLANNING) continue;
if (project == Projects.ADVANCED_URBAN_PLANNING) continue;
if (project == Projects.METROPOLITAN_PLANNING) continue;
}
if (includeProjects != null && !includeProjects.contains(project)) continue;
projectCost = ResourceType.addResourcesToA(projectCost, project.cost());
}
Expand All @@ -2581,15 +2587,23 @@ public String allianceCost(@Me IMessageIO channel, @Me GuildDB db,
militaryCost = ResourceType.addResourcesToA(militaryCost, ResourceType.resourcesToMap(unit.getCost(units)));
}
int cities = nation.getCities();
double nationCityCost = 0;
for (int i = 1; i <= cities; i++) {
boolean manifest = true;
boolean cp = i > Projects.URBAN_PLANNING.requiredCities() && projects.contains(Projects.URBAN_PLANNING);
boolean acp = i > Projects.ADVANCED_URBAN_PLANNING.requiredCities() && projects.contains(Projects.ADVANCED_URBAN_PLANNING);
boolean mp = i > Projects.METROPOLITAN_PLANNING.requiredCities() && projects.contains(Projects.METROPOLITAN_PLANNING);
boolean gsa = projects.contains(Projects.GOVERNMENT_SUPPORT_AGENCY);
boolean bda = projects.contains(Projects.BUREAU_OF_DOMESTIC_AFFAIRS);
cityCost += PW.City.nextCityCost(i, manifest, cp, acp, mp, gsa, bda);
if (new_city_formula) {
nationCityCost += PW.City.newNextCityCost(i, manifest, cp, acp, mp, gsa, bda);
} else {
nationCityCost += PW.City.nextCityCost(i, manifest, cp, acp, mp, gsa, bda);
}
}

cityCost += nationCityCost;

Map<Integer, JavaCity> cityMap = nation.getCityMap(update, update,false);
for (Map.Entry<Integer, JavaCity> cityEntry : cityMap.entrySet()) {
JavaCity city = cityEntry.getValue();
Expand Down

0 comments on commit 5c0a7fa

Please sign in to comment.