Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion C7/UIElements/Advisors/DomesticAdvisor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public void ShowAdvisor() {
scienceStatus.Text = playerController.SummarizeScience(gameData);
treasury.Text = $"Treasury: {playerController.gold}";

incomeDetails.Text = $"From cities: +{totalIncome.CityInflows()}\nFrom taxmen: +{totalIncome.taxmenTaxes}\nFrom other civs: +{totalIncome.fromOtherCivs}\nFrom interest: +{totalIncome.interest}";
incomeDetails.Text = $"From cities: +{totalIncome.taxes + totalIncome.wealthProduction}\nFrom taxmen: +{totalIncome.taxmenTaxes}\nFrom other civs: +{totalIncome.fromOtherCivs}\nFrom interest: +{totalIncome.interest}";
expenseDetails.Text = $"-{totalIncome.beakers}: Science\n-{totalIncome.happiness}: Entertainment\n-{totalIncome.corrupted}: Corruption\n-{totalIncome.maintenance}: Maintenance\n-{totalIncome.unitSupport}: Unit costs\n-{totalIncome.toOtherCivs}: To other civs";
incomeSummary.Text = $"Income: {totalIncome.Inflows()}";
expenseSummary.Text = $"Expenses: {totalIncome.Outflows()}";
Expand Down
11 changes: 8 additions & 3 deletions C7Engine/C7GameData/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,24 @@ public struct PlayerCommerceBreakdown {
public int unitSupport; // Expenses due to unit support costs
public int wealthProduction; // Amount of extra commerce from "building" an Inflow that produces commerce

// The total treasury gold coming in each turn. Corruption, science and
// entertainment are allocations of a city's commerce, not income.
public int Inflows() {
return corrupted + taxes + taxmenTaxes + beakers + happiness + fromOtherCivs + interest + wealthProduction;
return taxes + taxmenTaxes + fromOtherCivs + interest + wealthProduction;
}

// The total treasury gold going out each turn.
public int Outflows() {
return corrupted + beakers + happiness + toOtherCivs + maintenance + unitSupport;
return toOtherCivs + maintenance + unitSupport;
}

public int Netflows() {
return Inflows() - Outflows();
}

public int CityInflows() {
// The total commerce generated by a player's cities before it is split
// between corruption, science, entertainment and taxes.
public int CommerceTotal() {
return corrupted + taxes + beakers + happiness + wealthProduction;
}
}
Expand Down
54 changes: 54 additions & 0 deletions EngineTests/GameData/PlayerCommerceBreakdownTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using C7GameData;
using Xunit;

namespace EngineTests.GameData;

public class PlayerCommerceBreakdownTest {
private static PlayerCommerceBreakdown MakeBreakdown() {
return new PlayerCommerceBreakdown {
corrupted = 3,
taxes = 4,
taxmenTaxes = 2,
beakers = 5,
happiness = 6,
fromOtherCivs = 1,
toOtherCivs = 2,
interest = 3,
maintenance = 4,
unitSupport = 5,
wealthProduction = 6,
};
}

[Fact]
public void InflowsIncludesOnlyTreasuryGoldIncome() {
PlayerCommerceBreakdown breakdown = MakeBreakdown();

// corrupted, beakers and happiness are allocations of city commerce,
// not income, so they must not appear in the treasury inflow number.
Assert.Equal(4 + 2 + 1 + 3 + 6, breakdown.Inflows());
}

[Fact]
public void OutflowsIncludesOnlyTreasuryGoldExpenses() {
PlayerCommerceBreakdown breakdown = MakeBreakdown();

// Science, entertainment and corruption are not treasury expenses.
Assert.Equal(2 + 4 + 5, breakdown.Outflows());
}

[Fact]
public void NetflowsIsInflowsMinusOutflows() {
PlayerCommerceBreakdown breakdown = MakeBreakdown();

Assert.Equal(breakdown.Inflows() - breakdown.Outflows(), breakdown.Netflows());
Assert.Equal(5, breakdown.Netflows());
}

[Fact]
public void CommerceTotalIncludesAllCityCommerce() {
PlayerCommerceBreakdown breakdown = MakeBreakdown();

Assert.Equal(3 + 4 + 5 + 6 + 6, breakdown.CommerceTotal());
}
}
Loading