mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
serialised RNG; font update
This commit is contained in:
@@ -176,10 +176,10 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
val world: GameWorldExtension,
|
||||
val historicalFigureIDBucket: ArrayList<Int>,
|
||||
val realGamePlayer: IngamePlayer,
|
||||
val rogueseed: Long,
|
||||
val rogueiter: Int,
|
||||
val weatherseed: Long,
|
||||
val weatheriter: Int
|
||||
val rogueS0: Long,
|
||||
val rogueS1: Long,
|
||||
val weatherS0: Long,
|
||||
val weatherS1: Long
|
||||
)
|
||||
|
||||
data class NewWorldParameters(
|
||||
@@ -209,8 +209,8 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
// set the randomisers right
|
||||
RoguelikeRandomiser.loadFromSave(gameSaveData.rogueseed, gameSaveData.rogueiter)
|
||||
WeatherMixer.loadFromSave(gameSaveData.weatherseed, gameSaveData.weatheriter)
|
||||
RoguelikeRandomiser.loadFromSave(gameSaveData.rogueS0, gameSaveData.rogueS1)
|
||||
WeatherMixer.loadFromSave(gameSaveData.weatherS0, gameSaveData.weatherS1)
|
||||
|
||||
|
||||
//initGame()
|
||||
@@ -242,8 +242,6 @@ open class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
historicalFigureIDBucket = ArrayList<Int>()
|
||||
|
||||
|
||||
RoguelikeRandomiser.seed = HQRNG().nextLong()
|
||||
|
||||
|
||||
// add new player and put it to actorContainer
|
||||
//playableActorDelegate = PlayableActorDelegate(PlayerBuilderSigrid())
|
||||
|
||||
@@ -1,29 +1,14 @@
|
||||
package net.torvald.terrarum.modulebasegame
|
||||
|
||||
import net.torvald.random.HQRNG
|
||||
import java.util.*
|
||||
|
||||
internal interface RNGConsumer {
|
||||
|
||||
val RNG: Random
|
||||
var seed: Long
|
||||
var iterations: Int
|
||||
val RNG: HQRNG
|
||||
|
||||
fun loadFromSave(seed: Long, iterations: Int) {
|
||||
this.seed = seed
|
||||
this.iterations = iterations
|
||||
|
||||
repeat(iterations, { RNG.nextInt() })
|
||||
}
|
||||
|
||||
private fun incIterations() {
|
||||
iterations++
|
||||
|
||||
if (iterations < 0) iterations = 0
|
||||
}
|
||||
|
||||
fun getRandomLong(): Long {
|
||||
iterations++
|
||||
return RNG.nextLong()
|
||||
fun loadFromSave(s0: Long, s1: Long) {
|
||||
RNG.reseed(s0, s1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItem
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* @param savefile TEVd file
|
||||
*
|
||||
* Created by minjaesong on 2018-09-15.
|
||||
*/
|
||||
class UIItemSavegameInfoCell(
|
||||
parent: UICanvas,
|
||||
savefile: File,
|
||||
override val width: Int,
|
||||
override var posX: Int,
|
||||
override var posY: Int
|
||||
) : UIItem(parent) {
|
||||
|
||||
override val height: Int = Terrarum.fontGame.lineHeight.toInt() * 2
|
||||
|
||||
override fun render(batch: SpriteBatch, camera: Camera) {
|
||||
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import com.badlogic.gdx.graphics.Camera
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import net.torvald.terrarum.Second
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.blendNormal
|
||||
import net.torvald.terrarum.serialise.SavegameLedger
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import net.torvald.terrarum.ui.UIItemList
|
||||
|
||||
/**
|
||||
* Created by minjaesong on 2018-09-15.
|
||||
*/
|
||||
class UITitleCharactersList : UICanvas() {
|
||||
|
||||
override var openCloseTime: Second = 0f
|
||||
|
||||
|
||||
|
||||
private val moduleAreaHMargin = 48
|
||||
|
||||
private val moduleAreaBorder = 8
|
||||
|
||||
override var width = (Terrarum.WIDTH * 0.75).toInt() - moduleAreaHMargin
|
||||
override var height = Terrarum.HEIGHT - moduleAreaHMargin * 2
|
||||
|
||||
private val moduleInfoCells = ArrayList<UIItemSavegameInfoCell>()
|
||||
// build module list
|
||||
init {
|
||||
SavegameLedger.getSavefileList()?.forEachIndexed { index, file ->
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private val mouduleArea = UIItemList<UIItemSavegameInfoCell>(
|
||||
this,
|
||||
moduleInfoCells,
|
||||
(Terrarum.WIDTH * 0.25f).toInt(), moduleAreaHMargin,
|
||||
width,
|
||||
height,
|
||||
inactiveCol = Color.WHITE,
|
||||
border = moduleAreaBorder
|
||||
)
|
||||
|
||||
|
||||
init {
|
||||
uiItems.add(mouduleArea)
|
||||
}
|
||||
|
||||
override fun updateUI(delta: Float) {
|
||||
mouduleArea.update(delta)
|
||||
}
|
||||
|
||||
override fun renderUI(batch: SpriteBatch, camera: Camera) {
|
||||
batch.color = Color.WHITE
|
||||
blendNormal()
|
||||
mouduleArea.render(batch, camera)
|
||||
}
|
||||
|
||||
override fun doOpening(delta: Float) {
|
||||
}
|
||||
|
||||
override fun doClosing(delta: Float) {
|
||||
}
|
||||
|
||||
override fun endOpening(delta: Float) {
|
||||
}
|
||||
|
||||
override fun endClosing(delta: Float) {
|
||||
}
|
||||
|
||||
override fun dispose() {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.torvald.terrarum.modulebasegame.ui
|
||||
|
||||
import net.torvald.terrarum.AppLoader
|
||||
import java.util.*
|
||||
|
||||
|
||||
@@ -33,10 +34,14 @@ object UITitleRemoConYaml {
|
||||
|
||||
val debugTools = """
|
||||
- Development Tools $
|
||||
- Building Maker
|
||||
- Building Maker
|
||||
- Start New Random Game
|
||||
""".trimIndent()
|
||||
|
||||
operator fun invoke() = parseYamlList(menus)
|
||||
operator fun invoke() = if (AppLoader.IS_DEVELOPMENT_BUILD)
|
||||
parseYamlList(menus + "\n" + debugTools)
|
||||
else
|
||||
parseYamlList(menus)
|
||||
|
||||
fun parseYamlList(yaml: String): QNDTreeNode<String> {
|
||||
var currentIndentLevel = -1
|
||||
|
||||
@@ -35,8 +35,6 @@ import java.util.*
|
||||
internal object WeatherMixer : RNGConsumer {
|
||||
|
||||
override val RNG = HQRNG()
|
||||
override var seed = 0L
|
||||
override var iterations = 0
|
||||
|
||||
|
||||
var weatherList: HashMap<String, ArrayList<BaseModularWeather>>
|
||||
|
||||
@@ -20,7 +20,6 @@ object RoguelikeRandomiser : RNGConsumer {
|
||||
val coloursTaken: ArrayList<Col4096> = ArrayList()
|
||||
|
||||
override val RNG = HQRNG()
|
||||
override var seed = 0L
|
||||
|
||||
private val POTION_HEAL_TIER1 = 0x00
|
||||
private val POTION_HEAL_TIRE2 = 0x01
|
||||
@@ -29,7 +28,6 @@ object RoguelikeRandomiser : RNGConsumer {
|
||||
|
||||
private val POTION_BERSERK_TIER1 = 0x20
|
||||
|
||||
override var iterations = 0
|
||||
|
||||
fun setupColours() {
|
||||
|
||||
@@ -55,13 +53,11 @@ object RoguelikeRandomiser : RNGConsumer {
|
||||
|
||||
fun shuffleArrayInt(ar: IntArray, rnd: Random) {
|
||||
for (i in ar.size - 1 downTo 0) {
|
||||
val index = rnd.nextInt(i + 1);
|
||||
val index = rnd.nextInt(i + 1)
|
||||
// Simple swap
|
||||
val a = ar[index];
|
||||
ar[index] = ar[i];
|
||||
ar[i] = a;
|
||||
|
||||
iterations++
|
||||
val a = ar[index]
|
||||
ar[index] = ar[i]
|
||||
ar[i] = a
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user