aboutsummaryrefslogtreecommitdiff
path: root/internal/game/game.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 13:28:06 -0400
committerhistoria <[not public]>2026-06-19 13:28:06 -0400
commit3a58125d14bb307f861b38c6c5b0a63babde7e08 (patch)
treebd89e866447d55e6dffd447d8ef5fabf9b8fbe9d /internal/game/game.go
parent575a71dcfed3b9fa44af244836f638a23df05a9a (diff)
downloadthehouseoficarus-3a58125d14bb307f861b38c6c5b0a63babde7e08.tar.gz
feat: all skills kind of implemented, random prototype content added
Diffstat (limited to 'internal/game/game.go')
-rw-r--r--internal/game/game.go43
1 files changed, 39 insertions, 4 deletions
diff --git a/internal/game/game.go b/internal/game/game.go
index e800a78..03300a4 100644
--- a/internal/game/game.go
+++ b/internal/game/game.go
@@ -41,6 +41,7 @@ type Game struct {
MobStore *world.MobStore
BehaviorStore *action.Store
RecipeStore *action.RecipeStore
+ CourseStore *CourseStore
Hub *net.Hub
Ticks *engine.Engine
WorldFlags map[string]any
@@ -56,10 +57,11 @@ type Game struct {
pendingDepletions []pendingDepletion
guardWatchTimers map[string]int
farmTickCounter int
+ hackingStates map[string]*HackingSession
}
func New(dataDir string, colorConfig *config.ColorsConfig) *Game {
- return &Game{
+ g := &Game{
World: world.New(dataDir),
ObjectStore: object.NewObjectStore(dataDir),
ItemStore: object.NewItemStore(dataDir),
@@ -67,6 +69,7 @@ func New(dataDir string, colorConfig *config.ColorsConfig) *Game {
MobStore: world.NewMobStore(dataDir),
BehaviorStore: action.NewStore(dataDir),
RecipeStore: action.NewRecipeStore(dataDir),
+ CourseStore: NewCourseStore(dataDir),
Ticks: engine.New(),
WorldFlags: make(map[string]any),
ColorConfig: colorConfig,
@@ -78,7 +81,10 @@ func New(dataDir string, colorConfig *config.ColorsConfig) *Game {
consumeQueue: make(map[string]*QueuedCommand),
pendingDepletions: nil,
guardWatchTimers: make(map[string]int),
+ hackingStates: make(map[string]*HackingSession),
}
+ g.CourseStore.LoadAll()
+ return g
}
func (g *Game) SetHub(hub *net.Hub) {
@@ -89,6 +95,7 @@ func (g *Game) SetHub(hub *net.Hub) {
g.charsMu.Lock()
delete(g.loggedInChars, p.Name)
g.charsMu.Unlock()
+ delete(g.hackingStates, p.Name)
}
})
}
@@ -126,6 +133,8 @@ func (g *Game) HandleSession(sess *net.Session, input string) {
g.handleTalkInput(sess, input)
case net.StateShop:
g.handleShopInput(sess, input)
+ case net.StateBank:
+ g.handleBankInput(sess, input)
case net.StateDropAllConfirm:
g.handleDropAllConfirm(sess, input)
case net.StateRecipeChoice:
@@ -136,6 +145,8 @@ func (g *Game) HandleSession(sess *net.Session, input string) {
g.handleProductChoice(sess, input)
case net.StateColorChoice:
g.handleColorChoice(sess, input)
+ case net.StateHacking:
+ g.handleHackingInput(sess, input)
}
}
@@ -160,14 +171,20 @@ func classifyCommand(cmd string) CommandClass {
"id", "identify",
"steal", "thieve",
"trigger", "cast",
- "plant", "harvest", "rake", "water", "cure":
+ "plant", "harvest", "rake", "water", "cure",
+ "bank", "construct", "make":
return ClassActive
- case "eat", "fletch", "clean":
+ case "jack", "jackin":
+ return ClassActive
+ case "eat", "fletch", "clean", "drink":
return ClassFree
}
if _, ok := verbAliases[cmd]; ok {
return ClassActive
}
+ if obstacleVerbs[cmd] {
+ return ClassActive
+ }
return ClassUnknown
}
@@ -404,6 +421,9 @@ func (g *Game) executeCommand(sess *net.Session, cmd string, args []string, rawI
case "eat":
g.doEat(sess, strings.Join(args, " "))
return
+ case "drink":
+ g.doDrink(sess, args)
+ return
case "fletch":
g.doFletch(sess, strings.Join(args, " "))
return
@@ -512,6 +532,16 @@ func (g *Game) executeCommand(sess *net.Session, cmd string, args []string, rawI
case "walk":
g.doWalk(sess, args)
return
+ case "bank":
+ g.doBank(sess)
+ return
+ case "construct", "make":
+ g.doConstruct(sess, strings.Join(args, " "))
+ return
+ case "jack", "jackin":
+ g.CancelAction(p)
+ g.doJack(sess, strings.Join(args, " "))
+ return
case "eq", "equipment", "equip", "wear", "wield":
g.doWear(sess, strings.Join(args, " "))
return
@@ -519,6 +549,10 @@ func (g *Game) executeCommand(sess *net.Session, cmd string, args []string, rawI
g.doRemove(sess, strings.Join(args, " "))
return
default:
+ if obstacleVerbs[cmd] {
+ g.doObstacle(sess, cmd)
+ return
+ }
if a, ok := verbAliases[cmd]; ok {
g.CancelAction(p)
switch a {
@@ -565,7 +599,8 @@ func (g *Game) ProcessQueuedCommands() {
switch as.Type {
case ActionGathering, ActionCombating, ActionUsing, ActionTalking,
ActionToggling, ActionBurning, ActionStoking, ActionResting, ActionWalking, ActionProducing,
- ActionStealing, ActionPlanting, ActionHarvesting, ActionRaking, ActionWatering, ActionCuring:
+ ActionStealing, ActionPlanting, ActionHarvesting, ActionRaking, ActionWatering, ActionCuring,
+ ActionTraversing:
default:
if as.Type != ActionMoving || p.MoveTicks <= 0 {
p.ActionState = nil