bubble up more, accounts

This commit is contained in:
stryan 2022-08-22 19:34:53 -04:00
parent a6d74089ee
commit 207a0e2d69
5 changed files with 32 additions and 10 deletions

10
account.go Normal file
View File

@ -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
}

11
data/landmark.toml Normal file
View File

@ -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 = []

View File

@ -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":

View File

@ -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 {

View File

@ -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