Skip to content

Commit c543af0

Browse files
committed
Logic 7 version
1 parent bc3c1d7 commit c543af0

File tree

2 files changed

+30
-16
lines changed

2 files changed

+30
-16
lines changed

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ allprojects{
3434

3535
dependencies{
3636
compileOnly "com.github.Anuken.Arc:arc-core:$mindustryVersion"
37-
// compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
38-
compileOnly 'com.github.Anuken:MindustryJitpack:1470d3d32f'
37+
compileOnly "com.github.Anuken.Mindustry:core:$mindustryVersion"
38+
// compileOnly 'com.github.Anuken:MindustryJitpack:1470d3d32f'
3939

4040
annotationProcessor "com.github.Anuken:jabel:$jabelVersion"
4141
}
Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
package cardillan.mlogassertions.logic;
22

33
import mindustry.logic.LExecutor;
4-
import mindustry.logic.LVar;
4+
import mindustry.logic.LExecutor.Var;
55

66
public class AssertsLInstructions {
77

88
public static class AssertI implements LExecutor.LInstruction {
9-
public TypeAssertion type;
10-
public LVar min;
11-
public AssertOp opMin;
12-
public LVar value;
13-
public AssertOp opMax;
14-
public LVar max;
15-
public LVar message;
16-
17-
public AssertI(TypeAssertion type, LVar min, AssertOp opMin, LVar value, AssertOp opMax, LVar max, LVar message) {
9+
public TypeAssertion type = TypeAssertion.any;
10+
public int min;
11+
public AssertOp opMin = AssertOp.lessThanEq;
12+
public int value;
13+
public AssertOp opMax = AssertOp.lessThanEq;
14+
public int max;
15+
public int message;
16+
17+
public AssertI(TypeAssertion type, int min, AssertOp opMin, int value, AssertOp opMax, int max, int message) {
1818
this.type = type;
1919
this.min = min;
2020
this.opMin = opMin;
@@ -24,18 +24,32 @@ public AssertI(TypeAssertion type, LVar min, AssertOp opMin, LVar value, AssertO
2424
this.message = message;
2525
}
2626

27+
public AssertI() {
28+
}
29+
2730
@Override
2831
public final void run(LExecutor exec) {
29-
boolean typeAssert = value.isobj ? type.objFunction.get(value.objval) : type.function.get(value.numval);
30-
boolean minAssert = opMin.function.get(min.num(), value.num());
31-
boolean maxAssert = opMax.function.get(value.num(), max.num());
32+
Var vaVal = var(exec, value);
33+
boolean typeAssert = vaVal.isobj ? type.objFunction.get(vaVal.objval) : type.function.get(vaVal.numval);
34+
boolean minAssert = opMin.function.get(num(exec,min), num(exec,value));
35+
boolean maxAssert = opMax.function.get(num(exec,value), num(exec,max));
3236

3337
if (!typeAssert || !minAssert || !maxAssert) {
3438
//skip back to self.
3539
// TODO enter broken assertion state
3640
exec.counter.numval--;
37-
exec.yield = true;
41+
//exec.yield = true;
3842
}
3943
}
44+
45+
// For easier switching between v7 and v8 logic
46+
47+
private Var var(LExecutor exec, int var) {
48+
return exec.var(value);
49+
}
50+
51+
private double num(LExecutor exec, int var) {
52+
return exec.num(var);
53+
}
4054
}
4155
}

0 commit comments

Comments
 (0)