Skip to content

Commit

Permalink
woops WIP Market debug + actual init list
Browse files Browse the repository at this point in the history
  • Loading branch information
gawquon committed Aug 19, 2024
1 parent c4e9889 commit 3707684
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
25 changes: 25 additions & 0 deletions EU4ToVic3/Source/V3World/EconomyManager/Demand/Market.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "Market.h"

#include <iomanip>
#include <numeric>
#include <ranges>

Expand Down Expand Up @@ -414,3 +415,27 @@ void V3::Market::clearMarket()
value = 0;
}
}

std::stringstream V3::Market::printMarketAsTable()
{
std::stringstream out;
int goodLength = 0;
int amtLength = 0;
const auto& balance = getMarketBalance();
for (const auto& [good, amt]: balance)
{
goodLength = std::max(goodLength, static_cast<int>(good.length()));
amtLength = std::max(amtLength, static_cast<int>(std::to_string(amt).length()));
}

out << std::endl;
out << std::left << std::setw(goodLength + 2) << "Good" << std::setw(amtLength + 2) << "Balance" << std::endl;
out << std::setfill('-') << std::setw(goodLength + 2) << "" << std::setw(amtLength + 2) << "" << std::endl;
out << std::setfill(' ');

for (const auto& pair: balance)
{
out << std::left << std::setw(goodLength + 2) << pair.first << std::setw(amtLength + 2) << pair.second << std::endl;
}
return out;
}
1 change: 1 addition & 0 deletions EU4ToVic3/Source/V3World/EconomyManager/Demand/Market.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Market
const std::set<std::string>& laws,
const std::map<std::string, Law>& lawsMap);
void clearMarket();
std::stringstream printMarketAsTable();

private:
static int estimateWealth(const std::string& strata);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
#include <numeric>


V3::MarketJobs::MarketJobs(const std::map<std::string, double>& jobsList)
V3::MarketJobs::MarketJobs(const std::map<std::string, double>& jobsList): jobCounts(jobsList)
{
jobCounts = jobsList;
population = std::accumulate(jobCounts.begin(), jobCounts.end(), 0, [](int sum, const auto& pair) {
return sum + static_cast<int>(pair.second);
});
Expand Down

0 comments on commit 3707684

Please sign in to comment.