1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Update ResourceSet.h

Rename income to availableFunds
This commit is contained in:
Xilmi 2024-09-05 16:34:42 +02:00
parent 044dc272c2
commit 20cfe712c9

View File

@ -148,19 +148,19 @@ public:
return ret;
}
//Returns how many items of "this" we can afford with provided income
int maxPurchasableCount(const ResourceSet& income) {
//Returns how many items of "this" we can afford with provided funds
int maxPurchasableCount(const ResourceSet& availableFunds) {
int ret = 0; // Initialize to 0 because we want the maximum number of accumulations
for (size_t i = 0; i < container.size(); ++i) {
if (container.at(i) > 0) { // We only care about fulfilling positive needs
if (income[i] == 0) {
if (availableFunds[i] == 0) {
// If income is 0 and we need a positive amount, it's impossible to fulfill
return INT_MAX;
}
else {
// Calculate the number of times we need to accumulate income to fulfill the need
int ceiledResult = vstd::divideAndCeil(container.at(i), income[i]);
int ceiledResult = vstd::divideAndCeil(container.at(i), availableFunds[i]);
ret = std::max(ret, ceiledResult);
}
}