From 3dcf69715ad1c0d3ebd0f5fb206f885aab504251 Mon Sep 17 00:00:00 2001 From: gmzar Date: Wed, 24 Jul 2019 21:04:21 -0700 Subject: [PATCH] fixed problem --- entity/entity.go | 4 ++-- interfaces/entity.go | 4 ++++ interfaces/gamemap.go | 2 +- main.go | 19 ++++++++++--------- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/entity/entity.go b/entity/entity.go index e86df88..e7529c8 100644 --- a/entity/entity.go +++ b/entity/entity.go @@ -15,13 +15,13 @@ type Entity struct { } // NewEntity returns an interface to a new populated Entity. -func NewEntity(x int, y int, r rune, style goro.Style, name string, flags Flags) interfaces.Entity { +func NewEntity(x int, y int, r rune, style goro.Style, name string, flags uint) interfaces.Entity { return &Entity{ x: x, y: y, rune: r, style: style, - name: name, + name: name, flags: flags, } } diff --git a/interfaces/entity.go b/interfaces/entity.go index b6afac4..a9723ce 100644 --- a/interfaces/entity.go +++ b/interfaces/entity.go @@ -14,4 +14,8 @@ type Entity interface { Style() goro.Style SetStyle(goro.Style) Move(int, int) + Name() string + SetName(string) + Flags() uint + SetFlags(uint) } diff --git a/interfaces/gamemap.go b/interfaces/gamemap.go index 89f77de..d103eb9 100644 --- a/interfaces/gamemap.go +++ b/interfaces/gamemap.go @@ -8,5 +8,5 @@ type GameMap interface { IsOpaque(x, y int) bool Explored(x, y int) bool SetExplored(x, y int, explored bool) - MakeMap(maxRooms, roomMinSize, roomMaxSize int, player Entity) + MakeMap(maxRooms, roomMinSize, roomMaxSize int, entities *[]Entity, maxMonsters int) } diff --git a/main.go b/main.go index d416f51..affcee7 100644 --- a/main.go +++ b/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "log" "steel/entity" "steel/interfaces" @@ -76,17 +77,17 @@ func main() { if !gameMap.IsBlocked(x, y) { otherEntity := entity.FindEntityAtLocation(entities, x, y, entity.BlockMovement, entity.BlockMovement) if otherEntity != nil { - fmt.Printf("You lick the %s in the shins, much to its enjoyment!\n", otherEntity.Name()) - } else { - player.Move(action.X, action.Y) - forRecompute = true + fmt.Printf("You lick the %s in the shins, much to its enjoyment!\n", otherEntity.Name()) + } else { + player.Move(action.X, action.Y) + fovRecompute = true + } } + gameState = NPCTurnState } - gameState = NPCTurnState + case ActionQuit: + goro.Quit() } - case ActionQuit: - goro.Quit() - } case goro.EventQuit: return } @@ -95,7 +96,7 @@ func main() { if gameState == NPCTurnState { for i, e := range entities { if i > 0 { - fmt.Printf("The &s punders.\n", e.Name()) + fmt.Printf("The %s punders.\n", e.Name()) } } gameState = PlayerTurnState