Compare commits

..

No commits in common. "accounts" and "master" have entirely different histories.

12 changed files with 62 additions and 172 deletions

12
TODO.md
View File

@ -1,12 +0,0 @@
* Adventure system
* Moving from landmark to another
* UI for it
* How to associate pods with landmarks
* Flags
* replace Requirements with "flags"?
* Flag processor (put flags on stack, pop them out to evalute?)
* "Accounts"
* how to handle a player that isn't in a pod
* or just ignore, player is in a pod until moved to new pod?
* what about player-the-person level triggers?

View File

@ -1,10 +0,0 @@
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
}

View File

@ -1,11 +0,0 @@
[[landmark]]
landmarkid = 0
name = "Spawn"
content = "Nothing's here but us chickens"
links = [1]
[[landmark]]
landmarkid = 1
name = "Landmark 1"
content = "New spot"
links = []

23
go.mod
View File

@ -3,26 +3,23 @@ module git.saintnet.tech/stryan/spacetea
go 1.18
require (
github.com/BurntSushi/toml v1.2.0
github.com/charmbracelet/bubbles v0.13.0
github.com/charmbracelet/bubbletea v0.22.1
github.com/charmbracelet/lipgloss v0.5.0
github.com/BurntSushi/toml v1.1.0
github.com/charmbracelet/bubbles v0.10.3
github.com/charmbracelet/bubbletea v0.20.0
github.com/charmbracelet/lipgloss v0.4.0
)
require (
github.com/atotto/clipboard v0.1.4 // indirect
github.com/containerd/console v1.0.3 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mattn/go-localereader v0.0.1 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b // indirect
github.com/muesli/reflow v0.3.0 // indirect
github.com/muesli/termenv v0.12.0 // indirect
github.com/rivo/uniseg v0.3.4 // indirect
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/sahilm/fuzzy v0.1.0 // indirect
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 // indirect
golang.org/x/text v0.3.7 // indirect
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c // indirect
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed // indirect
)

60
go.sum
View File

@ -1,60 +1,48 @@
github.com/BurntSushi/toml v1.2.0 h1:Rt8g24XnyGTyglgET/PRUNlrUeu9F5L+7FilkXfZgs0=
github.com/BurntSushi/toml v1.2.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.1.0 h1:ksErzDEI1khOiGPgpwuI7x2ebx/uXQNw7xJpn9Eq1+I=
github.com/BurntSushi/toml v1.1.0/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4=
github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI=
github.com/charmbracelet/bubbles v0.13.0 h1:zP/ROH3wJEBqZWKIsD50ZKKlx3ydLInq3LdD/Nrlb8w=
github.com/charmbracelet/bubbles v0.13.0/go.mod h1:bbeTiXwPww4M031aGi8UK2HT9RDWoiNibae+1yCMtcc=
github.com/charmbracelet/bubbletea v0.21.0/go.mod h1:GgmJMec61d08zXsOhqRC/AiOx4K4pmz+VIcRIm1FKr4=
github.com/charmbracelet/bubbletea v0.22.1 h1:z66q0LWdJNOWEH9zadiAIXp2GN1AWrwNXU8obVY9X24=
github.com/charmbracelet/bubbletea v0.22.1/go.mod h1:8/7hVvbPN6ZZPkczLiB8YpLkLJ0n7DMho5Wvfd2X1C0=
github.com/charmbracelet/harmonica v0.2.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/lipgloss v0.5.0 h1:lulQHuVeodSgDez+3rGiuxlPVXSnhth442DATR2/8t8=
github.com/charmbracelet/lipgloss v0.5.0/go.mod h1:EZLha/HbzEt7cYqdFPovlqy5FZPj0xFhg5SaqxScmgs=
github.com/charmbracelet/bubbles v0.10.3 h1:fKarbRaObLn/DCsZO4Y3vKCwRUzynQD9L+gGev1E/ho=
github.com/charmbracelet/bubbles v0.10.3/go.mod h1:jOA+DUF1rjZm7gZHcNyIVW+YrBPALKfpGVdJu8UiJsA=
github.com/charmbracelet/bubbletea v0.19.3/go.mod h1:VuXF2pToRxDUHcBUcPmCRUHRvFATM4Ckb/ql1rBl3KA=
github.com/charmbracelet/bubbletea v0.20.0 h1:/b8LEPgCbNr7WWZ2LuE/BV1/r4t5PyYJtDb+J3vpwxc=
github.com/charmbracelet/bubbletea v0.20.0/go.mod h1:zpkze1Rioo4rJELjRyGlm9T2YNou1Fm4LIJQSa5QMEM=
github.com/charmbracelet/harmonica v0.1.0/go.mod h1:KSri/1RMQOZLbw7AHqgcBycp8pgJnQMYYT8QZRqZ1Ao=
github.com/charmbracelet/lipgloss v0.4.0 h1:768h64EFkGUr8V5yAKV7/Ta0NiVceiPaV+PphaW1K9g=
github.com/charmbracelet/lipgloss v0.4.0/go.mod h1:vmdkHvce7UzX6xkyf4cca8WlwdQ5RQr8fzta+xl7BOM=
github.com/containerd/console v1.0.2/go.mod h1:ytZPjGgY2oeTkAONYafi2kSj0aYggsf8acV1PGKCbzQ=
github.com/containerd/console v1.0.3 h1:lIr7SlA5PxZyMV30bDW0MGbiOPXwc63yRuCP0ARubLw=
github.com/containerd/console v1.0.3/go.mod h1:7LqA/THxQ86k76b8c/EMSiaJ3h1eZkMkXar0TQ1gf3U=
github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc=
github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-localereader v0.0.1 h1:ygSAOl7ZXTx4RdPYinUpg6W99U8jWvWi9Ye2JC/oIi4=
github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+EiG4R1k4Cjx5p88=
github.com/mattn/go-runewidth v0.0.10/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b h1:1XF24mVaiu7u+CFywTdcDo2ie1pzzhwjt6RHqzpMU34=
github.com/muesli/ansi v0.0.0-20211018074035-2e021307bc4b/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70 h1:kMlmsLSbjkikxQJ1IPwaM+7LJ9ltFu/fi8CRzvSnQmA=
github.com/muesli/ansi v0.0.0-20211031195517-c9f0611b6c70/go.mod h1:fQuZ0gauxyBcmsdE3ZT4NasjaRdxmbCS0jRHsrWu3Ho=
github.com/muesli/cancelreader v0.2.0/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/cancelreader v0.2.2 h1:3I4Kt4BQjOR54NavqnDogx/MIoWBFa0StPA8ELUXHmA=
github.com/muesli/cancelreader v0.2.2/go.mod h1:3XuTXfFS2VjM+HTLZY9Ak0l6eUKfijIfMUZ4EgX0QYo=
github.com/muesli/reflow v0.2.1-0.20210115123740-9e1d0d53df68/go.mod h1:Xk+z4oIWdQqJzsxyjgl3P22oYZnHdZ8FFTHAQQt5BMQ=
github.com/muesli/reflow v0.3.0 h1:IFsN6K9NfGtjeggFP+68I4chLZV2yIKsXJFNZ+eWh6s=
github.com/muesli/reflow v0.3.0/go.mod h1:pbwTDkVPibjO2kyvBQRBxTWEEGDGq0FlB1BIKtnHY/8=
github.com/muesli/termenv v0.11.1-0.20220204035834-5ac8409525e0/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
github.com/muesli/termenv v0.9.0/go.mod h1:R/LzAKf+suGs4IsO95y7+7DpFHO0KABgnZqtlyx2mBw=
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739 h1:QANkGiGr39l1EESqrE0gZw0/AJNYzIvoGLhIoVYtluI=
github.com/muesli/termenv v0.11.1-0.20220212125758-44cd13922739/go.mod h1:Bd5NYQ7pd+SrtBSrSNoBBmXlcY8+Xj4BMJgh8qcZrvs=
github.com/muesli/termenv v0.12.0 h1:KuQRUE3PgxRFWhq4gHvZtPSLCGDqM5q/cYr1pZ39ytc=
github.com/muesli/termenv v0.12.0/go.mod h1:WCCv32tusQ/EEZ5S8oUIIrC/nIuBcxCVqlN4Xfkv+7A=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/rivo/uniseg v0.1.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.3.4 h1:3Z3Eu6FGHZWSfNKJTOUiPatWwfc7DzJRU04jFUqJODw=
github.com/rivo/uniseg v0.3.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220204135822-1c1b9b1eba6a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 h1:Sx/u41w+OwrInGdEckYmEuU5gHoGSL4QbDz3S9s6j4U=
golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 h1:Q5284mrmYTpACcm+eAKjKJH48BBwSyfJqmmGDTtT8Vc=
golang.org/x/term v0.0.0-20220722155259-a9ba230a4035/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed h1:Ei4bQjjpYUsS4efOUz+5Nz++IVkHk87n2zBA0NxBWc0=
golang.org/x/term v0.0.0-20210422114643-f5beecf764ed/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=

View File

@ -16,14 +16,13 @@ func (i jEntry) ID() string { return i.id }
func (i jEntry) FilterValue() string { return i.title }
type jMenuModel struct {
acc *Account
list list.Model
lastSize tea.WindowSizeMsg
}
type readMsg string
func newJMenuModel(pages []sim.JournalPage, acc *Account) jMenuModel {
func newJMenuModel(pages []sim.JournalPage) jMenuModel {
var jm jMenuModel
items := []list.Item{}
for _, v := range pages {
@ -32,7 +31,6 @@ func newJMenuModel(pages []sim.JournalPage, acc *Account) jMenuModel {
jm.list = list.New(items, list.NewDefaultDelegate(), 80, 32)
jm.list.DisableQuitKeybindings()
jm.list.Title = "Read which entry?"
jm.acc = acc
return jm
}
@ -52,11 +50,11 @@ 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.Batch(tea.Quit, j.GetSize)
return j, tea.Quit
case "esc":
return initMainscreen(j.acc), tea.Batch(j.GetSize, heartbeat())
return initMainscreen(), tea.Batch(j.GetSize, heartbeat())
case "enter":
return initMainscreen(j.acc), tea.Batch(j.GetSize, j.buildJmenuMsg, heartbeat())
return initMainscreen(), tea.Batch(j.GetSize, j.buildJmenuMsg, heartbeat())
}
}

View File

@ -31,11 +31,10 @@ type jview struct {
ready bool
lastSize tea.WindowSizeMsg
viewport viewport.Model
acc *Account
}
func newJView(title, content string, acc *Account) jview {
return jview{title: title, content: content, acc: acc}
func newJView(title, content string) jview {
return jview{title: title, content: content}
}
func (m jview) Init() tea.Cmd {
@ -51,7 +50,7 @@ func (m jview) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
switch msg := msg.(type) {
case tea.KeyMsg:
if k := msg.String(); k == "ctrl+c" || k == "q" || k == "esc" {
return initMainscreen(m.acc), tea.Batch(m.GetSize, heartbeat())
return initMainscreen(), tea.Batch(m.GetSize, heartbeat())
}
case tea.WindowSizeMsg:

15
main.go
View File

@ -5,22 +5,15 @@ import (
"os"
sim "git.saintnet.tech/stryan/spacetea/simulator"
tea "github.com/charmbracelet/bubbletea"
)
func main() {
simulator := sim.NewSimulator()
player := sim.NewPlayer()
acc := &Account{
Player: player,
Simulator: simulator,
Landmark: nil,
}
sim.Demo(acc.Player, acc.Simulator)
var simulator *sim.Simulator
func main() {
simulator = sim.NewSimulator()
simulator.Start()
parent := parent{initMainscreen(acc)}
parent := parent{initMainscreen()}
if err := tea.NewProgram(parent, tea.WithAltScreen()).Start(); err != nil {
fmt.Printf("Uh oh, there was an error: %v\n", err)
os.Exit(1)

View File

@ -28,7 +28,6 @@ type model struct {
keys keyMap
next string
lastSize tea.WindowSizeMsg
acc *Account
}
type beat struct{}
@ -48,18 +47,17 @@ func (m model) simCommand() tea.Msg {
}
return nil
}
func initMainscreen(acc *Account) model {
func initMainscreen() model {
ti := textinput.New()
ti.Placeholder = "input command"
ti.CharLimit = 156
ti.Width = 20
return model{
s: acc.Simulator,
s: simulator,
input: ti,
help: help.New(),
keys: keys,
acc: acc,
}
}
func (m model) Init() tea.Cmd {
@ -89,7 +87,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if err != nil {
panic(err)
}
return newJView(sim.GlobalPages[pid].Title, sim.GlobalPages[pid].Content, m.acc), m.GetSize
return newJView(sim.GlobalPages[pid].Title, sim.GlobalPages[pid].Content), m.GetSize
case tea.KeyMsg:
switch {
case key.Matches(msg, m.keys.Help):
@ -120,7 +118,7 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
sort.Sort(res)
return newMenuModel(res, placeMenu, m.acc), m.GetSize
return newMenuModel(res, placeMenu), m.GetSize
case key.Matches(msg, m.keys.Pickup):
m.s.Input("pickup")
case key.Matches(msg, m.keys.Destroy):
@ -131,14 +129,14 @@ func (m model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
res = append(res, sim.GlobalItems[k].(sim.ItemEntry))
}
sort.Sort(res)
return newMenuModel(res, craftMenu, m.acc), m.GetSize
return newMenuModel(res, craftMenu), m.GetSize
case key.Matches(msg, m.keys.Journal):
var res pagelist
for k := range m.s.Player.Pages {
res = append(res, sim.GlobalPages[k])
}
sort.Sort(res)
return newJMenuModel(res, m.acc), m.GetSize
return newJMenuModel(res), m.GetSize
}
}
m.input, cmd = m.input.Update(msg)

View File

@ -31,15 +31,13 @@ type menuModel struct {
list list.Model
kind menutype
lastSize tea.WindowSizeMsg
acc *Account
}
type placeMsg string
type craftMsg string
func newMenuModel(entries []sim.ItemEntry, i menutype, acc *Account) menuModel {
func newMenuModel(entries []sim.ItemEntry, i menutype) menuModel {
var p menuModel
p.acc = acc
p.kind = i
items := []list.Item{}
for _, v := range entries {
@ -91,9 +89,9 @@ func (p menuModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
case "ctrl-c":
return p, tea.Quit
case "esc":
return initMainscreen(p.acc), tea.Batch(p.GetSize, heartbeat())
return initMainscreen(), tea.Batch(p.GetSize, heartbeat())
case "enter":
return initMainscreen(p.acc), tea.Batch(p.GetSize, p.buildMenuMsg, heartbeat())
return initMainscreen(), tea.Batch(p.GetSize, p.buildMenuMsg, heartbeat())
}
}

View File

@ -1,38 +0,0 @@
package simulator
import (
"strconv"
"github.com/BurntSushi/toml"
)
//LandmarkID is a landmark
type LandmarkID int
//Landmark is a flavour location
type Landmark struct {
LandmarkID LandmarkID `toml:"landmarkid"`
Name string `toml:"title"`
Content string `toml:"content"`
Links []LandmarkID `toml:"links"`
}
func (l Landmark) ID() string {
return strconv.Itoa(int(l.LandmarkID))
}
//GlobalPages is a list of all pages
var GlobalLandmarks []Landmark
type landmarks struct {
Landmark []Landmark
}
func loadLandmarks(filename string) {
var res landmarks
_, err := toml.DecodeFile(filename, &res)
if err != nil {
panic(err)
}
GlobalLandmarks = res.Landmark
}

View File

@ -16,19 +16,10 @@ type Simulator struct {
stop chan bool
}
func Demo(p *Player, s *Simulator) {
pod := newPod()
pod.Place(newResource(lookupByName("tea").ID()), 4, 4)
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 = p
}
//NewSimulator creates a new simulator instance
func NewSimulator() *Simulator {
pod := newPod()
player := NewPlayer()
log.Println("loading items")
initItems()
log.Println("loading techs")
@ -39,8 +30,6 @@ func NewSimulator() *Simulator {
loadConverters("data/converters.toml")
log.Println("loading journal")
loadPages("data/journal.toml")
log.Println("loading landmarks")
loadLandmarks("data/landmark.toml")
if len(GlobalItems) < 1 {
panic("Loaded items but nothing in global items table")
}
@ -50,11 +39,12 @@ func NewSimulator() *Simulator {
if len(GlobalPages) < 1 {
panic("Loaded journal but no pages in table")
}
if len(GlobalLandmarks) < 1 {
panic("Loaded landmarks but nothing in table")
}
return &Simulator{nil, nil, 0, 0, 0, make(chan bool)}
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")
return &Simulator{pod, player, 0, 0, 0, make(chan bool)}
}
//Start begins the simulation, non blocking