fix broken tests
This commit is contained in:
parent
03e8e9442a
commit
d1353eec60
4 changed files with 929 additions and 869 deletions
|
|
@ -79,9 +79,7 @@ class ColourHexTest : BehaviorSpec({
|
||||||
val colour: Colour = jsonMapperKafkatorio.decodeFromString(colourJson)
|
val colour: Colour = jsonMapperKafkatorio.decodeFromString(colourJson)
|
||||||
val colourHex = colour.toHex()
|
val colourHex = colour.toHex()
|
||||||
colourHex shouldBe ColourHex(r, g, b, a)
|
colourHex shouldBe ColourHex(r, g, b, a)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,14 @@
|
||||||
package dev.adamko.kafkatorio.events.schema
|
package dev.adamko.kafkatorio.events.schema
|
||||||
|
|
||||||
|
import dev.adamko.kafkatorio.schema.common.Colour
|
||||||
|
import dev.adamko.kafkatorio.schema.common.PrototypeName
|
||||||
|
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||||
|
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||||
|
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||||
|
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||||
import io.kotest.core.spec.style.BehaviorSpec
|
import io.kotest.core.spec.style.BehaviorSpec
|
||||||
import io.kotest.matchers.collections.shouldContain
|
import io.kotest.inspectors.forOne
|
||||||
|
import io.kotest.matchers.shouldBe
|
||||||
import io.kotest.matchers.types.shouldBeInstanceOf
|
import io.kotest.matchers.types.shouldBeInstanceOf
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
|
|
||||||
|
|
@ -11,17 +18,16 @@ class PrototypesTest : BehaviorSpec({
|
||||||
val raw = """
|
val raw = """
|
||||||
{
|
{
|
||||||
"modVersion": "0.2.4",
|
"modVersion": "0.2.4",
|
||||||
"packetType":"PROTOTYPES",
|
|
||||||
"tick": 534,
|
"tick": 534,
|
||||||
|
"data": {
|
||||||
|
"type": "dev.adamko.kafkatorio.schema2.PrototypesUpdate",
|
||||||
"prototypes": [
|
"prototypes": [
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "tile-unknown",
|
"name": "tile-unknown",
|
||||||
"order": "z-a",
|
"order": "z-a",
|
||||||
"layer": 0,
|
"layer": 0,
|
||||||
"collisionMasks":{
|
"collisionMasks": {},
|
||||||
|
|
||||||
},
|
|
||||||
"mapColour": {
|
"mapColour": {
|
||||||
"red": 0,
|
"red": 0,
|
||||||
"green": 0,
|
"green": 0,
|
||||||
|
|
@ -31,11 +37,12 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
Then("expect can be parsed") {
|
Then("expect can be parsed") {
|
||||||
val data = jsonMapperKafkatorio.decodeFromString<KafkatorioPacket>(raw)
|
val data = jsonMapperKafkatorio.decodeFromString<KafkatorioPacket2>(raw)
|
||||||
println(data)
|
println(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -46,11 +53,12 @@ class PrototypesTest : BehaviorSpec({
|
||||||
val raw = """
|
val raw = """
|
||||||
{
|
{
|
||||||
"modVersion": "0.3.2",
|
"modVersion": "0.3.2",
|
||||||
"packetType":"PROTOTYPES",
|
|
||||||
"tick": 534,
|
"tick": 534,
|
||||||
|
"data": {
|
||||||
|
"type": "dev.adamko.kafkatorio.schema2.PrototypesUpdate",
|
||||||
"prototypes": [
|
"prototypes": [
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "stone-path",
|
"name": "stone-path",
|
||||||
"order": "a[artificial]-a[tier-1]-a[stone-path]",
|
"order": "a[artificial]-a[tier-1]-a[stone-path]",
|
||||||
"layer": 60,
|
"layer": 60,
|
||||||
|
|
@ -66,7 +74,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": true
|
"canBeMined": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "concrete",
|
"name": "concrete",
|
||||||
"order": "a[artificial]-b[tier-2]-a[concrete]",
|
"order": "a[artificial]-b[tier-2]-a[concrete]",
|
||||||
"layer": 61,
|
"layer": 61,
|
||||||
|
|
@ -82,7 +90,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": true
|
"canBeMined": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "hazard-concrete-left",
|
"name": "hazard-concrete-left",
|
||||||
"order": "a[artificial]-b[tier-2]-b[hazard-concrete-left]",
|
"order": "a[artificial]-b[tier-2]-b[hazard-concrete-left]",
|
||||||
"layer": 62,
|
"layer": 62,
|
||||||
|
|
@ -98,7 +106,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": true
|
"canBeMined": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "hazard-concrete-right",
|
"name": "hazard-concrete-right",
|
||||||
"order": "a[artificial]-b[tier-2]-c[hazard-concrete-right]",
|
"order": "a[artificial]-b[tier-2]-c[hazard-concrete-right]",
|
||||||
"layer": 62,
|
"layer": 62,
|
||||||
|
|
@ -114,7 +122,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": true
|
"canBeMined": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "refined-concrete",
|
"name": "refined-concrete",
|
||||||
"order": "a[artificial]-c[tier-3]-a[refined-concrete]",
|
"order": "a[artificial]-c[tier-3]-a[refined-concrete]",
|
||||||
"layer": 64,
|
"layer": 64,
|
||||||
|
|
@ -130,7 +138,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": true
|
"canBeMined": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "refined-hazard-concrete-left",
|
"name": "refined-hazard-concrete-left",
|
||||||
"order": "a[artificial]-c[tier-3]-b[refined-hazard-concrete-left]",
|
"order": "a[artificial]-c[tier-3]-b[refined-hazard-concrete-left]",
|
||||||
"layer": 65,
|
"layer": 65,
|
||||||
|
|
@ -146,7 +154,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": true
|
"canBeMined": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "refined-hazard-concrete-right",
|
"name": "refined-hazard-concrete-right",
|
||||||
"order": "a[artificial]-c[tier-3]-c[refined-hazard-concrete-right]",
|
"order": "a[artificial]-c[tier-3]-c[refined-hazard-concrete-right]",
|
||||||
"layer": 65,
|
"layer": 65,
|
||||||
|
|
@ -162,7 +170,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": true
|
"canBeMined": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "landfill",
|
"name": "landfill",
|
||||||
"order": "a[artificial]-d[utility]-a[landfill]",
|
"order": "a[artificial]-d[utility]-a[landfill]",
|
||||||
"layer": 57,
|
"layer": 57,
|
||||||
|
|
@ -178,7 +186,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "acid-refined-concrete",
|
"name": "acid-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-acid",
|
"order": "a[artificial]-e[color-concrete]-acid",
|
||||||
"layer": 97,
|
"layer": 97,
|
||||||
|
|
@ -194,7 +202,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "black-refined-concrete",
|
"name": "black-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-black",
|
"order": "a[artificial]-e[color-concrete]-black",
|
||||||
"layer": 88,
|
"layer": 88,
|
||||||
|
|
@ -210,7 +218,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "blue-refined-concrete",
|
"name": "blue-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-blue",
|
"order": "a[artificial]-e[color-concrete]-blue",
|
||||||
"layer": 73,
|
"layer": 73,
|
||||||
|
|
@ -226,7 +234,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "brown-refined-concrete",
|
"name": "brown-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-brown",
|
"order": "a[artificial]-e[color-concrete]-brown",
|
||||||
"layer": 91,
|
"layer": 91,
|
||||||
|
|
@ -242,7 +250,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "cyan-refined-concrete",
|
"name": "cyan-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-cyan",
|
"order": "a[artificial]-e[color-concrete]-cyan",
|
||||||
"layer": 94,
|
"layer": 94,
|
||||||
|
|
@ -258,7 +266,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "green-refined-concrete",
|
"name": "green-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-green",
|
"order": "a[artificial]-e[color-concrete]-green",
|
||||||
"layer": 70,
|
"layer": 70,
|
||||||
|
|
@ -274,7 +282,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "orange-refined-concrete",
|
"name": "orange-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-orange",
|
"order": "a[artificial]-e[color-concrete]-orange",
|
||||||
"layer": 76,
|
"layer": 76,
|
||||||
|
|
@ -290,7 +298,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "pink-refined-concrete",
|
"name": "pink-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-pink",
|
"order": "a[artificial]-e[color-concrete]-pink",
|
||||||
"layer": 82,
|
"layer": 82,
|
||||||
|
|
@ -306,7 +314,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "purple-refined-concrete",
|
"name": "purple-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-purple",
|
"order": "a[artificial]-e[color-concrete]-purple",
|
||||||
"layer": 85,
|
"layer": 85,
|
||||||
|
|
@ -322,7 +330,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "red-refined-concrete",
|
"name": "red-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-red",
|
"order": "a[artificial]-e[color-concrete]-red",
|
||||||
"layer": 67,
|
"layer": 67,
|
||||||
|
|
@ -338,7 +346,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "yellow-refined-concrete",
|
"name": "yellow-refined-concrete",
|
||||||
"order": "a[artificial]-e[color-concrete]-yellow",
|
"order": "a[artificial]-e[color-concrete]-yellow",
|
||||||
"layer": 79,
|
"layer": 79,
|
||||||
|
|
@ -354,7 +362,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "grass-1",
|
"name": "grass-1",
|
||||||
"order": "b[natural]-a[grass]-a[grass-1]",
|
"order": "b[natural]-a[grass]-a[grass-1]",
|
||||||
"layer": 26,
|
"layer": 26,
|
||||||
|
|
@ -370,7 +378,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "grass-2",
|
"name": "grass-2",
|
||||||
"order": "b[natural]-a[grass]-b[grass-2]",
|
"order": "b[natural]-a[grass]-b[grass-2]",
|
||||||
"layer": 28,
|
"layer": 28,
|
||||||
|
|
@ -386,7 +394,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "grass-3",
|
"name": "grass-3",
|
||||||
"order": "b[natural]-a[grass]-c[grass-3]",
|
"order": "b[natural]-a[grass]-c[grass-3]",
|
||||||
"layer": 29,
|
"layer": 29,
|
||||||
|
|
@ -402,7 +410,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "grass-4",
|
"name": "grass-4",
|
||||||
"order": "b[natural]-a[grass]-d[grass-4]",
|
"order": "b[natural]-a[grass]-d[grass-4]",
|
||||||
"layer": 30,
|
"layer": 30,
|
||||||
|
|
@ -418,7 +426,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "dry-dirt",
|
"name": "dry-dirt",
|
||||||
"order": "b[natural]-b[dirt]-a[dry-dirt]",
|
"order": "b[natural]-b[dirt]-a[dry-dirt]",
|
||||||
"layer": 18,
|
"layer": 18,
|
||||||
|
|
@ -434,7 +442,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "dirt-1",
|
"name": "dirt-1",
|
||||||
"order": "b[natural]-b[dirt]-b[dirt-1]",
|
"order": "b[natural]-b[dirt]-b[dirt-1]",
|
||||||
"layer": 19,
|
"layer": 19,
|
||||||
|
|
@ -450,7 +458,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "dirt-2",
|
"name": "dirt-2",
|
||||||
"order": "b[natural]-b[dirt]-c[dirt-2]",
|
"order": "b[natural]-b[dirt]-c[dirt-2]",
|
||||||
"layer": 20,
|
"layer": 20,
|
||||||
|
|
@ -466,7 +474,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "dirt-3",
|
"name": "dirt-3",
|
||||||
"order": "b[natural]-b[dirt]-d[dirt-3]",
|
"order": "b[natural]-b[dirt]-d[dirt-3]",
|
||||||
"layer": 21,
|
"layer": 21,
|
||||||
|
|
@ -482,7 +490,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "dirt-4",
|
"name": "dirt-4",
|
||||||
"order": "b[natural]-b[dirt]-e[dirt-4]",
|
"order": "b[natural]-b[dirt]-e[dirt-4]",
|
||||||
"layer": 22,
|
"layer": 22,
|
||||||
|
|
@ -498,7 +506,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "dirt-5",
|
"name": "dirt-5",
|
||||||
"order": "b[natural]-b[dirt]-f[dirt-5]",
|
"order": "b[natural]-b[dirt]-f[dirt-5]",
|
||||||
"layer": 23,
|
"layer": 23,
|
||||||
|
|
@ -514,7 +522,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "dirt-6",
|
"name": "dirt-6",
|
||||||
"order": "b[natural]-b[dirt]-g[dirt-6]",
|
"order": "b[natural]-b[dirt]-g[dirt-6]",
|
||||||
"layer": 24,
|
"layer": 24,
|
||||||
|
|
@ -530,7 +538,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "dirt-7",
|
"name": "dirt-7",
|
||||||
"order": "b[natural]-b[dirt]-h[dirt-7]",
|
"order": "b[natural]-b[dirt]-h[dirt-7]",
|
||||||
"layer": 25,
|
"layer": 25,
|
||||||
|
|
@ -546,7 +554,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "sand-1",
|
"name": "sand-1",
|
||||||
"order": "b[natural]-c[sand]-a[sand-1]",
|
"order": "b[natural]-c[sand]-a[sand-1]",
|
||||||
"layer": 8,
|
"layer": 8,
|
||||||
|
|
@ -562,7 +570,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "sand-2",
|
"name": "sand-2",
|
||||||
"order": "b[natural]-c[sand]-b[sand-2]",
|
"order": "b[natural]-c[sand]-b[sand-2]",
|
||||||
"layer": 9,
|
"layer": 9,
|
||||||
|
|
@ -578,7 +586,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "sand-3",
|
"name": "sand-3",
|
||||||
"order": "b[natural]-c[sand]-c[sand-3]",
|
"order": "b[natural]-c[sand]-c[sand-3]",
|
||||||
"layer": 10,
|
"layer": 10,
|
||||||
|
|
@ -594,7 +602,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "red-desert-0",
|
"name": "red-desert-0",
|
||||||
"order": "b[natural]-d[red-desert]-a[red-desert-0]",
|
"order": "b[natural]-d[red-desert]-a[red-desert-0]",
|
||||||
"layer": 31,
|
"layer": 31,
|
||||||
|
|
@ -610,7 +618,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "red-desert-1",
|
"name": "red-desert-1",
|
||||||
"order": "b[natural]-d[red-desert]-b[red-desert-1]",
|
"order": "b[natural]-d[red-desert]-b[red-desert-1]",
|
||||||
"layer": 14,
|
"layer": 14,
|
||||||
|
|
@ -626,7 +634,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "red-desert-2",
|
"name": "red-desert-2",
|
||||||
"order": "b[natural]-d[red-desert]-c[red-desert-2]",
|
"order": "b[natural]-d[red-desert]-c[red-desert-2]",
|
||||||
"layer": 15,
|
"layer": 15,
|
||||||
|
|
@ -642,7 +650,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "red-desert-3",
|
"name": "red-desert-3",
|
||||||
"order": "b[natural]-d[red-desert]-d[red-desert-3]",
|
"order": "b[natural]-d[red-desert]-d[red-desert-3]",
|
||||||
"layer": 16,
|
"layer": 16,
|
||||||
|
|
@ -658,7 +666,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "water",
|
"name": "water",
|
||||||
"order": "c[water]-a[water]",
|
"order": "c[water]-a[water]",
|
||||||
"layer": 3,
|
"layer": 3,
|
||||||
|
|
@ -678,7 +686,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "deepwater",
|
"name": "deepwater",
|
||||||
"order": "c[water]-b[deep-water]",
|
"order": "c[water]-b[deep-water]",
|
||||||
"layer": 3,
|
"layer": 3,
|
||||||
|
|
@ -698,7 +706,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "water-green",
|
"name": "water-green",
|
||||||
"order": "c[water]-c[water-green]",
|
"order": "c[water]-c[water-green]",
|
||||||
"layer": 3,
|
"layer": 3,
|
||||||
|
|
@ -718,7 +726,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "deepwater-green",
|
"name": "deepwater-green",
|
||||||
"order": "c[water]-d[deepwater-green]",
|
"order": "c[water]-d[deepwater-green]",
|
||||||
"layer": 3,
|
"layer": 3,
|
||||||
|
|
@ -738,7 +746,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "water-shallow",
|
"name": "water-shallow",
|
||||||
"order": "c[water]-e[water-shallow]",
|
"order": "c[water]-e[water-shallow]",
|
||||||
"layer": 6,
|
"layer": 6,
|
||||||
|
|
@ -757,7 +765,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "water-mud",
|
"name": "water-mud",
|
||||||
"order": "c[water]-g[water-mud]",
|
"order": "c[water]-g[water-mud]",
|
||||||
"layer": 7,
|
"layer": 7,
|
||||||
|
|
@ -776,7 +784,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "nuclear-ground",
|
"name": "nuclear-ground",
|
||||||
"order": "d[destruction]-a[nuclear]-a[nuclear-ground]",
|
"order": "d[destruction]-a[nuclear]-a[nuclear-ground]",
|
||||||
"layer": 33,
|
"layer": 33,
|
||||||
|
|
@ -792,7 +800,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "water-wube",
|
"name": "water-wube",
|
||||||
"order": "x[wube]-a[water-wube]",
|
"order": "x[wube]-a[water-wube]",
|
||||||
"layer": 2,
|
"layer": 2,
|
||||||
|
|
@ -812,12 +820,11 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "tile-unknown",
|
"name": "tile-unknown",
|
||||||
"order": "z-a",
|
"order": "z-a",
|
||||||
"layer": 0,
|
"layer": 0,
|
||||||
"collisionMasks": {
|
"collisionMasks": {
|
||||||
|
|
||||||
},
|
},
|
||||||
"mapColour": {
|
"mapColour": {
|
||||||
"red": 0,
|
"red": 0,
|
||||||
|
|
@ -828,7 +835,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "out-of-map",
|
"name": "out-of-map",
|
||||||
"order": "z[other]-a[out-of-map]",
|
"order": "z[other]-a[out-of-map]",
|
||||||
"layer": 0,
|
"layer": 0,
|
||||||
|
|
@ -851,7 +858,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "lab-dark-1",
|
"name": "lab-dark-1",
|
||||||
"order": "z[other]-b[lab]-a[lab-dark-1]",
|
"order": "z[other]-b[lab]-a[lab-dark-1]",
|
||||||
"layer": 70,
|
"layer": 70,
|
||||||
|
|
@ -867,7 +874,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "lab-dark-2",
|
"name": "lab-dark-2",
|
||||||
"order": "z[other]-b[lab]-b[lab-dark-2]",
|
"order": "z[other]-b[lab]-b[lab-dark-2]",
|
||||||
"layer": 70,
|
"layer": 70,
|
||||||
|
|
@ -883,7 +890,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "lab-white",
|
"name": "lab-white",
|
||||||
"order": "z[other]-b[lab]-c[lab-white]",
|
"order": "z[other]-b[lab]-c[lab-white]",
|
||||||
"layer": 70,
|
"layer": 70,
|
||||||
|
|
@ -899,7 +906,7 @@ class PrototypesTest : BehaviorSpec({
|
||||||
"canBeMined": false
|
"canBeMined": false
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"prototypeObjectName":"LuaTilePrototype",
|
"type": "dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2.MapTile",
|
||||||
"name": "tutorial-grid",
|
"name": "tutorial-grid",
|
||||||
"order": "z[other]-c[tutorial]-a[tutorial-grid]",
|
"order": "z[other]-c[tutorial]-a[tutorial-grid]",
|
||||||
"layer": 55,
|
"layer": 55,
|
||||||
|
|
@ -916,25 +923,24 @@ class PrototypesTest : BehaviorSpec({
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
Then("expect can be parsed") {
|
Then("expect can be parsed") {
|
||||||
val data: KafkatorioPacket = jsonMapperKafkatorio.decodeFromString(raw)
|
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(raw)
|
||||||
println(data)
|
// println(packet)
|
||||||
|
|
||||||
data.shouldBeInstanceOf<FactorioPrototypes>()
|
packet.data.shouldBeInstanceOf<PrototypesUpdate>()
|
||||||
|
.prototypes
|
||||||
data.prototypes.shouldContain(
|
.forOne {
|
||||||
MapTilePrototype(
|
it.shouldBeInstanceOf<FactorioPrototype2.MapTile>()
|
||||||
name = PrototypeName("tutorial-grid"),
|
it.name shouldBe PrototypeName("tutorial-grid")
|
||||||
order = "z[other]-c[tutorial]-a[tutorial-grid]",
|
it.order shouldBe "z[other]-c[tutorial]-a[tutorial-grid]"
|
||||||
layer = 55u,
|
it.layer shouldBe 55u
|
||||||
collisionMasks = listOf("ground-tile"),
|
it.collisionMasks shouldBe listOf("ground-tile")
|
||||||
mapColour = Colour(122f, 122f, 122f, 255f),
|
it.mapColour shouldBe Colour(122f, 122f, 122f, 255f)
|
||||||
canBeMined = false,
|
it.canBeMined shouldBe false
|
||||||
)
|
}
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,18 @@
|
||||||
package dev.adamko.kafkatorio.events.schema
|
package dev.adamko.kafkatorio.events.schema
|
||||||
|
|
||||||
|
import dev.adamko.kafkatorio.schema.common.Colour
|
||||||
|
import dev.adamko.kafkatorio.schema.common.EntityIdentifiersData
|
||||||
|
import dev.adamko.kafkatorio.schema.common.ForceIndex
|
||||||
|
import dev.adamko.kafkatorio.schema.common.MapEntityPosition
|
||||||
|
import dev.adamko.kafkatorio.schema.common.PlayerIndex
|
||||||
|
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||||
|
import dev.adamko.kafkatorio.schema.common.Tick
|
||||||
|
import dev.adamko.kafkatorio.schema.common.UnitNumber
|
||||||
|
import dev.adamko.kafkatorio.schema.jsonMapperKafkatorio
|
||||||
|
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||||
|
import dev.adamko.kafkatorio.schema2.PlayerUpdate
|
||||||
|
import dev.adamko.kafkatorio.schema2.PlayerUpdateKey
|
||||||
|
import dev.adamko.kafkatorio.schema2.SurfaceUpdate
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import kotlinx.serialization.decodeFromString
|
import kotlinx.serialization.decodeFromString
|
||||||
|
|
@ -13,8 +26,9 @@ class UpdatePacketsTest : FunSpec({
|
||||||
{
|
{
|
||||||
"tick": 66,
|
"tick": 66,
|
||||||
"modVersion": "0.3.2",
|
"modVersion": "0.3.2",
|
||||||
"packetType": "UPDATE",
|
"data": {
|
||||||
"update": {
|
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||||
|
"key": {"index": 1},
|
||||||
"afkTime": 0,
|
"afkTime": 0,
|
||||||
"chatColour": {
|
"chatColour": {
|
||||||
"red": 1,
|
"red": 1,
|
||||||
|
|
@ -33,7 +47,6 @@ class UpdatePacketsTest : FunSpec({
|
||||||
"on_player_joined_game": 1
|
"on_player_joined_game": 1
|
||||||
},
|
},
|
||||||
"forceIndex": 1,
|
"forceIndex": 1,
|
||||||
"index": 1,
|
|
||||||
"isAdmin": true,
|
"isAdmin": true,
|
||||||
"isConnected": true,
|
"isConnected": true,
|
||||||
"isShowOnMap": true,
|
"isShowOnMap": true,
|
||||||
|
|
@ -41,23 +54,20 @@ class UpdatePacketsTest : FunSpec({
|
||||||
"lastOnline": 0,
|
"lastOnline": 0,
|
||||||
"name": "fredthedeadhead",
|
"name": "fredthedeadhead",
|
||||||
"onlineTime": 0,
|
"onlineTime": 0,
|
||||||
"position": {
|
"position": [-58, 13],
|
||||||
"y": 13,
|
"tag": ""
|
||||||
"x": -58
|
|
||||||
},
|
|
||||||
"tag": "",
|
|
||||||
"updateType": "PLAYER"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
test("decode") {
|
test("decode") {
|
||||||
val packet: FactorioEventUpdatePacket = jsonMapperKafkatorio.decodeFromString(json)
|
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||||
|
|
||||||
packet shouldBe FactorioEventUpdatePacket(
|
packet shouldBe KafkatorioPacket2(
|
||||||
modVersion = "0.3.2",
|
modVersion = "0.3.2",
|
||||||
tick = Tick(66u),
|
tick = Tick(66u),
|
||||||
update = PlayerUpdate(
|
data = PlayerUpdate(
|
||||||
|
key = PlayerUpdateKey(PlayerIndex(1u)),
|
||||||
afkTime = Tick(0u),
|
afkTime = Tick(0u),
|
||||||
bannedReason = null,
|
bannedReason = null,
|
||||||
characterUnitNumber = null,
|
characterUnitNumber = null,
|
||||||
|
|
@ -67,7 +77,6 @@ class UpdatePacketsTest : FunSpec({
|
||||||
disconnectReason = null,
|
disconnectReason = null,
|
||||||
eventCounts = mapOf("on_player_changed_position" to 7u, "on_player_joined_game" to 1u),
|
eventCounts = mapOf("on_player_changed_position" to 7u, "on_player_joined_game" to 1u),
|
||||||
forceIndex = ForceIndex(1u),
|
forceIndex = ForceIndex(1u),
|
||||||
index = PlayerIndex(1u),
|
|
||||||
isAdmin = true,
|
isAdmin = true,
|
||||||
isConnected = true,
|
isConnected = true,
|
||||||
isRemoved = null,
|
isRemoved = null,
|
||||||
|
|
@ -86,11 +95,11 @@ class UpdatePacketsTest : FunSpec({
|
||||||
}
|
}
|
||||||
|
|
||||||
test("encode") {
|
test("encode") {
|
||||||
val v = FactorioEventUpdatePacket(
|
val v = KafkatorioPacket2(
|
||||||
modVersion = "0.3.2",
|
modVersion = "0.3.2",
|
||||||
tick = Tick(66u),
|
tick = Tick(66u),
|
||||||
update = PlayerUpdate(
|
data = PlayerUpdate(
|
||||||
index = PlayerIndex(1u),
|
key = PlayerUpdateKey(PlayerIndex(1u)),
|
||||||
characterUnitNumber = null,
|
characterUnitNumber = null,
|
||||||
chatColour = null,
|
chatColour = null,
|
||||||
colour = null,
|
colour = null,
|
||||||
|
|
@ -121,21 +130,22 @@ class UpdatePacketsTest : FunSpec({
|
||||||
{
|
{
|
||||||
"modVersion": "0.3.2",
|
"modVersion": "0.3.2",
|
||||||
"tick": 66,
|
"tick": 66,
|
||||||
"update": {
|
"data": {
|
||||||
"index": 1,
|
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||||
|
"key": {
|
||||||
|
"index": 1
|
||||||
|
},
|
||||||
"name": "fredthedeadhead",
|
"name": "fredthedeadhead",
|
||||||
"afkTime": 0,
|
"afkTime": 0,
|
||||||
"isShowOnMap": true,
|
"isShowOnMap": true,
|
||||||
"isSpectator": false,
|
"isSpectator": false,
|
||||||
"lastOnline": 0,
|
"lastOnline": 0,
|
||||||
"onlineTime": 0,
|
"onlineTime": 0,
|
||||||
"position": {
|
"position": [
|
||||||
"x": -58.0,
|
-58.0,
|
||||||
"y": 13.0
|
13.0
|
||||||
},
|
]
|
||||||
"updateType": "PLAYER"
|
}
|
||||||
},
|
|
||||||
"packetType": "UPDATE"
|
|
||||||
}
|
}
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
@ -147,10 +157,11 @@ class UpdatePacketsTest : FunSpec({
|
||||||
{
|
{
|
||||||
"tick": 227934,
|
"tick": 227934,
|
||||||
"modVersion": "0.3.2",
|
"modVersion": "0.3.2",
|
||||||
"packetType": "UPDATE",
|
"data": {
|
||||||
"update": {
|
"type": "dev.adamko.kafkatorio.schema2.PlayerUpdate",
|
||||||
"index": 1,
|
"key": {
|
||||||
"updateType": "PLAYER",
|
"index": 1
|
||||||
|
},
|
||||||
"lastOnline": 227932,
|
"lastOnline": 227932,
|
||||||
"onlineTime": 227888,
|
"onlineTime": 227888,
|
||||||
"afkTime": 324,
|
"afkTime": 324,
|
||||||
|
|
@ -158,7 +169,7 @@ class UpdatePacketsTest : FunSpec({
|
||||||
"diedCause": {
|
"diedCause": {
|
||||||
"unitNumber": 66,
|
"unitNumber": 66,
|
||||||
"name": "small-biter",
|
"name": "small-biter",
|
||||||
"type": "unit"
|
"protoType": "unit"
|
||||||
},
|
},
|
||||||
"eventCounts": {
|
"eventCounts": {
|
||||||
"on_player_died": 2
|
"on_player_died": 2
|
||||||
|
|
@ -168,12 +179,12 @@ class UpdatePacketsTest : FunSpec({
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
|
|
||||||
test("decode") {
|
test("decode") {
|
||||||
val packet: FactorioEventUpdatePacket = jsonMapperKafkatorio.decodeFromString(json)
|
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||||
|
|
||||||
packet shouldBe FactorioEventUpdatePacket(
|
packet shouldBe KafkatorioPacket2(
|
||||||
modVersion = "0.3.2",
|
modVersion = "0.3.2",
|
||||||
tick = Tick(227934u),
|
tick = Tick(227934u),
|
||||||
update = PlayerUpdate(
|
data = PlayerUpdate(
|
||||||
afkTime = Tick(324u),
|
afkTime = Tick(324u),
|
||||||
bannedReason = null,
|
bannedReason = null,
|
||||||
characterUnitNumber = null,
|
characterUnitNumber = null,
|
||||||
|
|
@ -182,12 +193,12 @@ class UpdatePacketsTest : FunSpec({
|
||||||
diedCause = EntityIdentifiersData(
|
diedCause = EntityIdentifiersData(
|
||||||
unitNumber = UnitNumber(66u),
|
unitNumber = UnitNumber(66u),
|
||||||
name = "small-biter",
|
name = "small-biter",
|
||||||
type = "unit",
|
protoType = "unit",
|
||||||
),
|
),
|
||||||
disconnectReason = null,
|
disconnectReason = null,
|
||||||
eventCounts = mapOf("on_player_died" to 2u),
|
eventCounts = mapOf("on_player_died" to 2u),
|
||||||
forceIndex = null,
|
forceIndex = null,
|
||||||
index = PlayerIndex(1u),
|
key = PlayerUpdateKey(PlayerIndex(1u)),
|
||||||
isAdmin = null,
|
isAdmin = null,
|
||||||
isConnected = true,
|
isConnected = true,
|
||||||
isRemoved = null,
|
isRemoved = null,
|
||||||
|
|
@ -204,7 +215,38 @@ class UpdatePacketsTest : FunSpec({
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
context("surface update") {
|
||||||
|
//language=json
|
||||||
|
val json = """
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"type": "dev.adamko.kafkatorio.schema2.SurfaceUpdate",
|
||||||
|
"name": "nauvis",
|
||||||
|
"index": 1,
|
||||||
|
"daytime": 0.73
|
||||||
|
},
|
||||||
|
"modVersion": "0.3.2",
|
||||||
|
"tick": 176000
|
||||||
|
}
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
|
val expected = KafkatorioPacket2(
|
||||||
|
tick = Tick(176000u),
|
||||||
|
modVersion = "0.3.2",
|
||||||
|
data = SurfaceUpdate(
|
||||||
|
name = "nauvis",
|
||||||
|
index = SurfaceIndex(1u),
|
||||||
|
daytime = 0.73,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
println(jsonMapperKafkatorio.encodeToString(expected))
|
||||||
|
|
||||||
|
test("decode") {
|
||||||
|
val packet: KafkatorioPacket2 = jsonMapperKafkatorio.decodeFromString(json)
|
||||||
|
packet shouldBe expected
|
||||||
|
}
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,19 @@
|
||||||
package dev.adamko.kafkatorio.processor.topology
|
package dev.adamko.kafkatorio.processor.topology
|
||||||
|
|
||||||
import dev.adamko.kafkatorio.processor.KafkatorioTopology
|
|
||||||
import dev.adamko.kafkatorio.processor.admin.TOPIC_GROUPED_MAP_CHUNKS_STATE
|
import dev.adamko.kafkatorio.processor.admin.TOPIC_GROUPED_MAP_CHUNKS_STATE
|
||||||
import dev.adamko.kafkatorio.processor.serdes.jsonMapper
|
import dev.adamko.kafkatorio.processor.serdes.jsonMapper
|
||||||
import dev.adamko.kafkatorio.processor.serdes.kxsBinary
|
import dev.adamko.kafkatorio.processor.serdes.kxsBinary
|
||||||
import dev.adamko.kafkatorio.schema.common.*
|
import dev.adamko.kafkatorio.schema.common.Colour
|
||||||
|
import dev.adamko.kafkatorio.schema.common.ColourHex
|
||||||
|
import dev.adamko.kafkatorio.schema.common.MapChunkPosition
|
||||||
|
import dev.adamko.kafkatorio.schema.common.MapTileDictionary
|
||||||
import dev.adamko.kafkatorio.schema.common.MapTileDictionary.PrototypeKey
|
import dev.adamko.kafkatorio.schema.common.MapTileDictionary.PrototypeKey
|
||||||
|
import dev.adamko.kafkatorio.schema.common.MapTilePosition
|
||||||
|
import dev.adamko.kafkatorio.schema.common.PrototypeName
|
||||||
|
import dev.adamko.kafkatorio.schema.common.SurfaceIndex
|
||||||
|
import dev.adamko.kafkatorio.schema.common.Tick
|
||||||
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
import dev.adamko.kafkatorio.schema.prototypes.FactorioPrototype2
|
||||||
|
import dev.adamko.kafkatorio.schema2.KafkatorioPacket2
|
||||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdate
|
import dev.adamko.kafkatorio.schema2.MapChunkUpdate
|
||||||
import dev.adamko.kafkatorio.schema2.MapChunkUpdateKey
|
import dev.adamko.kafkatorio.schema2.MapChunkUpdateKey
|
||||||
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
import dev.adamko.kafkatorio.schema2.PrototypesUpdate
|
||||||
|
|
@ -28,24 +35,27 @@ class GroupMapChunksTest : FunSpec({
|
||||||
test("basic test") {
|
test("basic test") {
|
||||||
val streamsBuilder = StreamsBuilder()
|
val streamsBuilder = StreamsBuilder()
|
||||||
|
|
||||||
val prototypesTopicName = "prototypes-topic"
|
val prototypesTopicName = "kafkatorio.packet.prototypes"
|
||||||
val mapChunkUpdatesTopicName = "map-chunk-updates-topic"
|
val mapChunkUpdatesTopicName = "kafkatorio.packet.map-chunk"
|
||||||
|
|
||||||
val topology = groupMapChunks(streamsBuilder)
|
val topology = groupMapChunks(streamsBuilder)
|
||||||
|
|
||||||
val testDriver = TopologyTestDriver(topology)
|
val testDriver = TopologyTestDriver(topology)
|
||||||
|
|
||||||
val prototypesTestInputTopic: TestInputTopic<FactorioServerId, PrototypesUpdate> =
|
val prototypesTestInputTopic: TestInputTopic<FactorioServerId, KafkatorioPacket2> =
|
||||||
testDriver.createInputTopic(
|
testDriver.createInputTopic(
|
||||||
prototypesTopicName,
|
prototypesTopicName,
|
||||||
jsonMapper.serde<FactorioServerId>().serializer(),
|
jsonMapper.serde<FactorioServerId>().serializer(),
|
||||||
jsonMapper.serde<PrototypesUpdate>().serializer(),
|
jsonMapper.serde<KafkatorioPacket2>().serializer(),
|
||||||
)
|
)
|
||||||
|
|
||||||
val serverId = FactorioServerId("test-server-id")
|
val serverId = FactorioServerId("test-server-id")
|
||||||
|
|
||||||
prototypesTestInputTopic.pipeInput(
|
prototypesTestInputTopic.pipeInput(
|
||||||
serverId,
|
serverId,
|
||||||
|
KafkatorioPacket2(
|
||||||
|
modVersion = "1.2.3",
|
||||||
|
tick = Tick(22u),
|
||||||
PrototypesUpdate(
|
PrototypesUpdate(
|
||||||
listOf(
|
listOf(
|
||||||
FactorioPrototype2.MapTile(
|
FactorioPrototype2.MapTile(
|
||||||
|
|
@ -59,16 +69,20 @@ class GroupMapChunksTest : FunSpec({
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val mapChunkUpdatesInputTopic: TestInputTopic<FactorioServerId, MapChunkUpdate> =
|
val mapChunkUpdatesInputTopic: TestInputTopic<FactorioServerId, KafkatorioPacket2> =
|
||||||
testDriver.createInputTopic(
|
testDriver.createInputTopic(
|
||||||
mapChunkUpdatesTopicName,
|
mapChunkUpdatesTopicName,
|
||||||
jsonMapper.serde<FactorioServerId>().serializer(),
|
jsonMapper.serde<FactorioServerId>().serializer(),
|
||||||
jsonMapper.serde<MapChunkUpdate>().serializer(),
|
jsonMapper.serde<KafkatorioPacket2>().serializer(),
|
||||||
)
|
)
|
||||||
|
|
||||||
mapChunkUpdatesInputTopic.pipeInput(
|
mapChunkUpdatesInputTopic.pipeInput(
|
||||||
serverId,
|
serverId,
|
||||||
|
KafkatorioPacket2(
|
||||||
|
modVersion = "1.2.3",
|
||||||
|
tick = Tick(44u),
|
||||||
MapChunkUpdate(
|
MapChunkUpdate(
|
||||||
key = MapChunkUpdateKey(
|
key = MapChunkUpdateKey(
|
||||||
MapChunkPosition(11, 22),
|
MapChunkPosition(11, 22),
|
||||||
|
|
@ -82,6 +96,7 @@ class GroupMapChunksTest : FunSpec({
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
)
|
||||||
|
|
||||||
val outputTopic: TestOutputTopic<ServerMapChunkId, ServerMapChunkTiles<ColourHex>> =
|
val outputTopic: TestOutputTopic<ServerMapChunkId, ServerMapChunkTiles<ColourHex>> =
|
||||||
testDriver
|
testDriver
|
||||||
|
|
@ -114,5 +129,4 @@ class GroupMapChunksTest : FunSpec({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue