diff options
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) + } +} |
