diff options
author | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-17 14:31:45 +0200 |
---|---|---|
committer | Joel Kronqvist <joel.kronqvist@iki.fi> | 2024-11-17 14:31:45 +0200 |
commit | a6b0330c845d4edad87c7059bac56e194a276c6f (patch) | |
tree | 912a897b01a9eec59c552752e053255cf2a041ff | |
parent | 5060c66738898913ca880d83b0fdcd5be2e0b59d (diff) | |
download | scalevalapokalypsi-a6b0330c845d4edad87c7059bac56e194a276c6f.tar.gz scalevalapokalypsi-a6b0330c845d4edad87c7059bac56e194a276c6f.zip |
UTF-8 support & fixed hard coded 'Alice'
-rw-r--r-- | src/scalevalapokalypsi/Model/Adventure.scala | 7 | ||||
-rw-r--r-- | src/scalevalapokalypsi/Model/Entities/Entity.scala | 2 | ||||
-rw-r--r-- | src/scalevalapokalypsi/utils/utils.scala | 5 |
3 files changed, 7 insertions, 7 deletions
diff --git a/src/scalevalapokalypsi/Model/Adventure.scala b/src/scalevalapokalypsi/Model/Adventure.scala index e751280..9d07ba6 100644 --- a/src/scalevalapokalypsi/Model/Adventure.scala +++ b/src/scalevalapokalypsi/Model/Adventure.scala @@ -31,10 +31,9 @@ class Adventure(val playerNames: Vector[String]): clearing.addItem(Item("battery", "It's a small battery cell. Looks new.")) southForest.addItem(Item( - "remote", - "It's the remote control for your TV.\n" + - "What it was doing in the forest, you have no idea.\n" + - "Problem is, there's no battery." + "laulukäärö", + "Jukranpujut, löysit laulukäärön!\n" + + "Et vielä voi tehdä sillä mitään, koska et edes osaa laula." )) val players: Map[String, Player] = Map() diff --git a/src/scalevalapokalypsi/Model/Entities/Entity.scala b/src/scalevalapokalypsi/Model/Entities/Entity.scala index ff5b320..b90a61a 100644 --- a/src/scalevalapokalypsi/Model/Entities/Entity.scala +++ b/src/scalevalapokalypsi/Model/Entities/Entity.scala @@ -61,7 +61,7 @@ class Entity(val name: String, initialLocation: Area): ) def sayTo(entity: Entity, message: String): (String, String) = - entity.observe(s"Alice: \"$message\"") + entity.observe(s"${this.name}: \"$message\"") (s"You say so to ${entity.name}.", "") def say(message: String): (String, String) = diff --git a/src/scalevalapokalypsi/utils/utils.scala b/src/scalevalapokalypsi/utils/utils.scala index b1bac4d..ab262ad 100644 --- a/src/scalevalapokalypsi/utils/utils.scala +++ b/src/scalevalapokalypsi/utils/utils.scala @@ -1,6 +1,7 @@ package scalevalapokalypsi.utils import java.io.InputStream +import java.nio.charset.StandardCharsets /** Converts this string to an array of bytes (probably for transmission). * @@ -8,7 +9,7 @@ import java.io.InputStream * @return an array of bytes representing the string in UTF8. */ def stringToByteArray(str: String): Array[Byte] = - str.toVector.map(_.toByte).toArray + str.getBytes(StandardCharsets.UTF_8) /** Reads n characters from the given InputStream blockingly. * @@ -25,4 +26,4 @@ def getNCharsFromSocket(input: InputStream, n: Int): Option[String] = if res < 0 then failed = true i += res // TODO: better error handling - if failed then None else Some(String(buffer)) + if failed then None else Some(String(buffer, StandardCharsets.UTF_8)) |