// File: src/TheSpread.sol



// SPDX-License-Identifier: MIT
pragma solidity >=0.8.19;

interface IConcord {
    function burn(address _from, uint256 _token, uint256 _quantity) external;
}

contract TheSpread {
    event InfectionSpread(address indexed sender, uint256 indexed infectedToken, uint256 time);

    address public concordAddress;
    uint256 public infectionPrice = 0.01 ether;

    address public constant WAGDIE = 0x8d2Eb1c6Ab5D87C5091f09fFE4a5ed31B1D9CF71;

    constructor(address _concordAddress) {
        concordAddress = _concordAddress;
    }

    function spreadInfections(uint256 quantity) external {
        // Burn the mushrooms
        IConcord(concordAddress).burn(msg.sender, 15, quantity);
        // Emit infection events
        for (uint256 i = 0; i < quantity; i++) {
            emit InfectionSpread(msg.sender, random(6666), block.timestamp);
        }
    }

    function infectWagdie(uint256 tokenId) external payable {
        require(tokenId > 0, "Invalid token");
        require(msg.value == infectionPrice, "More sacrifice required");
        // Sweep payment
        // solhint-disable-next-line no-unused-vars
        (bool sent, bytes memory data) = WAGDIE.call{ value: msg.value }("");
        require(sent, "Failed to send Ether");
        // Increase price for next infection
        infectionPrice = infectionPrice + 0.0025 ether;
        // Burn Concord
        IConcord(concordAddress).burn(msg.sender, 15, 1);
        // Emit infection
        emit InfectionSpread(msg.sender, tokenId, block.timestamp);
    }

    // Basic Random Function
    function random(uint256 num) private view returns (uint256) {
        return uint256(keccak256(abi.encodePacked(block.timestamp, block.difficulty, msg.sender))) % num;
    }
}