aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_use.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-20 03:20:01 -0400
committerhistoria <[not public]>2026-06-20 03:20:01 -0400
commite4400c5f1e84c18d2126f2cb502ae10685977cbb (patch)
tree0523e9d68f1cfdc6f81b862e3068fe12c1a85054 /internal/game/cmd_use.go
parent5ea082ab4e82409aebc889b496f43e52b003d4f7 (diff)
downloadthehouseoficarus-e4400c5f1e84c18d2126f2cb502ae10685977cbb.tar.gz
refactor: combined all station crafting
Diffstat (limited to 'internal/game/cmd_use.go')
-rw-r--r--internal/game/cmd_use.go24
1 files changed, 9 insertions, 15 deletions
diff --git a/internal/game/cmd_use.go b/internal/game/cmd_use.go
index 4f830a8..e653c93 100644
--- a/internal/game/cmd_use.go
+++ b/internal/game/cmd_use.go
@@ -83,7 +83,7 @@ func (g *Game) useRoomObject(sess *net.Session, p *player.Player, input string)
}
recipes := g.stationRecipes(p, objSt.DefID)
if len(recipes) > 0 {
- g.showStationRecipeMenu(sess, p, recipes, def.Name)
+ g.showRecipeMenu(sess, p, recipes, def.Name)
return true
}
bt := def.BehaviorType()
@@ -105,13 +105,7 @@ func (g *Game) useRoomObject(sess *net.Session, p *player.Player, input string)
g.applyNodeAction(sess, ui.Action)
}
p.ActionState = &ActionState{Type: ActionUsing, TargetName: def.Name}
- if g.Hub != nil {
- for _, other := range g.Hub.PlayersInRoom(p.RoomID) {
- if other != sess && other.Player != nil {
- other.WriteLine(g.colorize(other, "broadcast", fmt.Sprintf("\n%s uses the %s.", p.Name, def.Name)))
- }
- }
- }
+ g.broadcastAction(sess, "\n%s uses the %s.", p.Name, def.Name)
return true
}
if len(def.UseInteractions) > 0 {
@@ -160,7 +154,7 @@ func (g *Game) stationRecipes(p *player.Player, stationDefID string) []action.Re
return results
}
-func (g *Game) showStationRecipeMenu(sess *net.Session, p *player.Player, recipes []action.RecipeDef, stationName string) {
+func (g *Game) showRecipeMenu(sess *net.Session, p *player.Player, recipes []action.RecipeDef, stationName string) {
if len(recipes) == 0 {
sess.WriteLine(fmt.Sprintf("You don't have anything you can make at the %s.", stationName))
return
@@ -320,8 +314,8 @@ func (g *Game) doUseItemOnTarget(sess *net.Session, p *player.Player, itemAName,
itemBID := matchesB[0].ID
- craftRecipes := g.findCraftRecipesForItems(p, itemAID, itemBID)
- fletchRecipes := g.findFletchRecipesForItems(p, itemAID, itemBID)
+ craftRecipes := g.findCraftRecipes(p, itemAID, itemBID)
+ fletchRecipes := g.findFletchRecipes(p, itemAID, itemBID)
if len(craftRecipes) > 0 && len(fletchRecipes) > 0 {
var menu []map[string]string
@@ -353,12 +347,12 @@ func (g *Game) doUseItemOnTarget(sess *net.Session, p *player.Player, itemAName,
if len(craftRecipes) > 0 {
var available []action.RecipeDef
for _, r := range craftRecipes {
- if g.canDoGenericRecipe(p, &r, player.Crafting) {
+ if g.canDoRecipe(p, &r, player.Crafting) {
available = append(available, r)
}
}
if len(available) == 1 {
- g.startGenericRecipe(sess, p, &available[0], 0, "last_craft")
+ g.startRecipe(sess, p, &available[0], 0, "last_craft")
return
}
if len(available) > 1 {
@@ -429,7 +423,7 @@ func (g *Game) findCombineResults(sess *net.Session, p *player.Player, itemAID,
}
}
}
- if aEntry >= 0 && bEntry >= 0 && aEntry != bEntry && madeFromItemsAvailable(p, def.MadeFrom) {
+ if aEntry >= 0 && bEntry >= 0 && aEntry != bEntry && madeFromAvailable(p, def.MadeFrom) {
matched = append(matched, def)
}
}
@@ -444,7 +438,7 @@ func combineMenuData(defs []*object.ItemDef) []map[string]string {
return out
}
-func madeFromItemsAvailable(p *player.Player, madeFrom []object.MadeFromEntry) bool {
+func madeFromAvailable(p *player.Player, madeFrom []object.MadeFromEntry) bool {
for _, entry := range madeFrom {
found := false
for _, id := range entry.Items {