package com.pixelized.shared.lwa.parser.expression

import com.pixelized.shared.lwa.parser.dice.Dice
import com.pixelized.shared.lwa.parser.word.Word

sealed interface Expression {

    data class Add(
        val first: Expression?,
        val second: Expression?,
    ) : Expression {
        override fun toString(): String {
            return "($first+$second)"
        }
    }

    data class Minus(
        val first: Expression?,
        val second: Expression?,
    ) : Expression {
        override fun toString(): String {
            return "($first-$second)"
        }
    }

    data class Div(
        val first: Expression?,
        val second: Expression?,
    ) : Expression {
        override fun toString(): String {
            return "($first/$second)"
        }
    }

    data class Prod(
        val first: Expression?,
        val second: Expression?,
    ) : Expression {
        override fun toString(): String {
            return "($first*$second)"
        }
    }

    data class Minimum(
        val first: Expression?,
        val second: Expression?,
    ) : Expression {
        override fun toString(): String {
            return "min($first,$second)"
        }
    }

    data class Maximum(
        val first: Expression?,
        val second: Expression?,
    ) : Expression {
        override fun toString(): String {
            return "max($first,$second)"
        }
    }

    data class Floor5(
        val expression: Expression?,
    ) : Expression {
        override fun toString(): String {
            return "floor5($expression)"
        }
    }

    data class Inversion(
        val expression: Expression,
    ) : Expression {
        override fun toString(): String {
            return "-($expression)"
        }
    }

    data class UrlExpression(
        val url: String,
    ) : Expression {
        override fun toString(): String {
            return url
        }
    }

    data class DiceExpression(
        val dice: Dice,
    ) : Expression {
        override fun toString(): String {
            return dice.toString()
        }
    }

    data class WordExpression(
        val word: Word,
    ) : Expression {
        override fun toString(): String {
            return word.toString()
        }
    }

    data class Flat(
        val value: Int,
    ) : Expression {
        override fun toString(): String {
            return "$value"
        }
    }
}