mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	Update ResourceSet.h
Rename income to availableFunds
This commit is contained in:
		| @@ -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); | ||||
| 				} | ||||
| 			} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user