feat: westworldwithwoman. add elsa

This commit is contained in:
jonas committed 2026-09-03 21:28:28 +02:00
1 parent 2764849943
commit 0e7482e04c
28 files changed
+1946

No files matched your search

@@ -0,0 +1,43 @@
package westworldwithwoman
import "sync"
// minerGlobalState is the Go version of the (not yet pasted)
// singleton class MinerGlobalState from the book. Same pattern as
// enterMineAndDigForNugget: unexported type, one shared instance,
// reached only through the function below. This is the state whose
// Execute runs on every single tick, regardless of whatever else
// the miner is currently doing (see StateMachine.Update).
type minerGlobalState struct{}
var (
minerGlobalStateInstance *minerGlobalState
minerGlobalStateOnce sync.Once
)
// MinerGlobalState is the Go stand-in for
// "MinerGlobalState::Instance()".
func MinerGlobalState() *minerGlobalState {
minerGlobalStateOnce.Do(func() {
minerGlobalStateInstance = &minerGlobalState{}
})
return minerGlobalStateInstance
}
var _ State[Miner] = (*minerGlobalState)(nil)
// Enter, Execute and Exit are placeholders - the book hasn't shown
// us this state's real methods yet. This stub exists only so
// NewMiner can set it as the miner's global state and compile.
func (s *minerGlobalState) Enter(m *Miner) {
// TODO: fill in once the book shows this method's body.
}
func (s *minerGlobalState) Execute(m *Miner) {
// TODO: fill in once the book shows this method's body.
}
func (s *minerGlobalState) Exit(m *Miner) {
// TODO: fill in once the book shows this method's body.
}