diff options
| author | historia <[not public]> | 2026-06-19 13:28:06 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-19 13:28:06 -0400 |
| commit | 3a58125d14bb307f861b38c6c5b0a63babde7e08 (patch) | |
| tree | bd89e866447d55e6dffd447d8ef5fabf9b8fbe9d /internal/game/cmd_jack.go | |
| parent | 575a71dcfed3b9fa44af244836f638a23df05a9a (diff) | |
| download | thehouseoficarus-3a58125d14bb307f861b38c6c5b0a63babde7e08.tar.gz | |
feat: all skills kind of implemented, random prototype content added
Diffstat (limited to 'internal/game/cmd_jack.go')
| -rw-r--r-- | internal/game/cmd_jack.go | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/internal/game/cmd_jack.go b/internal/game/cmd_jack.go new file mode 100644 index 0000000..db157f3 --- /dev/null +++ b/internal/game/cmd_jack.go @@ -0,0 +1,83 @@ +package game + +import ( + "fmt" + "strings" + + "thehouseoficarus/internal/combat" + "thehouseoficarus/internal/net" + "thehouseoficarus/internal/player" +) + +func (g *Game) doJack(sess *net.Session, target string) { + p := sess.Player.(*player.Player) + + if combat.GetCombat(p.Name) != nil { + sess.WriteLine("You can't do that during combat!") + return + } + + if target == "" { + target = g.findTerminalInRoom(p.RoomID) + if target == "" { + sess.WriteLine("There's no terminal here to jack into.") + return + } + } + + instances := g.World.FindObjInstances(p.RoomID, strings.ToLower(target)) + if len(instances) == 0 { + sess.WriteLine("You don't see that here.") + return + } + + defID := instances[0].DefID + tDef, ok := terminalDefs[defID] + if !ok { + sess.WriteLine("You can't jack into that.") + return + } + + hackLevel := p.Level(player.Hacking) + if hackLevel < tDef.Level { + sess.WriteLine(fmt.Sprintf("You need level %d Hacking to use this terminal.", tDef.Level)) + return + } + + g.CancelAction(p) + g.CancelBackgroundAction(p) + + minigame := tDef.Minigame() + display := minigame.Init(hackLevel) + + g.hackingStates[p.Name] = &HackingSession{ + Minigame: minigame, + TerminalID: defID, + Level: hackLevel, + ReqLevel: tDef.Level, + Started: false, + } + + p.ActionState = &ActionState{Type: ActionHacking, TargetName: tDef.Name} + sess.State = net.StateHacking + + if g.Hub != nil { + for _, other := range g.Hub.PlayersInRoom(p.RoomID) { + if other != sess { + other.WriteLine(fmt.Sprintf("\n%s jacks into a terminal.", p.Name)) + } + } + } + + sess.WriteLine(display) + sess.Write("\nhack> ") +} + +func (g *Game) findTerminalInRoom(roomID int) string { + for _, st := range g.World.FindObjInstances(roomID, "") { + if strings.HasPrefix(st.DefID, "terminal_") { + return st.Name + } + } + return "" +} |
