diff options
Diffstat (limited to 'internal/game/hacking.go')
| -rw-r--r-- | internal/game/hacking.go | 93 |
1 files changed, 0 insertions, 93 deletions
diff --git a/internal/game/hacking.go b/internal/game/hacking.go deleted file mode 100644 index 3457728..0000000 --- a/internal/game/hacking.go +++ /dev/null @@ -1,93 +0,0 @@ -package game - -import ( - "fmt" - "strings" - - "thehouseoficarus/internal/game/hacking" - "thehouseoficarus/internal/net" - "thehouseoficarus/internal/player" -) - -func (g *Game) handleHackingInput(sess *net.Session, input string) { - p := sess.Player - if p == nil { - sess.State = net.StateGame - return - } - - hs, ok := g.hackingStates[p.Name] - if !ok { - sess.State = net.StateGame - g.writePrompt(sess) - return - } - - input = strings.TrimSpace(input) - lower := strings.ToLower(input) - - if lower == "jack out" || lower == "quit" || lower == "disconnect" { - g.endHacking(sess, p, false, false) - return - } - - hs.Started = true - output, done, won := hs.Minigame.HandleInput(input) - - sess.WriteLine(output) - - if done { - g.endHacking(sess, p, true, won) - return - } - - sess.Write("\nhack> ") -} - -func (g *Game) endHacking(sess *net.Session, p *player.Player, completed bool, won bool) { - hs, ok := g.hackingStates[p.Name] - if !ok { - sess.State = net.StateGame - g.writePrompt(sess) - return - } - - tDef := hacking.Terminals[hs.TerminalID] - var xp int - - if completed && won { - xp = hacking.CalcXP(tDef.BaseXPWin, hs.Level, hs.ReqLevel) - sess.WriteLine("\nConnection terminated. Contract complete.") - } else if completed { - xp = hacking.CalcXP(tDef.BaseXPLose, hs.Level, hs.ReqLevel) - sess.WriteLine("\nConnection lost.") - } else if hs.Started { - xp = hacking.CalcXP(tDef.BaseXPLose, hs.Level, hs.ReqLevel) - sess.WriteLine("\nYou jack out of the terminal.") - } else { - sess.WriteLine("\nYou jack out of the terminal.") - } - - if won { - if b, ok := hs.Minigame.(hacking.XPBonuser); ok { - bonus := b.BonusXP() - if bonus > 0 { - xp += hacking.CalcXP(bonus, hs.Level, hs.ReqLevel) - } - } - } - - if xp > 0 { - g.awardSkillXP(sess, p, player.Hacking, xp) - if p.OptionBool("xp_drops") { - sess.WriteLine(g.colorize(sess, "xp", - fmt.Sprintf("(+%dxp %s)", xp, player.SkillAbbr[player.Hacking]))) - } - g.AccountStore.SaveCharacter(p) - } - - delete(g.hackingStates, p.Name) - p.ActionState = nil - sess.State = net.StateGame - g.writePrompt(sess) -} |
