Skip to content
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
10 changes: 9 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ repositories {
}

dependencies {
implementation(project(":game-model"))

implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.0")
implementation("org.jetbrains.kotlinx:kotlinx-collections-immutable:0.4.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
Expand All @@ -35,6 +37,7 @@ dependencies {
testImplementation(kotlin("test"))
testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
testImplementation(project(":game-model"))

runtimeOnly("com.h2database:h2")
}
Expand All @@ -61,7 +64,8 @@ tasks.register<JavaExec>("generateJsDoc") {
classpath = sourceSets["main"].runtimeClasspath
mainClass.set("tools.GenerateJsDocKt")

args("--file", "src/main/kotlin/game/Types.kt")
// Updated path after moving game-model into modules/
args("--file", "modules/game-model/src/commonMain/kotlin/game/CompactTypes.kt")
args("--out", "frontend/generated/types.js")
}

Expand All @@ -72,6 +76,10 @@ tasks.register<JavaExec>("runSpringServer2") {
mainClass.set("server2.SpringAppKt")
}

springBoot {
mainClass.set("server2.SpringAppKt")
}

kotlin {
jvmToolchain(21)
}
55 changes: 55 additions & 0 deletions frontend-kotlin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Kotlin Frontend (Experimental)

This directory contains an experimental Kotlin/JS frontend that demonstrates rendering a list of `CompactCombatEvent` objects using shared Kotlin data types.

## Build & Run

Generate the production bundle and copy it here:

```bash
./gradlew :kjs:copyKotlinFrontend
```

Then open `frontend-kotlin/index.html` in a browser (or serve the directory via a simple HTTP server).

## What It Does

`Main.kt` constructs a small in-memory battle snapshot and a sequence of compact events, renders them as list items, and logs a JSON serialization of the events to the browser console.

## Development / Watch (optional)

For iterative development you can run the Webpack dev server:

```bash
./gradlew :kjs:jsBrowserDevelopmentRun
```

(Then point a browser to the URL it prints; this does not copy into `frontend-kotlin` automatically.)

## Notes

* The module `game-model` contains a minimal subset of game types ported for multiplatform use. In the future you can refactor the main server module to be multiplatform and remove duplication.
* Styling is intentionally minimal.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Season Arena Kotlin Frontend</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style>
body { font-family: system-ui, sans-serif; margin: 2rem; background:#111; color:#eee; }
h1 { font-size: 1.4rem; margin-top:0; }
ul { list-style: none; padding:0; }
li { background:#222; margin:.25rem 0; padding:.5rem .75rem; border-radius:4px; font-size:.9rem; }
.footer { margin-top:2rem; font-size:.75rem; opacity:.6; }
</style>
</head>
<body>
<h1>Season Arena Demo (Kotlin/JS)</h1>
<p>This page renders a sample list of CompactCombatEvent entries using shared Kotlin types.</p>
<div id="kotlin-root"></div>
<div class="footer">Generated by Kotlin/JS. Open the console to inspect serialized JSON output.</div>
<script type="module" src="kjs.js"></script>
</body>
</html>

26 changes: 26 additions & 0 deletions frontend-kotlin/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- ...existing code removed (file was empty)... -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Season Arena Kotlin Frontend</title>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<style>
body { font-family: system-ui, sans-serif; margin: 2rem; background:#111; color:#eee; }
h1 { font-size: 1.4rem; margin-top:0; }
ul { list-style: none; padding:0; }
li { background:#222; margin:.25rem 0; padding:.5rem .75rem; border-radius:4px; font-size:.9rem; }
.footer { margin-top:2rem; font-size:.7rem; opacity:.6; }
.error { color:#f55; }
</style>
</head>
<body>
<h1>Season Arena Demo (Kotlin/JS)</h1>
<p>This page fetches <code>CompactCombatEvent</code> data from <code>/combat/example</code> and lists them. Open the console for raw JSON.</p>
<noscript><div class="error">JavaScript required.</div></noscript>
<div id="kotlin-root">Initializing Kotlin/JS...</div>
<div class="footer">If nothing loads, ensure the backend is running on <code>localhost:8080</code>.</div>
<script type="module" src="kjs.js"></script>
</body>
</html>

2 changes: 2 additions & 0 deletions frontend-kotlin/kjs.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions frontend-kotlin/kjs.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions frontend/generated/kotlin/kjs.js

Large diffs are not rendered by default.

Loading