The default implementation behaves as if:
@@ -85,7 +88,9 @@ public class PairedMapLayer implements Iterable
- * 0 == 6 AM
- * @return
- */
- public static int elapsedSeconds(){
- return (HOUR_SEC * hours + MINUTE_SEC * minutes + seconds) % DAY_LENGTH;
- }
-
- /**
- * How much time has passed since the beginning, in seconds.
- * @return
- */
- public static long totalSeconds(){
- return (long)(DAY_LENGTH) * daysCount + HOUR_SEC * hours + MINUTE_SEC * minutes + seconds;
- }
-
- public static boolean isLeapYear(){
- return ((years % 4 == 0) && (years % 100 != 0)) || (years % 400 == 0);
- }
-
- public static void setTime(int t){
- days += t / DAY_LENGTH;
- hours = t / HOUR_SEC;
- minutes = (t - HOUR_SEC * hours) / MINUTE_SEC;
- seconds = t - minutes * MINUTE_SEC;
- }
-
- public static void addTime(int t){
- setTime(elapsedSeconds() + t);
- }
-
- public static void setTimeDelta(int d){
- timeDelta = (d == 0) ? 1 : d;
- }
-
- public static String getDayName(){
- return DAYNAMES[dayOfWeek];
- }
-
- private static void kickVariables() {
- if (seconds >= 60){
- seconds = 0;
- minutes++;
- }
-
- if (minutes >= 60){
- minutes = 0;
- hours++;
- }
-
- if (hours >= DAY_LENGTH/3600){
- hours = 0;
- days++;
- daysCount++;
- dayOfWeek++;
- }
- }
-}
\ No newline at end of file
diff --git a/src/com/Torvald/Terrarum/GameMap/WorldTime.kt b/src/com/Torvald/Terrarum/GameMap/WorldTime.kt
new file mode 100644
index 000000000..d2629dc2c
--- /dev/null
+++ b/src/com/Torvald/Terrarum/GameMap/WorldTime.kt
@@ -0,0 +1,150 @@
+package com.Torvald.Terrarum.GameMap
+
+/**
+ * Created by minjaesong on 16-01-24.
+ */
+class WorldTime {
+ internal var seconds: Int
+ internal var minutes: Int
+ internal var hours: Int
+
+ internal var daysCount: Int //NOT a calendar day
+
+ internal var days: Int
+ internal var months: Int
+ internal var years: Int
+
+ internal var dayOfWeek: Int //0: Mondag-The first day of weekday
+
+ internal var timeDelta = 1
+
+ @Transient private var realMillisec: Int
+
+ val DAYNAMES = arrayOf(//daynames are taken from Nynorsk (å -> o)
+ "Mondag", "Tysdag", "Midtedag" //From Islenska Miðvikudagur
+ , "Torsdag", "Fredag", "Laurdag", "Sundag", "Verdag" //From Norsk word 'verd'
+ )
+ val DAYNAMES_SHORT = arrayOf("Mon", "Tys", "Mid", "Tor", "Fre", "Lau", "Sun", "Ver")
+
+
+ @Transient val REAL_SEC_IN_MILLI = 1000
+
+ init {
+ seconds = 0
+ minutes = 0
+ hours = 0
+ daysCount = 0
+ days = 1
+ months = 1
+ years = 1
+ dayOfWeek = 0
+ realMillisec = 0
+ }
+
+ fun update(delta: Int) {
+ //time
+ realMillisec += delta * timeDelta
+ seconds = Math.round(GAME_MIN_TO_REAL_SEC.toFloat() / REAL_SEC_IN_MILLI.toFloat() * realMillisec.toFloat())
+
+ if (realMillisec >= REAL_SEC_IN_MILLI)
+ realMillisec -= REAL_SEC_IN_MILLI
+
+ kickVariables()
+ }
+
+ /**
+ * How much time has passed today, in seconds.
+ * 0 == 6 AM
+ * @return
+ */
+ fun elapsedSeconds(): Int {
+ return (HOUR_SEC * hours + MINUTE_SEC * minutes + seconds) % DAY_LENGTH
+ }
+
+ val isLeapYear: Boolean
+ get() = years % 4 == 0 && years % 100 != 0 || years % 400 == 0
+
+ fun setTime(t: Int) {
+ days += t / DAY_LENGTH
+ hours = t / HOUR_SEC
+ minutes = (t - HOUR_SEC * hours) / MINUTE_SEC
+ seconds = t - minutes * MINUTE_SEC
+ }
+
+ fun addTime(t: Int) {
+ setTime(elapsedSeconds() + t)
+ }
+
+ fun setTimeDelta(d: Int) {
+ timeDelta = if (d < 0) 0 else d
+ }
+
+ val dayName: String
+ get() = DAYNAMES[dayOfWeek]
+
+ private fun kickVariables() {
+ if (seconds >= MINUTE_SEC) {
+ seconds = 0
+ minutes += 1
+ }
+
+ if (minutes >= HOUR_MIN) {
+ minutes = 0
+ hours += 1
+ }
+
+ if (hours >= DAY_LENGTH / HOUR_SEC) {
+ hours = 0
+ days += 1
+ daysCount += 1
+ dayOfWeek += 1
+ }
+
+ //calendar (the world calendar)
+ if (dayOfWeek == 7) {
+ dayOfWeek = 0
+ }
+ if ((months == 12 || months == 7 && isLeapYear) && days == 31) {
+ dayOfWeek = 7
+ }
+
+ if ((months == 12 || months == 7 && isLeapYear) && days == 32) {
+ days = 1
+ months = 1
+ years++
+ }
+ else if ((months == 1 || months == 4 || months == 7 || months == 10) && days > 31) {
+ days = 0
+ months++
+ }
+ else if (days > 30) {
+ days = 0
+ months++
+ }
+
+ if (months > 12) {
+ months = 1
+ years++
+ }
+ }
+
+ fun getFormattedTime(): String {
+ fun formatMin(min: Int): String {
+ return if (min < 10) "0${min.toString()}" else min.toString()
+ }
+
+ return "${hours}h${formatMin(minutes)}"
+ }
+
+ companion object {
+ /**
+ * 22h
+ */
+ @Transient val DAY_LENGTH = 79200 //must be the multiple of 3600
+
+ @Transient val HOUR_SEC: Int = 3600
+ @Transient val MINUTE_SEC: Int = 60
+ @Transient val HOUR_MIN: Int = 60
+ @Transient val GAME_MIN_TO_REAL_SEC: Float = 60f
+ }
+}
\ No newline at end of file
diff --git a/src/com/Torvald/Terrarum/ItemProperties/ItemProp.kt b/src/com/Torvald/Terrarum/ItemProperties/ItemProp.kt
new file mode 100644
index 000000000..511051468
--- /dev/null
+++ b/src/com/Torvald/Terrarum/ItemProperties/ItemProp.kt
@@ -0,0 +1,9 @@
+package com.Torvald.Terrarum.ItemProperties
+
+/**
+ * Created by minjaesong on 16-03-18.
+ */
+internal data class ItemProp (
+ var baseMass: Float,
+ var material: Material
+)
\ No newline at end of file
diff --git a/src/com/Torvald/Terrarum/GameItem/ItemPropCodex.kt b/src/com/Torvald/Terrarum/ItemProperties/ItemPropCodex.kt
similarity index 84%
rename from src/com/Torvald/Terrarum/GameItem/ItemPropCodex.kt
rename to src/com/Torvald/Terrarum/ItemProperties/ItemPropCodex.kt
index eeb38bd34..111f97511 100644
--- a/src/com/Torvald/Terrarum/GameItem/ItemPropCodex.kt
+++ b/src/com/Torvald/Terrarum/ItemProperties/ItemPropCodex.kt
@@ -1,6 +1,7 @@
-package com.Torvald.Terrarum.GameItem
+package com.Torvald.Terrarum.ItemProperties
import com.Torvald.Terrarum.Actors.CanBeStoredAsItem
+import com.Torvald.Terrarum.GameItem.InventoryItem
import com.Torvald.Terrarum.Terrarum
import org.newdawn.slick.GameContainer
import java.util.*
@@ -30,10 +31,10 @@ object ItemPropCodex {
fun getItem(code: Long): InventoryItem {
if (code < ITEM_UNIQUE_MAX)
- return itemCodex[code as Int]!!
+ return itemCodex[(code and 0xFFFFFFFF).toInt()]
else {
for (actor in Terrarum.game.actorContainer) {
- if (actor is CanBeStoredAsItem && actor.referenceID!!.equals(code))
+ if (actor is CanBeStoredAsItem && actor.referenceID.equals(code))
return actor.itemData
}
diff --git a/src/com/Torvald/Terrarum/ItemProperties/Material.kt b/src/com/Torvald/Terrarum/ItemProperties/Material.kt
new file mode 100644
index 000000000..174cedcfc
--- /dev/null
+++ b/src/com/Torvald/Terrarum/ItemProperties/Material.kt
@@ -0,0 +1,10 @@
+package com.Torvald.Terrarum.ItemProperties
+
+/**
+ * Created by minjaesong on 16-03-18.
+ */
+internal data class Material (
+ var maxEdge: Int,
+ var hardness: Int,
+ var density: Int
+)
\ No newline at end of file
diff --git a/src/com/Torvald/Terrarum/ItemProperties/MaterialFactory.kt b/src/com/Torvald/Terrarum/ItemProperties/MaterialFactory.kt
new file mode 100644
index 000000000..4655052f7
--- /dev/null
+++ b/src/com/Torvald/Terrarum/ItemProperties/MaterialFactory.kt
@@ -0,0 +1,7 @@
+package com.Torvald.Terrarum.ItemProperties
+
+/**
+ * Created by minjaesong on 16-03-19.
+ */
+object MaterialFactory {
+}
\ No newline at end of file
diff --git a/src/com/Torvald/Terrarum/ItemProperties/MaterialPropCodex.kt b/src/com/Torvald/Terrarum/ItemProperties/MaterialPropCodex.kt
new file mode 100644
index 000000000..085ce9130
--- /dev/null
+++ b/src/com/Torvald/Terrarum/ItemProperties/MaterialPropCodex.kt
@@ -0,0 +1,9 @@
+package com.Torvald.Terrarum.ItemProperties
+
+/**
+ * Created by minjaesong on 16-03-18.
+ */
+object MaterialPropCodex {
+ val CSV_PATH = "./src/com/Torvald/Terrarum/ItemProperties/materialprop.csv"
+
+}
\ No newline at end of file
diff --git a/src/com/Torvald/Terrarum/KVHashMap.java b/src/com/Torvald/Terrarum/KVHashMap.java
deleted file mode 100644
index f909cef33..000000000
--- a/src/com/Torvald/Terrarum/KVHashMap.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package com.Torvald.Terrarum;
-
-import com.google.gson.JsonPrimitive;
-
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Set;
-
-/**
- * Created by minjaesong on 15-12-30.
- */
-public class KVHashMap {
-
- private HashMap