From 7cc820ee054ce39cebdcf5e4f085846674254d05 Mon Sep 17 00:00:00 2001 From: Bryson Zimmerman Date: Sat, 26 Oct 2024 13:16:57 -0400 Subject: [PATCH] TileProperties: Fixed toString, fixed bitflag maths... by putting it back to the way it was --- src/main/kotlin/data/TileProperties.kt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/kotlin/data/TileProperties.kt b/src/main/kotlin/data/TileProperties.kt index 1a79d67..1bdfc1a 100644 --- a/src/main/kotlin/data/TileProperties.kt +++ b/src/main/kotlin/data/TileProperties.kt @@ -30,27 +30,27 @@ value class TileProperties(val connections: Int) { } operator fun plus(dir: Directions): TileProperties { - return TileProperties(connections + dir.dir) + return TileProperties(connections or(dir.dir)) } operator fun minus(dir: Directions): TileProperties { - return TileProperties(connections - dir.dir) + return TileProperties(connections and dir.dir.inv()) } fun isWest(): Boolean { - return connections and(LEFT.dir) != 0 + return connections and(LEFT.dir) == LEFT.dir } fun isEast():Boolean { - return connections and(RIGHT.dir) != 0 + return connections and(RIGHT.dir) == RIGHT.dir } fun isNorth(): Boolean { - return connections and(UP.dir) != 0 + return connections and(UP.dir) == UP.dir } fun isSouth():Boolean { - return connections and(DOWN.dir) != 0 + return connections and(DOWN.dir) == DOWN.dir } override fun toString():String { @@ -73,8 +73,9 @@ value class TileProperties(val connections: Int) { ret.append(", ") ret.append("SOUTH") } + ret.append(": $connections") - return "" + return ret.toString() } } \ No newline at end of file