|
|
@ -6,6 +6,7 @@ import (
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
|
|
"github.com/gdamore/tcell/v2"
|
|
|
|
"github.com/jordanorelli/astro-domu/internal/math"
|
|
|
|
"github.com/jordanorelli/astro-domu/internal/math"
|
|
|
|
"github.com/jordanorelli/astro-domu/internal/sim"
|
|
|
|
"github.com/jordanorelli/astro-domu/internal/sim"
|
|
|
|
|
|
|
|
"github.com/jordanorelli/astro-domu/internal/wire"
|
|
|
|
"github.com/jordanorelli/blammo"
|
|
|
|
"github.com/jordanorelli/blammo"
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
@ -225,19 +226,24 @@ func (p pickup) exec(ui *UI) {
|
|
|
|
go func() {
|
|
|
|
go func() {
|
|
|
|
res, err := ui.client.Send(sim.Pickup{p.x, p.y})
|
|
|
|
res, err := ui.client.Send(sim.Pickup{p.x, p.y})
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
ui.Error("look error: %v", err)
|
|
|
|
ui.state.detail = textView(err.Error())
|
|
|
|
return
|
|
|
|
return
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pickedup, ok := res.Body.(*sim.Pickedup)
|
|
|
|
switch v := res.Body.(type) {
|
|
|
|
if !ok {
|
|
|
|
case *sim.Pickedup:
|
|
|
|
ui.Error("pickup response is not pickedup: %v", res.Body)
|
|
|
|
ui.misc <- func(ui *UI) {
|
|
|
|
return
|
|
|
|
ui.state.detail = textView(fmt.Sprintf("you picked up: %s", v.Name))
|
|
|
|
|
|
|
|
ui.state.inventory.items = append(ui.state.inventory.items, item{name: v.Name})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
case wire.Error:
|
|
|
|
ui.misc <- func(ui *UI) {
|
|
|
|
ui.misc <- func(ui *UI) {
|
|
|
|
ui.state.detail = textView(fmt.Sprintf("you picked up: %s", pickedup.Name))
|
|
|
|
ui.state.detail = textView(v.Error())
|
|
|
|
ui.state.inventory.items = append(ui.state.inventory.items, item{name: pickedup.Name})
|
|
|
|
}
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
ui.misc <- func(ui *UI) {
|
|
|
|
|
|
|
|
ui.state.detail = textView(fmt.Sprintf("unexpected pickup response type: %T", res.Body))
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
}()
|
|
|
|
}
|
|
|
|
}
|
|
|
|