|
|
@ -10,12 +10,8 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
type gameView struct {
|
|
|
|
type gameView struct {
|
|
|
|
*blammo.Log
|
|
|
|
*blammo.Log
|
|
|
|
roomName string
|
|
|
|
room *wire.Room
|
|
|
|
width int
|
|
|
|
me *wire.Entity
|
|
|
|
height int
|
|
|
|
|
|
|
|
me wire.Entity
|
|
|
|
|
|
|
|
allRooms map[string]wire.Room
|
|
|
|
|
|
|
|
allEntities map[int]wire.Entity
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (v *gameView) handleEvent(ui *UI, e tcell.Event) bool {
|
|
|
|
func (v *gameView) handleEvent(ui *UI, e tcell.Event) bool {
|
|
|
@ -40,59 +36,42 @@ func (v *gameView) handleEvent(ui *UI, e tcell.Event) bool {
|
|
|
|
return true
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (v *gameView) notify(wv wire.Value) {
|
|
|
|
|
|
|
|
v.Error("ignoring notifications at the moment: %v", wv)
|
|
|
|
|
|
|
|
switch z := wv.(type) {
|
|
|
|
|
|
|
|
case *wire.UpdateEntity:
|
|
|
|
|
|
|
|
if z.Room == v.roomName {
|
|
|
|
|
|
|
|
v.Info("we want to read this one: %v", z)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (v *gameView) move(ui *UI, dx, dy int) {
|
|
|
|
func (v *gameView) move(ui *UI, dx, dy int) {
|
|
|
|
reply, err := ui.client.Send(sim.Move{dx, dy})
|
|
|
|
reply, err := ui.client.Send(sim.Move{dx, dy})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
e := reply.Body.(*wire.UpdateEntity)
|
|
|
|
e := reply.Body.(*wire.Entity)
|
|
|
|
// ughhhhhh
|
|
|
|
v.room.Entities[e.ID] = e
|
|
|
|
v.me = wire.Entity{
|
|
|
|
v.me = e
|
|
|
|
ID: e.ID,
|
|
|
|
|
|
|
|
Position: e.Position,
|
|
|
|
|
|
|
|
Glyph: e.Glyph,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
v.allEntities[e.ID] = v.me
|
|
|
|
|
|
|
|
// jfc this sucks
|
|
|
|
|
|
|
|
v.allRooms[v.roomName].Entities[e.ID] = v.me
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func (v *gameView) draw(ui *UI) {
|
|
|
|
func (v *gameView) draw(ui *UI) {
|
|
|
|
offset := point{1, 1}
|
|
|
|
offset := point{1, 1}
|
|
|
|
|
|
|
|
|
|
|
|
// fill in background dots first
|
|
|
|
// fill in background dots first
|
|
|
|
for x := 0; x < v.width; x++ {
|
|
|
|
for x := 0; x < v.room.Width(); x++ {
|
|
|
|
for y := 0; y < v.height; y++ {
|
|
|
|
for y := 0; y < v.room.Height(); y++ {
|
|
|
|
ui.screen.SetContent(x+offset.x, y+offset.y, '·', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(x+offset.x, y+offset.y, '·', nil, tcell.StyleDefault)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// frame it
|
|
|
|
// frame it
|
|
|
|
ui.screen.SetContent(offset.x-1, offset.y-1, '┌', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x-1, offset.y-1, '┌', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x+v.width, offset.y-1, '┐', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x+v.room.Width(), offset.y-1, '┐', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x-1, offset.y+v.height, '└', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x-1, offset.y+v.room.Height(), '└', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x+v.width, offset.y+v.height, '┘', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x+v.room.Width(), offset.y+v.room.Height(), '┘', nil, tcell.StyleDefault)
|
|
|
|
for x := 0; x < v.width; x++ {
|
|
|
|
for x := 0; x < v.room.Width(); x++ {
|
|
|
|
ui.screen.SetContent(x+offset.x, offset.y-1, '─', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(x+offset.x, offset.y-1, '─', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(x+offset.x, offset.y+v.height, '─', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(x+offset.x, offset.y+v.room.Height(), '─', nil, tcell.StyleDefault)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for y := 0; y < v.height; y++ {
|
|
|
|
for y := 0; y < v.room.Height(); y++ {
|
|
|
|
ui.screen.SetContent(offset.x-1, y+offset.y, '│', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x-1, y+offset.y, '│', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x+v.width, y+offset.y, '│', nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(offset.x+v.room.Width(), y+offset.y, '│', nil, tcell.StyleDefault)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for _, e := range v.allRooms[v.roomName].Entities {
|
|
|
|
for _, e := range v.room.Entities {
|
|
|
|
pos := e.Position.Add(math.Vec{1, 1})
|
|
|
|
pos := e.Position.Add(math.Vec{1, 1})
|
|
|
|
ui.screen.SetContent(pos.X, pos.Y, e.Glyph, nil, tcell.StyleDefault)
|
|
|
|
ui.screen.SetContent(pos.X, pos.Y, e.Glyph, nil, tcell.StyleDefault)
|
|
|
|
}
|
|
|
|
}
|
|
|
|