From df1ec0bd923b5b7106c48c2cc58af18c6e7585b4 Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR Date: Fri, 1 Oct 2021 10:43:19 -0300 Subject: [PATCH 1/2] Serialize NumberChoice as a Double, not as a String --- common/src/main/kotlin/entity/Interactions.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/common/src/main/kotlin/entity/Interactions.kt b/common/src/main/kotlin/entity/Interactions.kt index d5c975d1163f..9a79183a0521 100644 --- a/common/src/main/kotlin/entity/Interactions.kt +++ b/common/src/main/kotlin/entity/Interactions.kt @@ -169,6 +169,7 @@ sealed class Choice { encoder.encodeStructure(descriptor) { encodeStringElement(descriptor, 0, value.name) if (value is IntChoice) encodeIntElement(descriptor, 1, value.value) + if (value is NumberChoice) encodeDoubleElement(descriptor, 1, value.value) else encodeStringElement(descriptor, 1, value.value.toString()) } } From ff8a2198d0d4fb39fe500a1ed16f5d359f82963f Mon Sep 17 00:00:00 2001 From: MrPowerGamerBR Date: Fri, 1 Oct 2021 10:48:20 -0300 Subject: [PATCH 2/2] Change if to when --- common/src/main/kotlin/entity/Interactions.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/entity/Interactions.kt b/common/src/main/kotlin/entity/Interactions.kt index 9a79183a0521..d6256a5817a3 100644 --- a/common/src/main/kotlin/entity/Interactions.kt +++ b/common/src/main/kotlin/entity/Interactions.kt @@ -168,9 +168,11 @@ sealed class Choice { override fun serialize(encoder: Encoder, value: Choice<*>) { encoder.encodeStructure(descriptor) { encodeStringElement(descriptor, 0, value.name) - if (value is IntChoice) encodeIntElement(descriptor, 1, value.value) - if (value is NumberChoice) encodeDoubleElement(descriptor, 1, value.value) - else encodeStringElement(descriptor, 1, value.value.toString()) + when (value) { + is IntChoice -> encodeIntElement(descriptor, 1, value.value) + is NumberChoice -> encodeDoubleElement(descriptor, 1, value.value) + else -> encodeStringElement(descriptor, 1, value.value.toString()) + } } } }