Winning and losing views && Update Gradle and Kotlin

This commit is contained in:
nelle 2023-10-28 14:24:38 -06:00
parent 886571f2da
commit 7294110d34
7 changed files with 102 additions and 11 deletions

View file

@ -5,10 +5,12 @@ val slf4j_version: String by project
val junit_version: String by project val junit_version: String by project
val mockito_version: String by project val mockito_version: String by project
val assertj_version: String by project val assertj_version: String by project
val game_name: String by project
val version: String by project
plugins { plugins {
kotlin("jvm") version "1.4.10" kotlin("jvm") version "1.9.10"
id("com.github.johnrengelman.shadow") version "5.2.0" id("com.github.johnrengelman.shadow") version "8.1.1"
} }
repositories { repositories {
@ -18,8 +20,8 @@ repositories {
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_11 sourceCompatibility = JavaVersion.VERSION_20
targetCompatibility = JavaVersion.VERSION_11 targetCompatibility = JavaVersion.VERSION_20
} }
dependencies { dependencies {
@ -38,10 +40,10 @@ dependencies {
tasks { tasks {
named<ShadowJar>("shadowJar") { named<ShadowJar>("shadowJar") {
archiveBaseName.set("potroge") archiveBaseName.set("$game_name + $version")
mergeServiceFiles() mergeServiceFiles()
manifest { manifest {
attributes(mapOf("Main-Class" to "com.example.MainKt")) attributes(mapOf("Main-Class" to "group.ouroboros.potrogue.MainKt"))
} }
} }
} }
@ -54,7 +56,7 @@ tasks {
val jar by tasks.getting(Jar::class) { val jar by tasks.getting(Jar::class) {
manifest { manifest {
attributes["Main-Class"] = "com.example.MainKt" attributes["Main-Class"] = "group.ouroboros.potrogue.MainKt"
} }
} }

View file

@ -10,4 +10,5 @@ assertj_version=3.6.2
slf4j_version=1.7.25 slf4j_version=1.7.25
group=group.ouroboros.potrogue group=group.ouroboros.potrogue
game_name=potrogue
version=0.1.0-DEV version=0.1.0-DEV

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View file

@ -0,0 +1,42 @@
package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GAME_THEME
import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ComponentAlignment
import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView
import kotlin.system.exitProcess
class LoseView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
init {
val header = Components.header()
.withText("Game Over")
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
.build()
val restartButton = Components.button()
.withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT)
.withText("Restart")
.withDecorations(box())
.build()
val exitButton = Components.button()
.withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT)
.withText("Quit")
.withDecorations(box())
.build()
restartButton.onActivated {
replaceWith(PlayView(grid))
}
exitButton.onActivated {
exitProcess(0)
}
screen.addComponents(header, restartButton, exitButton)
}
}

View file

@ -1,6 +1,6 @@
package group.ouroboros.potrogue.view package group.ouroboros.potrogue.view
import org.hexworks.zircon.api.ColorThemes import group.ouroboros.potrogue.GAME_THEME
import org.hexworks.zircon.api.ComponentDecorations.box import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.ComponentDecorations.shadow import org.hexworks.zircon.api.ComponentDecorations.shadow
import org.hexworks.zircon.api.Components import org.hexworks.zircon.api.Components
@ -9,7 +9,7 @@ import org.hexworks.zircon.api.component.ComponentAlignment.RIGHT_CENTER
import org.hexworks.zircon.api.grid.TileGrid import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView import org.hexworks.zircon.api.view.base.BaseView
class PlayView (private val grid: TileGrid) : BaseView(grid, ColorThemes.arc()) { class PlayView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
init { init {
val loseButton = Components.button() val loseButton = Components.button()
// constants like LEFT_CENTER can also be imported for brevity // constants like LEFT_CENTER can also be imported for brevity
@ -24,6 +24,9 @@ class PlayView (private val grid: TileGrid) : BaseView(grid, ColorThemes.arc())
.withDecorations(box(), shadow()) .withDecorations(box(), shadow())
.build() .build()
winButton.onActivated { replaceWith(WinView(grid)) }
loseButton.onActivated { replaceWith(LoseView(grid)) }
// multiple components can be added once // multiple components can be added once
screen.addComponents(loseButton, winButton) screen.addComponents(loseButton, winButton)
} }

View file

@ -39,7 +39,7 @@ class StartView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
//TODO //TODO
//move this on to a configuration screen for world/player customization before PlayView, for now basic gameplay is in order though. //move this on to a configuration screen for world/player customization before PlayView, for now basic gameplay is in order though.
// Once the start button is pressed, move on to the PlayView //Once the start button is pressed, move on to the PlayView
startButton.onActivated { startButton.onActivated {
replaceWith(PlayView(grid)) replaceWith(PlayView(grid))
} }

View file

@ -0,0 +1,43 @@
package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GAME_THEME
import org.hexworks.zircon.api.ColorThemes
import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ComponentAlignment
import org.hexworks.zircon.api.grid.TileGrid
import org.hexworks.zircon.api.view.base.BaseView
import kotlin.system.exitProcess
// For if winning.... obviously just a test.
class WinView (private val grid: TileGrid) : BaseView(grid, GAME_THEME) {
init {
val header = Components.header()
.withText("You won!")
.withAlignmentWithin(screen, ComponentAlignment.CENTER)
.build()
val restartButton = Components.button()
.withAlignmentAround(header, ComponentAlignment.BOTTOM_LEFT)
.withText("Restart")
.withDecorations(box())
.build()
val exitButton = Components.button()
.withAlignmentAround(header, ComponentAlignment.BOTTOM_RIGHT)
.withText("Quit")
.withDecorations(box())
.build()
restartButton.onActivated {
replaceWith(PlayView(grid))
}
exitButton.onActivated {
exitProcess(0)
}
screen.addComponents(header, restartButton, exitButton)
}
}