diff options
| author | historia <[not public]> | 2026-06-27 02:29:55 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-27 02:29:55 -0400 |
| commit | 6f3d21d6e7f01155ce0c461857a053b43d329392 (patch) | |
| tree | 51e96b62deb5f99a3d70c3a15ab94c520a1ee8e8 /internal/game/act_trigger_module.go | |
| parent | 3102525d97aa6f1ad152c74b2ccfbd4b3a9b83f5 (diff) | |
| download | thehouseoficarus-6f3d21d6e7f01155ce0c461857a053b43d329392.tar.gz | |
feat: recall/home cmd, line break option
Diffstat (limited to 'internal/game/act_trigger_module.go')
| -rw-r--r-- | internal/game/act_trigger_module.go | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/internal/game/act_trigger_module.go b/internal/game/act_trigger_module.go new file mode 100644 index 0000000..467cb83 --- /dev/null +++ b/internal/game/act_trigger_module.go @@ -0,0 +1,61 @@ +package game + +import ( + "fmt" + + "thehouseoficarus/internal/behavior" + "thehouseoficarus/internal/net" + "thehouseoficarus/internal/player" +) + +func (g *Game) startTriggerModule(sess *net.Session, p *player.Player, mod *ModDef) { + if p.Action != nil { + g.cancelAction(p) + } + p.Action = &behavior.Action{ + Type: behavior.TypeTriggerModule, + TargetID: mod.ID, + TargetName: mod.Name, + WaitLeft: 0, + Data: &behavior.TriggerModuleData{ + ModID: mod.ID, + Steps: mod.Sequence, + StepIndex: 0, + }, + } + g.writePrompt(sess) +} + +func (g *Game) advanceTriggerModule(sess *net.Session, p *player.Player) { + data := p.Action.Data.(*behavior.TriggerModuleData) + + mod := GetMod(data.ModID) + if mod == nil { + g.cancelAction(p) + sess.WriteLine("The module has vanished.") + return + } + + if data.StepIndex < len(data.Steps) { + step := data.Steps[data.StepIndex] + sess.WriteLine(step.Message) + data.StepIndex++ + p.Action.WaitLeft = step.Delay + } else { + g.triggerModReward(sess, p, mod, 1.0) + if g.Combat.Get(p.Name) != nil { + g.Combat.Leave(p.Name) + } + switch mod.Category { + case ModTransport: + g.executeTransportEffect(sess, p, mod) + if mod.ID == "transport_home" { + p.HomeTransportCooldown = 3000 + } + default: + sess.WriteLine(fmt.Sprintf("%s completes.", mod.Name)) + } + g.cancelAction(p) + g.writePrompt(sess) + } +} |
