From 0bc84924c329e7cadc3726251ab032c307c6491a Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Tue, 15 Jan 2019 19:06:06 +0100 Subject: [PATCH] Moved tile & entity type to separate code unit. --- soko/entitytype.go | 23 +++++++++++++++++++++++ soko/level.go | 41 ----------------------------------------- soko/tile.go | 21 +++++++++++++++++++++ 3 files changed, 44 insertions(+), 41 deletions(-) create mode 100644 soko/entitytype.go create mode 100644 soko/tile.go diff --git a/soko/entitytype.go b/soko/entitytype.go new file mode 100644 index 0000000..6be1485 --- /dev/null +++ b/soko/entitytype.go @@ -0,0 +1,23 @@ +package soko + +type EntityType byte + +const ( + EntityTypeInvalid EntityType = EntityType(0) + EntityTypeNone = '_' + EntityTypeCharacter = '@' + EntityTypeEgg = 'X' + EntityTypeBrick = 'B' +) + +func (e EntityType) IsValid() bool { + switch e { + case EntityTypeNone: + case EntityTypeCharacter: + case EntityTypeEgg: + case EntityTypeBrick: + default: + return false + } + return true +} diff --git a/soko/level.go b/soko/level.go index beaed7a..a681746 100644 --- a/soko/level.go +++ b/soko/level.go @@ -4,47 +4,6 @@ import ( "opslag.de/schobers/geom" ) -type EntityType byte -type Tile byte - -const ( - EntityTypeInvalid EntityType = EntityType(0) - EntityTypeNone = '_' - EntityTypeCharacter = '@' - EntityTypeEgg = 'X' - EntityTypeBrick = 'B' -) - -func (e EntityType) IsValid() bool { - switch e { - case EntityTypeNone: - case EntityTypeCharacter: - case EntityTypeEgg: - case EntityTypeBrick: - default: - return false - } - return true -} - -const ( - TileInvalid Tile = Tile(0) - TileNothing = '.' - TileBasic = '#' - TileMagma = '~' -) - -func (t Tile) IsValid() bool { - switch t { - case TileNothing: - case TileBasic: - case TileMagma: - default: - return false - } - return true -} - type Level struct { Width int Height int diff --git a/soko/tile.go b/soko/tile.go new file mode 100644 index 0000000..af92fc8 --- /dev/null +++ b/soko/tile.go @@ -0,0 +1,21 @@ +package soko + +type Tile byte + +const ( + TileInvalid Tile = Tile(0) + TileNothing = '.' + TileBasic = '#' + TileMagma = '~' +) + +func (t Tile) IsValid() bool { + switch t { + case TileNothing: + case TileBasic: + case TileMagma: + default: + return false + } + return true +}