//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/access/Ownable.sol";

contract BitForestGames is Ownable {
    uint tokenPrice;
    uint exchangeRate;

    constructor() {
        tokenPrice = 0.0005 ether;
        exchangeRate = 1 * tokenPrice;
    }

    function changeTokenPrice(uint256 _tokenPrice) public onlyOwner {
        tokenPrice = _tokenPrice;
        exchangeRate = 1 * tokenPrice;
    }

    event PurchaseTokens(uint256 amountOfTokensPurchased);

    function purchaseTokens(uint256 amount) public payable {
        require(msg.value == amount * tokenPrice, "Inusffucient payment");

        emit PurchaseTokens(amount);
    }

    function swapTokensForEth(address[] calldata clients, uint256[] calldata amounts) public onlyOwner {
        for (uint i = 0; i < clients.length; i++) {
            uint amountInEth = amounts[i] * exchangeRate / 100 ;
            (bool success, ) = clients[i].call{ value: amountInEth }("");
            require(success, "Exchange failed");
        }
    }

    function getContractBalanceEth() public view returns (uint256) {
        return address(this).balance;
    }

    receive() external payable {}
}
[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amountOfTokensPurchased","type":"uint256"}],"name":"PurchaseTokens","type":"event"},{"inputs":[{"internalType":"uint256","name":"_tokenPrice","type":"uint256"}],"name":"changeTokenPrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getContractBalanceEth","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"purchaseTokens","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"clients","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"}],"name":"swapTokensForEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]