From 207a0e2d69f2724a49c0f87e577b726d1303150d Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 22 Aug 2022 19:34:53 -0400 Subject: [PATCH] bubble up more, accounts --- account.go | 10 ++++++++++ data/landmark.toml | 11 +++++++++++ jmenu.go | 2 +- main.go | 6 ++++-- simulator/simulator.go | 13 ++++++------- 5 files changed, 32 insertions(+), 10 deletions(-) create mode 100644 account.go create mode 100644 data/landmark.toml diff --git a/account.go b/account.go new file mode 100644 index 0000000..a157c90 --- /dev/null +++ b/account.go @@ -0,0 +1,10 @@ +package main + +import sim "git.saintnet.tech/stryan/spacetea/simulator" + +//Account is a account +type Account struct { + Player *sim.Player + Simulator *sim.Simulator + Landmark *sim.Landmark +} diff --git a/data/landmark.toml b/data/landmark.toml new file mode 100644 index 0000000..0e70ceb --- /dev/null +++ b/data/landmark.toml @@ -0,0 +1,11 @@ +[[landmark]] +landmarkid = 0 +name = "Spawn" +content = "Nothing's here but us chickens" +links = [1] + +[[landmark]] +landmarkid = 1 +name = "Landmark 1" +content = "New spot" +links = [] diff --git a/jmenu.go b/jmenu.go index ddea30c..0951f5c 100644 --- a/jmenu.go +++ b/jmenu.go @@ -52,7 +52,7 @@ func (j jMenuModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { case tea.KeyMsg: switch keypress := msg.String(); keypress { case "ctrl-c": - return j, tea.Quit + return j, tea.Batch(tea.Quit, j.GetSize) case "esc": return initMainscreen(j.acc), tea.Batch(j.GetSize, heartbeat()) case "enter": diff --git a/main.go b/main.go index 698d48a..62c1093 100644 --- a/main.go +++ b/main.go @@ -11,12 +11,14 @@ import ( func main() { simulator := sim.NewSimulator() - sim.Demo(simulator) + player := sim.NewPlayer() acc := &Account{ - Player: simulator.Player, + Player: player, Simulator: simulator, Landmark: nil, } + sim.Demo(acc.Player, acc.Simulator) + simulator.Start() parent := parent{initMainscreen(acc)} if err := tea.NewProgram(parent, tea.WithAltScreen()).Start(); err != nil { diff --git a/simulator/simulator.go b/simulator/simulator.go index 1844ae6..4a0196a 100644 --- a/simulator/simulator.go +++ b/simulator/simulator.go @@ -16,16 +16,15 @@ type Simulator struct { stop chan bool } -func Demo(s *Simulator) { +func Demo(p *Player, s *Simulator) { pod := newPod() - player := NewPlayer() pod.Place(newResource(lookupByName("tea").ID()), 4, 4) - player.AddItem(itemType(1), 30) - player.AddItem(itemType(3), 5) - pod.Tiles[0][0].User = player - player.Announce("Game started") + p.AddItem(itemType(1), 30) + p.AddItem(itemType(3), 5) + pod.Tiles[0][0].User = p + p.Announce("Game started") s.Place = pod - s.Player = player + s.Player = p } //NewSimulator creates a new simulator instance