From a470e30a4155162f14e92fa60f6288da97ce9fc8 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Fri, 6 Nov 2020 21:25:37 +0000 Subject: [PATCH] kitchen --- internal/app/status_bar.go | 2 +- internal/app/ui.go | 3 +++ internal/sim/world.go | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 38 insertions(+), 4 deletions(-) diff --git a/internal/app/status_bar.go b/internal/app/status_bar.go index f2db4c1..184d6c1 100644 --- a/internal/app/status_bar.go +++ b/internal/app/status_bar.go @@ -18,7 +18,7 @@ func (s *statusBar) draw(b *buffer) { if s.ui == nil { return } - line := fmt.Sprintf("shown: %08d cleared: %08d", s.ui.showCount, s.ui.clearCount) + line := fmt.Sprintf("shown: %08d cleared: %08d messages: %08d", s.ui.showCount, s.ui.clearCount, s.ui.msgCount) b.writeString(line, math.Vec{0, 0}, tcell.StyleDefault) } diff --git a/internal/app/ui.go b/internal/app/ui.go index 339e41c..d836dca 100644 --- a/internal/app/ui.go +++ b/internal/app/ui.go @@ -17,6 +17,8 @@ type UI struct { screen tcell.Screen room *wire.Room client *wire.Client + + msgCount int showCount int clearCount int @@ -122,6 +124,7 @@ func (ui *UI) clearTerminal() { func (ui *UI) handleNotifications(c <-chan wire.Response) { for n := range c { + ui.msgCount++ if ui.handleNotification(n.Body) { if ui.gameView != nil { ui.render() diff --git a/internal/sim/world.go b/internal/sim/world.go index 4d77e8a..e7671da 100644 --- a/internal/sim/world.go +++ b/internal/sim/world.go @@ -76,7 +76,7 @@ func newWorld(log *blammo.Log) *world { Log: log.Child("hall"), name: "hall", Rect: math.CreateRect(20, 4), - tiles: make([]tile, bounds.Area()), + tiles: make([]tile, 80), players: make(map[string]*player), } @@ -91,12 +91,43 @@ func newWorld(log *blammo.Log) *world { }, }) + kitchen := room{ + Log: log.Child("kitchen"), + name: "kitchen", + Rect: math.CreateRect(6, 12), + tiles: make([]tile, 72), + players: make(map[string]*player), + } + + foyer.addEntity(&entity{ + ID: -6, + Position: math.Vec{9, 7}, + Glyph: '◇', + behavior: &door{ + Log: log.Child("door"), + to: "kitchen", + exit: -7, + }, + }) + + kitchen.addEntity(&entity{ + ID: -7, + Position: math.Vec{0, 2}, + Glyph: '◇', + behavior: &door{ + Log: log.Child("door"), + to: "foyer", + exit: -6, + }, + }) + log.Info("created foyer with bounds: %#v having width: %d height: %d area: %d", foyer.Rect, foyer.Width, foyer.Height, foyer.Area()) return &world{ Log: log, rooms: map[string]*room{ - "foyer": &foyer, - "hall": &hall, + "foyer": &foyer, + "hall": &hall, + "kitchen": &kitchen, }, done: make(chan bool), inbox: make(chan Request),