diff options
| author | historia <[not public]> | 2026-06-20 03:20:01 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-20 03:20:01 -0400 |
| commit | e4400c5f1e84c18d2126f2cb502ae10685977cbb (patch) | |
| tree | 0523e9d68f1cfdc6f81b862e3068fe12c1a85054 /internal/game/action_burn.go | |
| parent | 5ea082ab4e82409aebc889b496f43e52b003d4f7 (diff) | |
| download | thehouseoficarus-e4400c5f1e84c18d2126f2cb502ae10685977cbb.tar.gz | |
refactor: combined all station crafting
Diffstat (limited to 'internal/game/action_burn.go')
| -rw-r--r-- | internal/game/action_burn.go | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/internal/game/action_burn.go b/internal/game/action_burn.go index c31d7d5..71b5a35 100644 --- a/internal/game/action_burn.go +++ b/internal/game/action_burn.go @@ -28,7 +28,7 @@ func (g *Game) doBurn(sess *net.Session, p *player.Player, input string) { if p.Action != nil { g.cancelAction(p) } - g.cancelBackgroundAction(p) + g.cancelBgAction(p) itemID, fromGround, ambiguous := g.resolveBurnTarget(p, input) if ambiguous { @@ -47,7 +47,7 @@ func (g *Game) doStoke(sess *net.Session, p *player.Player, input string) { if p.Action != nil { g.cancelAction(p) } - g.cancelBackgroundAction(p) + g.cancelBgAction(p) if !g.hasFireObject(p.RoomID) { sess.WriteLine("There's no fire here to stoke.") @@ -120,13 +120,7 @@ func (g *Game) startBurn(sess *net.Session, p *player.Player, itemID string, fro p.ActionState = &ActionState{Type: ActionBurning} - 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 starts building a fire.", p.Name))) - } - } - } + g.broadcastAction(sess, "\n%s starts building a fire.", p.Name) p.Action = &action.Action{ Type: "burn", @@ -166,13 +160,7 @@ func (g *Game) startStoke(sess *net.Session, p *player.Player, itemID string) { p.ActionState = &ActionState{Type: ActionStoking} - 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 tends to the fire.", p.Name))) - } - } - } + g.broadcastAction(sess, "\n%s tends to the fire.", p.Name) p.Action = &action.Action{ Type: "stoke", @@ -260,11 +248,7 @@ func (g *Game) advanceBurn(sess *net.Session, p *player.Player) { } sess.WriteLine(msg) - for _, other := range g.Hub.PlayersInRoom(p.RoomID) { - if other != sess { - other.WriteLine(g.colorize(other, "broadcast", fmt.Sprintf("\n%s started a fire!", p.Name))) - } - } + g.broadcastAction(sess, "\n%s started a fire!", p.Name) return } @@ -458,12 +442,12 @@ func (g *Game) cancelStokers(roomID int) { func (g *Game) resolveBurnTarget(p *player.Player, input string) (itemID string, fromGround bool, ambiguous bool) { if input != "" { - return g.resolveNamedBurnTarget(p, input) + return g.namedBurnTarget(p, input) } - return g.resolveDefaultBurnTarget(p) + return g.defaultBurnTarget(p) } -func (g *Game) collectBurnableGround(roomID int, name string) []string { +func (g *Game) burnableGround(roomID int, name string) []string { var out []string for itemID := range g.World.GroundItems(roomID) { def, err := g.ItemStore.Load(itemID) @@ -477,7 +461,7 @@ func (g *Game) collectBurnableGround(roomID int, name string) []string { return out } -func (g *Game) collectBurnableInv(p *player.Player, name string) []string { +func (g *Game) burnableInv(p *player.Player, name string) []string { var out []string seen := make(map[string]bool) for _, slot := range p.Inventory { @@ -496,8 +480,8 @@ func (g *Game) collectBurnableInv(p *player.Player, name string) []string { return out } -func (g *Game) resolveNamedBurnTarget(p *player.Player, input string) (itemID string, fromGround bool, ambiguous bool) { - groundMatches := g.collectBurnableGround(p.RoomID, input) +func (g *Game) namedBurnTarget(p *player.Player, input string) (itemID string, fromGround bool, ambiguous bool) { + groundMatches := g.burnableGround(p.RoomID, input) if len(groundMatches) > 1 { return "", false, true } @@ -505,7 +489,7 @@ func (g *Game) resolveNamedBurnTarget(p *player.Player, input string) (itemID st return groundMatches[0], true, false } - invMatches := g.collectBurnableInv(p, input) + invMatches := g.burnableInv(p, input) if len(invMatches) > 1 { return "", false, true } @@ -516,8 +500,8 @@ func (g *Game) resolveNamedBurnTarget(p *player.Player, input string) (itemID st return "", false, false } -func (g *Game) resolveDefaultBurnTarget(p *player.Player) (itemID string, fromGround bool, ambiguous bool) { - groundBurnable := g.collectBurnableGround(p.RoomID, "") +func (g *Game) defaultBurnTarget(p *player.Player) (itemID string, fromGround bool, ambiguous bool) { + groundBurnable := g.burnableGround(p.RoomID, "") if len(groundBurnable) == 1 { return groundBurnable[0], true, false } @@ -525,7 +509,7 @@ func (g *Game) resolveDefaultBurnTarget(p *player.Player) (itemID string, fromGr return "", false, true } - invBurnable := g.collectBurnableInv(p, "") + invBurnable := g.burnableInv(p, "") if len(invBurnable) == 1 { return invBurnable[0], false, false } @@ -537,7 +521,7 @@ func (g *Game) resolveDefaultBurnTarget(p *player.Player) (itemID string, fromGr } func (g *Game) resolveStokeTarget(p *player.Player, input string) (string, bool) { - invBurnable := g.collectBurnableInv(p, input) + invBurnable := g.burnableInv(p, input) if len(invBurnable) == 1 { return invBurnable[0], false } |
