All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.skillw.pouvoir.api.feature.operation.NumberOperation.kt Maven / Gradle / Ivy

There is a newer version: 1.6.7-beta-6
Show newest version
package com.skillw.pouvoir.api.feature.operation

import com.skillw.pouvoir.Pouvoir.operationManager

/**
 * Base operation
 *
 * @constructor Create empty Base operation
 * @property key 运算操作键
 */
abstract class NumberOperation(override val key: String, vararg val alias: String) : Operation {
    abstract override fun operate(a: Number, b: Number): Number

    override var release: Boolean = false

    /**
     * 构成运算元素 (可以理解成 运算符 + 数)
     *
     * @param number
     * @return 运算元素
     */
    fun element(number: Number): OperationElement = OperationElement(this, number)

    override fun register() {
        arrayOf(key, *alias).forEach {
            operationManager.register(it, this)
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy