new actor type "HistoricalFigure" that has date of birth and death

Former-commit-id: ec7ca90f29e0c56b3553e87b5a95fd023d9c55e1
Former-commit-id: 685958754f78542843913731880eb73f90e8e4c9
This commit is contained in:
Song Minjae
2016-10-10 18:25:29 +09:00
parent b0736aa722
commit c1d72c29af
12 changed files with 79 additions and 27 deletions

View File

@@ -3,9 +3,9 @@ package net.torvald.terrarum.gameworld
/**
* Created by minjaesong on 16-01-17.
*/
class MapLayer(var width: Int, var height: Int) : Iterable<Byte> {
class MapLayer(val width: Int, val height: Int) : Iterable<Byte> {
internal var data: Array<ByteArray>
internal @Volatile var data: Array<ByteArray> // in parallel programming: do not trust your register; always read freshly from RAM!
init {
data = Array(height) { ByteArray(width) }

View File

@@ -7,7 +7,7 @@ import java.util.function.Consumer
/**
* Created by minjaesong on 16-02-15.
*/
class PairedMapLayer(width: Int, var height: Int) : Iterable<Byte> {
class PairedMapLayer(width: Int, val height: Int) : Iterable<Byte> {
/**
* 0b_xxxx_yyyy, x for lower index, y for higher index
@@ -17,9 +17,9 @@ class PairedMapLayer(width: Int, var height: Int) : Iterable<Byte> {
* 0110 1101 is interpreted as
* 6 for tile 0, 13 for tile 1.
*/
internal var dataPair: Array<ByteArray>
internal @Volatile var dataPair: Array<ByteArray>
var width: Int = 0
val width: Int
init {
this.width = width / 2

View File

@@ -56,6 +56,8 @@ class WorldTime {
val HOUR_MIN: Int = 60
val GAME_MIN_TO_REAL_SEC: Float = 60f
val YEAR_DAYS: Int = 365
fun parseTime(s: String): Int =
if (s.length >= 4) {
s.toLowerCase().substringBefore('h').toInt() * WorldTime.HOUR_SEC +
@@ -103,9 +105,6 @@ class WorldTime {
val elapsedSeconds: Int
get() = (HOUR_SEC * hours + MINUTE_SEC * minutes + seconds) % DAY_LENGTH
val isLeapYear: Boolean
get() = years % 4 == 0 && years % 100 != 0 || years % 400 == 0
/** Sets time of this day. */
fun setTime(t: Int) {
days += t / DAY_LENGTH
@@ -148,11 +147,11 @@ class WorldTime {
if (dayOfWeek == 7) {
dayOfWeek = 0
}
if ((months == 12 || months == 7 && isLeapYear) && days == 31) {
if (months == 12 && days == 31) {
dayOfWeek = 7
}
if ((months == 12 || months == 7 && isLeapYear) && days == 32) {
if (months == 12 && days == 32) {
days = 1
months = 1
years++
@@ -173,7 +172,14 @@ class WorldTime {
}
}
fun getFormattedTime() = "${String.format("%02d", hours)}h${String.format("%02d", minutes)}"
/** Format: "%A %d %B %Y %X" */
fun getFormattedTime() = "${getDayNameFull()} " +
"$days " +
"${getMonthNameFull()} " +
"$years " +
"${String.format("%02d", hours)}:" +
"${String.format("%02d", minutes)}:" +
"${String.format("%02d", seconds)}"
fun getDayNameFull() = DAY_NAMES[dayOfWeek]
fun getDayNameShort() = DAY_NAMES_SHORT[dayOfWeek]