contract ChronosBase is ChronosAccessControl {
    using SafeMath for uint256;
 
    /// @notice Boolean indicating whether a game is live.
    bool public gameStarted;
    
    /// @notice The player who started the game.
    address public gameStarter;
    
    /// @notice The last player to have entered.
    address public lastPlayer;
    
    /// @notice The timestamp the last wager times out.
    uint256 public lastWagerTimeoutTimestamp;

    /// @notice The number of seconds before the game ends.
    uint256 public timeout;
    
    /// @notice The number of seconds before the game ends -- setting
    /// for the next game.
    uint256 public nextTimeout;
    
    /// @notice The minimum number of seconds before the game ends.
    uint256 public minimumTimeout;
    
    /// @notice The minmum number of seconds before the game ends --
    /// setting for the next game.
    uint256 public nextMinimumTimeout;
    
    /// @notice The number of wagers required to move to the
    /// minimum timeout.
    uint256 public numberOfWagersToMinimumTimeout;
    
    /// @notice The number of wagers required to move to the
    /// minimum timeout -- setting for the next game.
    uint256 public nextNumberOfWagersToMinimumTimeout;
    
    /// @notice The wager index of the the current wager in the game.
    uint256 public wagerIndex = 0;
    
    /// @notice Calculate the current game's timeout.
    function calculateTimeout() public view returns(uint256) {
        if (wagerIndex >= numberOfWagersToMinimumTimeout || numberOfWagersToMinimumTimeout == 0) {
            return minimumTimeout;
        } else {
            // This cannot underflow, as timeout is guaranteed to be
            // greater than or equal to minimumTimeout.
            uint256 difference = timeout - minimumTimeout;
            
            // Calculate the decrease in timeout, based on the number of wagers performed.
            uint256 decrease = difference.mul(wagerIndex).div(numberOfWagersToMinimumTimeout);
            
            // This subtraction cannot underflow, as decrease is guaranteed to be less than or equal to timeout.            
            return (timeout - decrease);
        }
    }
}
/// @dev Defines base data structures for Chronos.
function calculateTimeout() public view returns(uint256) {
    if (wagerIndex >= numberOfWagersToMinimumTimeout || numberOfWagersToMinimumTimeout == 0) {
        return minimumTimeout;
    } else {
        // This cannot underflow, as timeout is guaranteed to be
        // greater than or equal to minimumTimeout.
        uint256 difference = timeout - minimumTimeout;
            
        // Calculate the decrease in timeout, based on the number of wagers performed.
        uint256 decrease = difference.mul(wagerIndex).div(numberOfWagersToMinimumTimeout);
            
        // This subtraction cannot underflow, as decrease is guaranteed to be less than or equal to timeout.            
        return (timeout - decrease);
    }
}

/// @notice Calculate the current game's timeout.