fixed problem

This commit is contained in:
Joel M. Southall 2019-07-24 21:04:21 -07:00
parent 733ffe3380
commit 3dcf69715a
4 changed files with 17 additions and 12 deletions

View File

@ -15,13 +15,13 @@ type Entity struct {
} }
// NewEntity returns an interface to a new populated Entity. // 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{ return &Entity{
x: x, x: x,
y: y, y: y,
rune: r, rune: r,
style: style, style: style,
name: name, name: name,
flags: flags, flags: flags,
} }
} }

View File

@ -14,4 +14,8 @@ type Entity interface {
Style() goro.Style Style() goro.Style
SetStyle(goro.Style) SetStyle(goro.Style)
Move(int, int) Move(int, int)
Name() string
SetName(string)
Flags() uint
SetFlags(uint)
} }

View File

@ -8,5 +8,5 @@ type GameMap interface {
IsOpaque(x, y int) bool IsOpaque(x, y int) bool
Explored(x, y int) bool Explored(x, y int) bool
SetExplored(x, y int, explored bool) SetExplored(x, y int, explored bool)
MakeMap(maxRooms, roomMinSize, roomMaxSize int, player Entity) MakeMap(maxRooms, roomMinSize, roomMaxSize int, entities *[]Entity, maxMonsters int)
} }

19
main.go
View File

@ -1,6 +1,7 @@
package main package main
import ( import (
"fmt"
"log" "log"
"steel/entity" "steel/entity"
"steel/interfaces" "steel/interfaces"
@ -76,17 +77,17 @@ func main() {
if !gameMap.IsBlocked(x, y) { if !gameMap.IsBlocked(x, y) {
otherEntity := entity.FindEntityAtLocation(entities, x, y, entity.BlockMovement, entity.BlockMovement) otherEntity := entity.FindEntityAtLocation(entities, x, y, entity.BlockMovement, entity.BlockMovement)
if otherEntity != nil { if otherEntity != nil {
fmt.Printf("You lick the %s in the shins, much to its enjoyment!\n", otherEntity.Name()) fmt.Printf("You lick the %s in the shins, much to its enjoyment!\n", otherEntity.Name())
} else { } else {
player.Move(action.X, action.Y) player.Move(action.X, action.Y)
forRecompute = true fovRecompute = true
}
} }
gameState = NPCTurnState
} }
gameState = NPCTurnState case ActionQuit:
goro.Quit()
} }
case ActionQuit:
goro.Quit()
}
case goro.EventQuit: case goro.EventQuit:
return return
} }
@ -95,7 +96,7 @@ func main() {
if gameState == NPCTurnState { if gameState == NPCTurnState {
for i, e := range entities { for i, e := range entities {
if i > 0 { if i > 0 {
fmt.Printf("The &s punders.\n", e.Name()) fmt.Printf("The %s punders.\n", e.Name())
} }
} }
gameState = PlayerTurnState gameState = PlayerTurnState