feat: finalize with step 5

This commit is contained in:
jonas committed 2026-09-03 23:39:25 +02:00
1 parent 129dd5d8b8
commit aab128b55c
10 files changed
+332 -37

No files matched your search

@@ -1,6 +1,7 @@
package westworldwithmessaging
import (
"fmt"
"math/rand"
"sync"
)
@@ -49,13 +50,19 @@ func (s *wifesGlobalState) Execute(e *Elsa) {
}
}
// OnMessage is required now that State[T] includes it. This state
// doesn't handle any messages yet - false ("not handled") is the
// correct default until the book shows otherwise. (Note: our Elsa
// only has DoHousework and VisitBathroom, not a cooking state, so
// the book's stew-related messages between Miner and Elsa may not
// map cleanly onto this simplified version - worth revisiting if
// that comes up.)
// OnMessage handles messages that should get through no matter what
// Elsa is currently doing - the book puts Msg_HiHoneyImHome here
// specifically because she should react to it "when in any state,"
// same reasoning as why the bathroom-call check above lives in the
// global state rather than in DoHousework.
func (s *wifesGlobalState) OnMessage(e *Elsa, msg Telegram) bool {
switch MessageType(msg.Msg) {
case MsgHiHoneyImHome:
fmt.Printf("\nMessage handled by %s at time: %.5f", GetNameOfEntity(e.ID()), Clock.GetCurrentTime())
fmt.Printf("\n%s: Hi honey. Let me make you some of mah fine country stew", GetNameOfEntity(e.ID()))
e.FSM().ChangeState(CookStew())
return true
}
return false
}