blocks now have properly formatted ids

This commit is contained in:
Song Minjae
2017-04-29 00:05:10 +09:00
parent df3afab5ee
commit 0510ac230b
17 changed files with 3346 additions and 851 deletions

View File

@@ -29,13 +29,11 @@ object BlockCodex {
println("[BlockCodex] Building block properties table")
records.forEach {
if (intVal(it, "sid") == -1) {
if (intVal(it, "blid") == -1) {
setProp(nullProp, it)
}
else {
setProp(
blockProps[idDamageToIndex(intVal(it, "id"), intVal(it, "sid"))], it
)
setProp(blockProps[intVal(it, "blid")], it)
}
}
}
@@ -44,15 +42,13 @@ object BlockCodex {
}
}
fun get(index: Int, subID: Int): BlockProp {
fun get(index: Int): BlockProp {
try {
blockProps[idDamageToIndex(index, subID)].id
return blockProps[index]
}
catch (e: NullPointerException) {
throw NullPointerException("Blockprop with id $index and subID $subID does not exist.")
throw NullPointerException("Blockprop with id $index does not exist.")
}
return blockProps[idDamageToIndex(index, subID)]
}
operator fun get(rawIndex: Int?): BlockProp {
@@ -71,14 +67,13 @@ object BlockCodex {
private fun setProp(prop: BlockProp, record: CSVRecord) {
prop.nameKey = record.get("name")
prop.id = idDamageToIndex(intVal(record, "id"), intVal(record, "sid"))
prop.id = intVal(record, "blid")
prop.drop = intVal(record, "drid")
prop.opacity = intVal(record, "opacity")
prop.strength = intVal(record, "strength")
prop.density = intVal(record, "dsty")
prop.luminosity = intVal(record, "lumcolor")
prop.drop = intVal(record, "drop")
prop.dropDamage = intVal(record, "ddmg")
prop.friction = intVal(record, "friction")
prop.viscosity = intVal(record, "vscs")
@@ -90,7 +85,7 @@ object BlockCodex {
prop.dynamicLuminosityFunction = intVal(record, "dlfn")
print(formatNum3(intVal(record, "id")) + ":" + formatNum2(intVal(record, "sid")))
print("${intVal(record, "blid")}")
println("\t" + prop.nameKey)
}
@@ -107,16 +102,5 @@ object BlockCodex {
private fun boolVal(rec: CSVRecord, s: String) = intVal(rec, s) != 0
fun idDamageToIndex(index: Int, damage: Int) = index * PairedMapLayer.RANGE + damage
private fun formatNum3(i: Int): String {
if (i < 10)
return "00" + i
else if (i < 100)
return "0" + i
else
return i.toString()
}
private fun formatNum2(i: Int) = if (i < 10) "0" + i else i.toString()
}