// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {Army} from "../src/RaidGeld.sol"; library RaidGeldUtils { function calculateUnitPrice(uint8 unit, uint16 currentLevel, uint16 units) internal pure returns (uint256) { require(unit <= 3, "No matching unit found"); uint256 rollingPriceCalculation = uint256(unit + 1) * 38; uint256 price = rollingPriceCalculation; // Each level costs 15% more than previous uint256 PERCENT_INCREASE = 115; for (uint256 i = 1; i < currentLevel + units; i++) { rollingPriceCalculation = rollingPriceCalculation * PERCENT_INCREASE / 100; if (i >= currentLevel) { price += rollingPriceCalculation; } } return price; } function calculateProfitsPerSecond(Army memory army) internal pure returns (uint256) { // Each next unit scales progressivelly better uint256 moloch_denier_profit = army.moloch_denier.level; uint256 apprentice_profit = army.apprentice.level * 61 / 10; uint256 anointed_profit = army.anointed.level * 6 * 64 / 10; uint256 champion_profit = army.champion.level * 61 / 10 * 64 / 10 * 67 / 10; return moloch_denier_profit + apprentice_profit + anointed_profit + champion_profit; } }