Skip to content

Commit d0683a7

Browse files
authored
Update to v0.2.2 (#9)
2 parents 20aad6b + 45aceca commit d0683a7

File tree

7 files changed

+35
-7
lines changed

7 files changed

+35
-7
lines changed

build.gradle.kts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
2+
13
plugins {
24
kotlin("jvm") version "2.0.0"
35

@@ -10,7 +12,7 @@ plugins {
1012
val jvm = JavaVersion.VERSION_11
1113

1214
group = "xyz.calcugames"
13-
version = "0.2.1-SNAPSHOT"
15+
version = "0.2.2-SNAPSHOT"
1416

1517
java {
1618
sourceCompatibility = jvm
@@ -40,8 +42,8 @@ tasks {
4042
}
4143

4244
compileKotlin {
43-
kotlinOptions {
44-
jvmTarget = jvm.toString()
45+
compilerOptions {
46+
jvmTarget.set(JvmTarget.JVM_11)
4547
}
4648
}
4749

gradle/wrapper/gradle-wrapper.jar

-9 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

src/main/java/xyz/calcugames/levelz/Keywords.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,13 @@ public interface Keywords {
2525
*/
2626
String DEFAULT_COORDINATE_3D = "[0, 0, 0]";
2727

28+
/**
29+
* The beginning of a comment.
30+
*/
31+
char COMMENT_CHAR = '#';
32+
33+
/**
34+
* The beginning of a comment.
35+
*/
36+
String COMMENT = "#";
2837
}

src/main/java/xyz/calcugames/levelz/parser/InternalParser.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,19 @@ static Level parse(String[] file, Random seed) {
256256

257257
Set<LevelObject> blocks = new HashSet<>();
258258
for (String line : split[1]) {
259+
if (line.startsWith(Keywords.COMMENT)) continue;
259260
if (line.equalsIgnoreCase(Keywords.END)) break;
260261

262+
int ci = line.indexOf(Keywords.COMMENT_CHAR);
263+
String line0 = line.substring(0, ci == -1 ? line.length() : ci).trim();
264+
261265
if (is2D) {
262-
Map<Block, Coordinate2D[]> blocks2D = read2DLine(line, seed);
266+
Map<Block, Coordinate2D[]> blocks2D = read2DLine(line0, seed);
263267
blocks2D.forEach((k, v) -> {
264268
for (Coordinate2D c : v) blocks.add(new LevelObject(k, c));
265269
});
266270
} else {
267-
Map<Block, Coordinate3D[]> blocks3D = read3DLine(line, seed);
271+
Map<Block, Coordinate3D[]> blocks3D = read3DLine(line0, seed);
268272
blocks3D.forEach((k, v) -> {
269273
for (Coordinate3D c : v) blocks.add(new LevelObject(k, c));
270274
});

src/test/java/xyz/calcugames/levelz/parser/TestLevelParser.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ public void testParse() {
3737
Level3D l3 = (Level3D) p3.parse();
3838

3939
Assertions.assertEquals(l3.getSpawn(), new Coordinate3D(0, 0, 0));
40+
41+
InputStream f4 = TestLevelParser.class.getResourceAsStream("/examples/2D/volcano/4.lvlz");
42+
LevelParser p4 = builder.input(f4).build();
43+
Level2D l4 = (Level2D) p4.parse();
44+
45+
Assertions.assertEquals(l4.getScroll(), Scroll.NONE);
46+
Assertions.assertEquals(l4.getSpawn(), new Coordinate2D(5, 1));
47+
48+
InputStream f5 = TestLevelParser.class.getResourceAsStream("/examples/3D/grasslands/3.lvlz");
49+
LevelParser p5 = builder.input(f5).build();
50+
Level3D l5 = (Level3D) p5.parse();
51+
52+
Assertions.assertEquals(l5.getSpawn(), new Coordinate3D(0, 10, 0));
4053
}
4154

4255
}

0 commit comments

Comments
 (0)