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