contract AnimecardPricing is AnimecardBase {

    /*** CONSTANTS ***/
    // Pricing steps.
    uint256 private constant first_step_limit = 0.05 ether;
    uint256 private constant second_step_limit = 0.5 ether;
    uint256 private constant third_step_limit = 2.0 ether;
    uint256 private constant fourth_step_limit = 5.0 ether;


    // Cut for studio & platform for each sale transaction
    uint256 public platformFee = 50; // 50%

    /// @dev Set Studio Fee. Can only be called by the Animator address. 
    function setPlatformFee(uint256 _val) external onlyAnimator {
        platformFee = _val;
    }

    /// @dev Computes next price of token given the current sale price.
    function computeNextPrice(uint256 _salePrice)
    internal
    pure
    returns(uint256) {
        if (_salePrice < first_step_limit) {
            return SafeMath.div(SafeMath.mul(_salePrice, 200), 100);
        } else if (_salePrice < second_step_limit) {
            return SafeMath.div(SafeMath.mul(_salePrice, 135), 100);
        } else if (_salePrice < third_step_limit) {
            return SafeMath.div(SafeMath.mul(_salePrice, 125), 100);
        } else if (_salePrice < fourth_step_limit) {
            return SafeMath.div(SafeMath.mul(_salePrice, 120), 100);
        } else {
            return SafeMath.div(SafeMath.mul(_salePrice, 115), 100);
        }
    }

    /// @dev Computes the payment for the token, which is the sale price of the token
    /// minus the house's cut.
    function computePayment(
        uint256 _tokenId,
        uint256 _salePrice)
    internal
    view
    returns(uint256) {
        uint256 prevSalePrice = animecardPrevPrice[_tokenId];

        uint256 profit = _salePrice - prevSalePrice;

        uint256 ownerCut = SafeMath.sub(100, platformFee);
        uint256 ownerProfitShare = SafeMath.div(SafeMath.mul(profit, ownerCut), 100);

        return prevSalePrice + ownerProfitShare;
    }
}
function computePayment(
    uint256 _tokenId,
    uint256 _salePrice)
internal
view
returns(uint256) {
    uint256 prevSalePrice = animecardPrevPrice[_tokenId];

    uint256 profit = _salePrice - prevSalePrice;

    uint256 ownerCut = SafeMath.sub(100, platformFee);
    uint256 ownerProfitShare = SafeMath.div(SafeMath.mul(profit, ownerCut), 100);

    return prevSalePrice + ownerProfitShare;
}

/// @dev Computes the payment for the token, which is the sale price of the token
/// minus the house's cut.