com.skillw.asahi.internal.namespacing.prefix.lang.math.Calculate.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Pouvoir Show documentation
Show all versions of Pouvoir Show documentation
Bukkit Script Engine Plugin.
package com.skillw.asahi.internal.namespacing.prefix.lang.math
import com.skillw.asahi.api.AsahiAPI.analysis
import com.skillw.asahi.api.annotation.AsahiPrefix
import com.skillw.asahi.api.prefixParser
import com.skillw.asahi.api.quest
import com.skillw.asahi.api.quester
import com.skillw.pouvoir.util.calculate.CalcOperator.Companion.toCalcOperator
/**
* @className Calculate
*
* @author Glom
* @date 2023/1/14 0:31 Copyright 2024 Glom.
*/
@AsahiPrefix(["calculate", "calc"], "lang")
private fun calculate() = prefixParser {
val formulaGetter = quest()
result {
val formula = formulaGetter.get().analysis(this, *namespaceNames())
com.skillw.pouvoir.util.calculate(formula)
}
}
@AsahiPrefix(["math"], "lang")
private fun math() = prefixParser {
val numA = questDouble()
val operator = questString().quester { it.first() }
val numB = questDouble()
result {
operator.get().toCalcOperator().calc(numB.get(), numA.get())
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy