// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; import {Army} from "../src/RaidGeldStructs.sol"; library RaidGeldUtils { uint256 public constant PRECISION = 10000; uint256 constant BASE_PRICE = 380000; uint256 constant PRICE_FACTOR = 11500; uint256 constant APPRENTICE_PROFIT = 61000; uint256 constant ANOINTED_PROFIT = 6 * 64000; uint256 constant CHAMPION_PROFIT = 67000 * 61000 * 64000/ PRECISION / PRECISION; function calculateUnitPrice(uint8 unit, uint16 currentLevel, uint16 units) internal pure returns (uint256) { require(unit <= 3, "No matching unit found"); uint256 rollingPriceCalculation = uint256(unit + 1) * BASE_PRICE; uint256 price = rollingPriceCalculation; // Each level costs 15% more than previous for (uint256 i = 1; i < currentLevel + units; i++) { rollingPriceCalculation = rollingPriceCalculation * PRICE_FACTOR / PRECISION; 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 * PRECISION; uint256 apprentice_profit = army.apprentice.level * APPRENTICE_PROFIT; uint256 anointed_profit = army.anointed.level * ANOINTED_PROFIT; uint256 champion_profit = army.champion.level * CHAMPION_PROFIT; return moloch_denier_profit + apprentice_profit + anointed_profit + champion_profit; } }