diff options
| author | historia <[not public]> | 2026-06-11 04:46:27 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-11 08:58:37 +0000 |
| commit | 1b9e2da3b3c438d8dc53d3489725dd5ba0022777 (patch) | |
| tree | 62264f24420bf4cfaa734942c65cc8dd45ba3d3b /internal/game/action_toggle.go | |
| parent | 06c02a697e5daf8832a462de5970dd4c0e13a02c (diff) | |
| download | thehouseoficarus-1b9e2da3b3c438d8dc53d3489725dd5ba0022777.tar.gz | |
feat: web client, get/drop updates and fixes
Diffstat (limited to 'internal/game/action_toggle.go')
| -rw-r--r-- | internal/game/action_toggle.go | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/internal/game/action_toggle.go b/internal/game/action_toggle.go new file mode 100644 index 0000000..3818d0d --- /dev/null +++ b/internal/game/action_toggle.go @@ -0,0 +1,46 @@ +package game + +import ( + "fmt" + + "thirdcollapse/internal/net" + "thirdcollapse/internal/object" + "thirdcollapse/internal/player" +) + +func (g *Game) startToggle(sess *net.Session, p *player.Player, obj *object.ObjectDef) { + cfg, err := g.BehaviorStore.LoadToggle(obj.BehaviorID) + if err != nil { + sess.WriteLine("Nothing happens.") + return + } + + if cfg.Check != nil { + val, ok := g.WorldFlags[cfg.Check.Flag] + if cfg.Check.Not { + if ok && val == cfg.Check.Value { + sess.WriteLine("Nothing happens.") + return + } + } else { + if !ok || val != cfg.Check.Value { + sess.WriteLine("Nothing happens.") + return + } + } + } + + for flag, val := range cfg.SetFlags { + g.WorldFlags[flag] = val + } + + sess.WriteLine(fmt.Sprintf("\n%s", cfg.Message)) + + if g.Hub != nil { + for _, other := range g.Hub.PlayersInRoom(p.RoomID) { + if other != sess && other.Player != nil { + other.WriteLine(fmt.Sprintf("\n%s uses the %s.", p.Name, obj.Name)) + } + } + } +} |
