// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {Test, console} from "forge-std/Test.sol";
import {Army, Raider} from "../src/RaidGeldStructs.sol";
import "../src/RaidGeldUtils.sol";

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.MOLOCH_DENIER_BASE_COST);

        // buying 3 units
        // has to be a bit more than 3 * 38 = 114
        uint256 price = RaidGeldUtils.calculateUnitPrice(0, 0, 3);
        assertGt(price, 3 * basePriceMolochDenier);

        uint256 basePriceChamp = RaidGeldUtils.calculateUnitPrice(0, 0, 3);
        // buying 3 units of champions
        // has to be a bit more than 4 * 38 * 3 = 114
        price = RaidGeldUtils.calculateUnitPrice(3, 0, 3);
        assertGt(price, 3 * basePriceChamp);

        // buying 12 units of champions when u already have 10
        price = RaidGeldUtils.calculateUnitPrice(3, 10, 12);
        // price should scale up
        assertGt(price, basePriceChamp * 12);
    }

    function test_1_profits_per_second(uint16 _dLvl, uint16 _apLvl, uint16 _anLvl, uint16 _cLvl) public pure {
        Army memory army = Army({
            moloch_denier: Raider({level: 1}),
            apprentice: Raider({level: 0}),
            anointed: Raider({level: 0}),
            champion: Raider({level: 0}),
            profit_per_second: 0 // irrelevant for this test
        });
        uint256 profits_per_second = RaidGeldUtils.calculateProfitsPerSecond(army);
        assertEq(profits_per_second, RaidGeldUtils.MOLOCH_DENIER_PROFIT);

        army = Army({
            moloch_denier: Raider({level: _dLvl}),
            apprentice: Raider({level: _apLvl}),
            anointed: Raider({level: _anLvl}),
            champion: Raider({level: _cLvl}),
            profit_per_second: 0 // irrelevant for this test
        });
        profits_per_second = RaidGeldUtils.calculateProfitsPerSecond(army);
        uint256 expected = _dLvl * RaidGeldUtils.MOLOCH_DENIER_PROFIT + _apLvl * RaidGeldUtils.APPRENTICE_PROFIT
            + _anLvl * RaidGeldUtils.ANOINTED_PROFIT + _cLvl * RaidGeldUtils.CHAMPION_PROFIT;
        assertEq(profits_per_second, expected);
    }
}
