Skip to content

Update to v0.2.2 #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import org.jetbrains.kotlin.gradle.dsl.JvmTarget

plugins {
kotlin("jvm") version "2.0.0"

Expand All @@ -10,7 +12,7 @@ plugins {
val jvm = JavaVersion.VERSION_11

group = "xyz.calcugames"
version = "0.2.1-SNAPSHOT"
version = "0.2.2-SNAPSHOT"

java {
sourceCompatibility = jvm
Expand Down Expand Up @@ -40,8 +42,8 @@ tasks {
}

compileKotlin {
kotlinOptions {
jvmTarget = jvm.toString()
compilerOptions {
jvmTarget.set(JvmTarget.JVM_11)
}
}

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/xyz/calcugames/levelz/Keywords.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,13 @@ public interface Keywords {
*/
String DEFAULT_COORDINATE_3D = "[0, 0, 0]";

/**
* The beginning of a comment.
*/
char COMMENT_CHAR = '#';

/**
* The beginning of a comment.
*/
String COMMENT = "#";
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,19 @@ static Level parse(String[] file, Random seed) {

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

int ci = line.indexOf(Keywords.COMMENT_CHAR);
String line0 = line.substring(0, ci == -1 ? line.length() : ci).trim();

if (is2D) {
Map<Block, Coordinate2D[]> blocks2D = read2DLine(line, seed);
Map<Block, Coordinate2D[]> blocks2D = read2DLine(line0, seed);
blocks2D.forEach((k, v) -> {
for (Coordinate2D c : v) blocks.add(new LevelObject(k, c));
});
} else {
Map<Block, Coordinate3D[]> blocks3D = read3DLine(line, seed);
Map<Block, Coordinate3D[]> blocks3D = read3DLine(line0, seed);
blocks3D.forEach((k, v) -> {
for (Coordinate3D c : v) blocks.add(new LevelObject(k, c));
});
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/xyz/calcugames/levelz/parser/TestLevelParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,19 @@ public void testParse() {
Level3D l3 = (Level3D) p3.parse();

Assertions.assertEquals(l3.getSpawn(), new Coordinate3D(0, 0, 0));

InputStream f4 = TestLevelParser.class.getResourceAsStream("/examples/2D/volcano/4.lvlz");
LevelParser p4 = builder.input(f4).build();
Level2D l4 = (Level2D) p4.parse();

Assertions.assertEquals(l4.getScroll(), Scroll.NONE);
Assertions.assertEquals(l4.getSpawn(), new Coordinate2D(5, 1));

InputStream f5 = TestLevelParser.class.getResourceAsStream("/examples/3D/grasslands/3.lvlz");
LevelParser p5 = builder.input(f5).build();
Level3D l5 = (Level3D) p5.parse();

Assertions.assertEquals(l5.getSpawn(), new Coordinate3D(0, 10, 0));
}

}
2 changes: 1 addition & 1 deletion src/test/resources/examples
Loading