package de.peeeq.wurstio.jassinterpreter.providers;

import de.peeeq.wurstscript.intermediatelang.ILconstInt;
import de.peeeq.wurstscript.intermediatelang.ILconstReal;
import de.peeeq.wurstscript.intermediatelang.interpreter.AbstractInterpreter;
import de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter;

import java.util.Random;

public class MathProvider extends Provider {
    private Random r = new Random();

    public MathProvider(AbstractInterpreter interpreter) {
        super(interpreter);
    }

    public ILconstReal SquareRoot(ILconstReal r) {
        return new ILconstReal(Math.sqrt(r.getVal()));
    }

    public ILconstReal Pow(ILconstReal x, ILconstReal power) {
        return new ILconstReal(Math.pow(x.getVal(), power.getVal()));
    }

    public ILconstReal Sin(ILconstReal r) {
        return new ILconstReal(Math.sin(r.getVal()));
    }

    public ILconstReal Cos(ILconstReal r) {
        return new ILconstReal(Math.cos(r.getVal()));
    }

    public ILconstReal Tan(ILconstReal r) {
        return new ILconstReal(Math.tan(r.getVal()));
    }

    public ILconstReal ATan(ILconstReal r) {
        return new ILconstReal(Math.atan(r.getVal()));
    }

    public ILconstReal Atan2(ILconstReal y, ILconstReal x) {
        return new ILconstReal(Math.atan2(y.getVal(), x.getVal()));
    }

    public ILconstReal GetRandomReal(ILconstReal a, ILconstReal b) {
        return new ILconstReal(a.getVal() + r.nextFloat() * (b.getVal() - a.getVal()));
    }

    public ILconstInt GetRandomInt(ILconstInt a, ILconstInt b) {
        return new ILconstInt(a.getVal() + r.nextInt(1 + b.getVal() - a.getVal()));
    }

    public ILconstInt ModuloInteger(ILconstInt a, ILconstInt b) {
        return new ILconstInt(a.getVal() % b.getVal());
    }

    public ILconstReal ModuloReal(ILconstReal a, ILconstReal b) {
        return new ILconstReal(a.getVal() % b.getVal());
    }
}

@@ -242,80 +242,8 @@
 ter;
-%0Aimport de.peeeq.wurstscript.intermediatelang.interpreter.ILInterpreter;
 %0A%0Aim
@@ -828,65 +828,279 @@
 eal 
-Cos(ILconstReal r) %7B%0A        return new ILconstReal(Math.
+Asin(ILconstReal r) %7B%0A        return new ILconstReal(Math.asin(r.getVal()));%0A    %7D%0A%0A    public ILconstReal Cos(ILconstReal r) %7B%0A        return new ILconstReal(Math.cos(r.getVal()));%0A    %7D%0A%0A    public ILconstReal Acos(ILconstReal r) %7B%0A        return new ILconstReal(Math.a
 cos(
@@ -1249,17 +1249,17 @@
 stReal A
-T
+t
 an(ILcon

add Asin, Acos and Atan for compiletime