Config & Refactor

This commit is contained in:
LimePotato 2023-10-29 13:22:39 -06:00
parent 402d39c728
commit b67935513a
24 changed files with 62 additions and 68 deletions

View file

@ -36,10 +36,6 @@ dependencies {
implementation(kotlin("stdlib-jdk8")) implementation(kotlin("stdlib-jdk8"))
testImplementation("junit:junit:$junit_version")
testImplementation("org.mockito:mockito-all:$mockito_version")
testImplementation("org.assertj:assertj-core:$assertj_version")
implementation("org.freedesktop:xdg-java:0.0.1-SNAPSHOT@jar") implementation("org.freedesktop:xdg-java:0.0.1-SNAPSHOT@jar")
implementation("org.assertj:assertj-core:3.6.2") implementation("org.assertj:assertj-core:3.6.2")
} }

View file

@ -1,11 +1,11 @@
package group.ouroboros.potrogue.builders package group.ouroboros.potrogue.builders
import group.ouroboros.potrogue.attributes.EntityPosition import group.ouroboros.potrogue.entity.attributes.EntityPosition
import group.ouroboros.potrogue.attributes.EntityTile import group.ouroboros.potrogue.entity.attributes.EntityTile
import group.ouroboros.potrogue.attributes.types.Player import group.ouroboros.potrogue.entity.attributes.types.Player
import group.ouroboros.potrogue.systems.CameraMover import group.ouroboros.potrogue.entity.systems.CameraMover
import group.ouroboros.potrogue.systems.InputReceiver import group.ouroboros.potrogue.entity.systems.InputReceiver
import group.ouroboros.potrogue.systems.Movable import group.ouroboros.potrogue.entity.systems.Movable
import group.ouroboros.potrogue.world.GameContext import group.ouroboros.potrogue.world.GameContext
import org.hexworks.amethyst.api.builder.EntityBuilder import org.hexworks.amethyst.api.builder.EntityBuilder
import org.hexworks.amethyst.api.entity.EntityType import org.hexworks.amethyst.api.entity.EntityType

View file

@ -1,4 +1,4 @@
package group.ouroboros.potrogue.config package group.ouroboros.potrogue.data.config
import java.io.File import java.io.File
import java.io.FileInputStream import java.io.FileInputStream
@ -9,13 +9,17 @@ import java.nio.file.Path
import java.nio.file.Paths import java.nio.file.Paths
import java.util.* import java.util.*
val file = File("./run/conf.properties")
val prop = Properties()
//init values
public val winW = prop.getProperty("winWidth")
//public val WINDOW_WIDTH = winW.toInt()
class Config { class Config {
var fileExists = file.exists()
init { init {
//Config Stage //Config Stage
val file = File("./run/conf.properties")
val prop = Properties()
var fileExists = file.exists()
if(fileExists){ if(fileExists){
FileInputStream(file).use { prop.load(it) } FileInputStream(file).use { prop.load(it) }
} }
@ -27,7 +31,8 @@ class Config {
FileInputStream(file).use { FileInputStream(file).use {
prop.load(it) prop.load(it)
prop.setProperty("myKey", "myValue") prop.setProperty("winWidth", "80")
prop.setProperty("WINDOW_HEIGHT", "50")
val out: OutputStream = FileOutputStream(file) val out: OutputStream = FileOutputStream(file)
prop.store(out, "some comment") prop.store(out, "some comment")
@ -38,4 +43,6 @@ class Config {
.associateWith {prop.getProperty(it)} .associateWith {prop.getProperty(it)}
.forEach { println(it) } .forEach { println(it) }
} }
val winW = prop.getProperty("winWidth")
} }

View file

@ -1,5 +1,7 @@
package group.ouroboros.potrogue package group.ouroboros.potrogue.data.config
import group.ouroboros.potrogue.GAME_ID
import group.ouroboros.potrogue.GAME_VER
import org.hexworks.zircon.api.CP437TilesetResources import org.hexworks.zircon.api.CP437TilesetResources
import org.hexworks.zircon.api.ColorThemes import org.hexworks.zircon.api.ColorThemes
import org.hexworks.zircon.api.application.AppConfig import org.hexworks.zircon.api.application.AppConfig

View file

@ -1,4 +1,4 @@
package group.ouroboros.potrogue.attributes package group.ouroboros.potrogue.entity.attributes
import org.hexworks.amethyst.api.base.BaseAttribute import org.hexworks.amethyst.api.base.BaseAttribute
import org.hexworks.cobalt.databinding.api.extension.toProperty import org.hexworks.cobalt.databinding.api.extension.toProperty

View file

@ -1,4 +1,4 @@
package group.ouroboros.potrogue.attributes package group.ouroboros.potrogue.entity.attributes
import org.hexworks.amethyst.api.base.BaseAttribute import org.hexworks.amethyst.api.base.BaseAttribute
import org.hexworks.zircon.api.data.Tile import org.hexworks.zircon.api.data.Tile

View file

@ -1,4 +1,4 @@
package group.ouroboros.potrogue.attributes.types package group.ouroboros.potrogue.entity.attributes.types
import org.hexworks.amethyst.api.base.BaseEntityType import org.hexworks.amethyst.api.base.BaseEntityType

View file

@ -1,4 +1,4 @@
package group.ouroboros.potrogue.messages package group.ouroboros.potrogue.entity.messages
import group.ouroboros.potrogue.extensions.GameEntity import group.ouroboros.potrogue.extensions.GameEntity
import group.ouroboros.potrogue.extensions.GameMessage import group.ouroboros.potrogue.extensions.GameMessage

View file

@ -1,4 +1,4 @@
package group.ouroboros.potrogue.messages package group.ouroboros.potrogue.entity.messages
import group.ouroboros.potrogue.extensions.GameEntity import group.ouroboros.potrogue.extensions.GameEntity
import group.ouroboros.potrogue.extensions.GameMessage import group.ouroboros.potrogue.extensions.GameMessage

View file

@ -1,7 +1,7 @@
package group.ouroboros.potrogue.systems package group.ouroboros.potrogue.entity.systems
import group.ouroboros.potrogue.entity.messages.MoveCamera
import group.ouroboros.potrogue.extensions.position import group.ouroboros.potrogue.extensions.position
import group.ouroboros.potrogue.messages.MoveCamera
import group.ouroboros.potrogue.world.GameContext import group.ouroboros.potrogue.world.GameContext
import org.hexworks.amethyst.api.Consumed import org.hexworks.amethyst.api.Consumed
import org.hexworks.amethyst.api.Response import org.hexworks.amethyst.api.Response

View file

@ -1,7 +1,7 @@
package group.ouroboros.potrogue.systems package group.ouroboros.potrogue.entity.systems
import group.ouroboros.potrogue.entity.messages.MoveTo
import group.ouroboros.potrogue.extensions.position import group.ouroboros.potrogue.extensions.position
import group.ouroboros.potrogue.messages.MoveTo
import group.ouroboros.potrogue.world.GameContext import group.ouroboros.potrogue.world.GameContext
import org.hexworks.amethyst.api.base.BaseBehavior import org.hexworks.amethyst.api.base.BaseBehavior
import org.hexworks.amethyst.api.entity.Entity import org.hexworks.amethyst.api.entity.Entity

View file

@ -1,15 +1,15 @@
package group.ouroboros.potrogue.systems package group.ouroboros.potrogue.entity.systems
import group.ouroboros.potrogue.messages.MoveTo import group.ouroboros.potrogue.entity.attributes.types.Player
import group.ouroboros.potrogue.entity.messages.MoveCamera
import group.ouroboros.potrogue.entity.messages.MoveTo
import group.ouroboros.potrogue.extensions.position
import group.ouroboros.potrogue.world.GameContext import group.ouroboros.potrogue.world.GameContext
import org.hexworks.amethyst.api.Consumed import org.hexworks.amethyst.api.Consumed
import org.hexworks.amethyst.api.MessageResponse
import org.hexworks.amethyst.api.Pass import org.hexworks.amethyst.api.Pass
import org.hexworks.amethyst.api.Response import org.hexworks.amethyst.api.Response
import org.hexworks.amethyst.api.base.BaseFacet import org.hexworks.amethyst.api.base.BaseFacet
import group.ouroboros.potrogue.attributes.types.Player
import group.ouroboros.potrogue.extensions.position
import group.ouroboros.potrogue.messages.MoveCamera
import org.hexworks.amethyst.api.MessageResponse
/* /*
* Hey, whats Pass and Consumed? * Hey, whats Pass and Consumed?

View file

@ -1,14 +1,14 @@
package group.ouroboros.potrogue.extensions package group.ouroboros.potrogue.extensions
import group.ouroboros.potrogue.attributes.EntityPosition import group.ouroboros.potrogue.entity.attributes.EntityPosition
import group.ouroboros.potrogue.attributes.EntityTile import group.ouroboros.potrogue.entity.attributes.EntityTile
import group.ouroboros.potrogue.world.GameContext import group.ouroboros.potrogue.world.GameContext
import org.hexworks.amethyst.api.Attribute import org.hexworks.amethyst.api.Attribute
import org.hexworks.amethyst.api.Message
import org.hexworks.amethyst.api.entity.Entity import org.hexworks.amethyst.api.entity.Entity
import org.hexworks.amethyst.api.entity.EntityType import org.hexworks.amethyst.api.entity.EntityType
import org.hexworks.zircon.api.data.Tile import org.hexworks.zircon.api.data.Tile
import kotlin.reflect.KClass import kotlin.reflect.KClass
import org.hexworks.amethyst.api.Message
typealias AnyGameEntity = GameEntity<EntityType> typealias AnyGameEntity = GameEntity<EntityType>
typealias GameEntity<T> = Entity<T, GameContext> typealias GameEntity<T> = Entity<T, GameContext>

View file

@ -1,6 +1,7 @@
package group.ouroboros.potrogue package group.ouroboros.potrogue
import group.ouroboros.potrogue.config.Config import group.ouroboros.potrogue.data.config.Config
import group.ouroboros.potrogue.data.config.GameConfig
import group.ouroboros.potrogue.view.StartView import group.ouroboros.potrogue.view.StartView
import org.hexworks.zircon.api.SwingApplications import org.hexworks.zircon.api.SwingApplications
@ -8,7 +9,6 @@ import org.hexworks.zircon.api.SwingApplications
const val GAME_ID = "PotRogue"; const val GAME_ID = "PotRogue";
const val GAME_VER = "0.1.0-DEV"; const val GAME_VER = "0.1.0-DEV";
fun main(args: Array<String>) { fun main(args: Array<String>) {
Config() Config()
//Start Application //Start Application

View file

@ -1,6 +1,6 @@
package group.ouroboros.potrogue.view package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GameConfig import group.ouroboros.potrogue.data.config.GameConfig
import org.hexworks.zircon.api.ComponentDecorations import org.hexworks.zircon.api.ComponentDecorations
import org.hexworks.zircon.api.Components import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ColorTheme import org.hexworks.zircon.api.component.ColorTheme

View file

@ -1,7 +1,7 @@
package group.ouroboros.potrogue.view package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GameConfig import group.ouroboros.potrogue.data.config.GameConfig
import org.hexworks.zircon.api.ComponentDecorations.box import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.Components import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ColorTheme import org.hexworks.zircon.api.component.ColorTheme

View file

@ -1,6 +1,6 @@
package group.ouroboros.potrogue.view package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GameConfig import group.ouroboros.potrogue.data.config.GameConfig
import org.hexworks.zircon.api.ComponentDecorations import org.hexworks.zircon.api.ComponentDecorations
import org.hexworks.zircon.api.Components import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ColorTheme import org.hexworks.zircon.api.component.ColorTheme

View file

@ -1,9 +1,9 @@
package group.ouroboros.potrogue.view package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GameConfig
import group.ouroboros.potrogue.GameConfig.LOG_AREA_HEIGHT
import group.ouroboros.potrogue.GameConfig.WINDOW_WIDTH
import group.ouroboros.potrogue.builders.GameTileRepository import group.ouroboros.potrogue.builders.GameTileRepository
import group.ouroboros.potrogue.data.config.GameConfig
import group.ouroboros.potrogue.data.config.GameConfig.LOG_AREA_HEIGHT
import group.ouroboros.potrogue.data.config.GameConfig.WINDOW_WIDTH
import group.ouroboros.potrogue.world.Game import group.ouroboros.potrogue.world.Game
import group.ouroboros.potrogue.world.GameBuilder import group.ouroboros.potrogue.world.GameBuilder
import org.hexworks.cobalt.databinding.api.extension.toProperty import org.hexworks.cobalt.databinding.api.extension.toProperty
@ -13,10 +13,10 @@ import org.hexworks.zircon.api.component.ColorTheme
import org.hexworks.zircon.api.component.ComponentAlignment import org.hexworks.zircon.api.component.ComponentAlignment
import org.hexworks.zircon.api.game.ProjectionMode import org.hexworks.zircon.api.game.ProjectionMode
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.internal.game.impl.GameAreaComponentRenderer
import org.hexworks.zircon.api.uievent.KeyboardEventType import org.hexworks.zircon.api.uievent.KeyboardEventType
import org.hexworks.zircon.api.uievent.Processed import org.hexworks.zircon.api.uievent.Processed
import org.hexworks.zircon.api.view.base.BaseView
import org.hexworks.zircon.internal.game.impl.GameAreaComponentRenderer
class PlayView (private val grid: TileGrid, private val game: Game = GameBuilder.create(), theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) { class PlayView (private val grid: TileGrid, private val game: Game = GameBuilder.create(), theme: ColorTheme = GameConfig.THEME) : BaseView(grid, theme) {

View file

@ -1,7 +1,7 @@
package group.ouroboros.potrogue.view package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GAME_ID import group.ouroboros.potrogue.GAME_ID
import group.ouroboros.potrogue.GameConfig import group.ouroboros.potrogue.data.config.GameConfig
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

View file

@ -1,7 +1,6 @@
package group.ouroboros.potrogue.view package group.ouroboros.potrogue.view
import group.ouroboros.potrogue.GameConfig import group.ouroboros.potrogue.data.config.GameConfig
import org.hexworks.zircon.api.ColorThemes
import org.hexworks.zircon.api.ComponentDecorations.box import org.hexworks.zircon.api.ComponentDecorations.box
import org.hexworks.zircon.api.Components import org.hexworks.zircon.api.Components
import org.hexworks.zircon.api.component.ColorTheme import org.hexworks.zircon.api.component.ColorTheme

View file

@ -1,6 +1,6 @@
package group.ouroboros.potrogue.world package group.ouroboros.potrogue.world
import group.ouroboros.potrogue.attributes.types.Player import group.ouroboros.potrogue.entity.attributes.types.Player
import group.ouroboros.potrogue.extensions.GameEntity import group.ouroboros.potrogue.extensions.GameEntity
/* /*

View file

@ -1,14 +1,14 @@
package group.ouroboros.potrogue.world package group.ouroboros.potrogue.world
import group.ouroboros.potrogue.GameConfig
import group.ouroboros.potrogue.GameConfig.LOG_AREA_HEIGHT
import group.ouroboros.potrogue.GameConfig.SIDEBAR_WIDTH
import group.ouroboros.potrogue.GameConfig.WINDOW_HEIGHT
import group.ouroboros.potrogue.GameConfig.WINDOW_WIDTH
import group.ouroboros.potrogue.GameConfig.WORLD_SIZE
import group.ouroboros.potrogue.attributes.types.Player
import group.ouroboros.potrogue.builders.EntityFactory import group.ouroboros.potrogue.builders.EntityFactory
import group.ouroboros.potrogue.builders.WorldBuilder import group.ouroboros.potrogue.builders.WorldBuilder
import group.ouroboros.potrogue.data.config.GameConfig
import group.ouroboros.potrogue.data.config.GameConfig.LOG_AREA_HEIGHT
import group.ouroboros.potrogue.data.config.GameConfig.SIDEBAR_WIDTH
import group.ouroboros.potrogue.data.config.GameConfig.WINDOW_HEIGHT
import group.ouroboros.potrogue.data.config.GameConfig.WINDOW_WIDTH
import group.ouroboros.potrogue.data.config.GameConfig.WORLD_SIZE
import group.ouroboros.potrogue.entity.attributes.types.Player
import group.ouroboros.potrogue.extensions.GameEntity import group.ouroboros.potrogue.extensions.GameEntity
import org.hexworks.zircon.api.data.Position3D import org.hexworks.zircon.api.data.Position3D
import org.hexworks.zircon.api.data.Size3D import org.hexworks.zircon.api.data.Size3D

View file

@ -1,10 +1,10 @@
package group.ouroboros.potrogue.world package group.ouroboros.potrogue.world
import group.ouroboros.potrogue.entity.attributes.types.Player
import group.ouroboros.potrogue.extensions.GameEntity import group.ouroboros.potrogue.extensions.GameEntity
import org.hexworks.amethyst.api.Context import org.hexworks.amethyst.api.Context
import org.hexworks.zircon.api.screen.Screen import org.hexworks.zircon.api.screen.Screen
import org.hexworks.zircon.api.uievent.UIEvent import org.hexworks.zircon.api.uievent.UIEvent
import group.ouroboros.potrogue.attributes.types.Player
data class GameContext( data class GameContext(
// The world itself // The world itself

View file

@ -1,10 +0,0 @@
import org.assertj.core.api.Assertions
import org.junit.Test
class Test {
@Test
fun test() {
Assertions.assertThat("this").isNotEqualTo("that")
}
}