1
0
forked from mico/idle_moloch

Balances how much units cost and profit

This commit is contained in:
mic0 2024-10-26 14:45:25 +02:00
parent 26b2480b52
commit 0ea4ba320c
Signed by: mico
GPG Key ID: A3F8023524CF1C8D
4 changed files with 25 additions and 12 deletions

View File

@ -5,18 +5,31 @@ 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 MOLOCH_DENIER_PROFIT = 10000;
uint256 constant APPRENTICE_PROFIT = 61000;
uint256 constant ANOINTED_PROFIT = 6 * 64000;
uint256 constant CHAMPION_PROFIT = 36 * 67000;
// base price * (0.00666) * 11 per each next unit
uint256 constant MOLOCH_DENIER_PROFIT = 2533;
uint256 constant APPRENTICE_PROFIT = 27863;
uint256 constant ANOINTED_PROFIT = 306493;
uint256 constant CHAMPION_PROFIT = 3371423;
// each costs 10 times plus a bit more
uint256 constant MOLOCH_DENIER_BASE_COST = 380000;
uint256 constant APPRENTICE_BASE_COST = 3420000;
uint256 constant ANOINTED_BASE_COST = 30096000;
uint256 constant CHAMPION_BASE_COST = 255816000;
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 rollingPriceCalculation = MOLOCH_DENIER_BASE_COST;
uint256 price = 0;
if (unit == 1) {
rollingPriceCalculation = APPRENTICE_BASE_COST;
} else if (unit == 2) {
rollingPriceCalculation = ANOINTED_BASE_COST;
} else if (unit == 3) {
rollingPriceCalculation = CHAMPION_BASE_COST;
}
// Each level costs 15% more than previous
for (uint256 i = 0; i < currentLevel + units; i++) {

View File

@ -9,7 +9,7 @@ contract raid_geldTest is Test {
function test_0_unit_price() public pure {
// buying 1 unit of moloch_denier
uint256 basePriceMolochDenier = RaidGeldUtils.calculateUnitPrice(0, 0, 1);
assertEq(basePriceMolochDenier, RaidGeldUtils.BASE_PRICE);
assertEq(basePriceMolochDenier, RaidGeldUtils.MOLOCH_DENIER_BASE_COST);
// buying 3 units
// has to be a bit more than 3 * 38 = 114
@ -37,7 +37,7 @@ contract raid_geldTest is Test {
profit_per_second: 0 // irrelevant for this test
});
uint256 profits_per_second = RaidGeldUtils.calculateProfitsPerSecond(army);
assertEq(profits_per_second, RaidGeldUtils.PRECISION);
assertEq(profits_per_second, RaidGeldUtils.MOLOCH_DENIER_PROFIT);
army = Army({
moloch_denier: Raider({level: _dLvl}),
@ -47,7 +47,7 @@ contract raid_geldTest is Test {
profit_per_second: 0 // irrelevant for this test
});
profits_per_second = RaidGeldUtils.calculateProfitsPerSecond(army);
uint256 expected = _dLvl * RaidGeldUtils.PRECISION + _apLvl * RaidGeldUtils.APPRENTICE_PROFIT
uint256 expected = _dLvl * RaidGeldUtils.MOLOCH_DENIER_PROFIT + _apLvl * RaidGeldUtils.APPRENTICE_PROFIT
+ _anLvl * RaidGeldUtils.ANOINTED_PROFIT + _cLvl * RaidGeldUtils.CHAMPION_PROFIT;
assertEq(profits_per_second, expected);
}