aboutsummaryrefslogtreecommitdiff
path: root/internal/game/cmd_map.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-14 21:07:26 -0400
committerhistoria <[not public]>2026-06-14 21:07:26 -0400
commit1aba2bdd23aebed4032333e74aa553c40a31fcbd (patch)
treec004f4c2a139df5c3cf4029b2611bdfa09b40f86 /internal/game/cmd_map.go
parenta19e6b6ab01670a5932308c7bd0e0e5eed8cbcad (diff)
downloadthehouseoficarus-1aba2bdd23aebed4032333e74aa553c40a31fcbd.tar.gz
refactor: added docs, split up some components in game package
Diffstat (limited to 'internal/game/cmd_map.go')
-rw-r--r--internal/game/cmd_map.go103
1 files changed, 0 insertions, 103 deletions
diff --git a/internal/game/cmd_map.go b/internal/game/cmd_map.go
index 7c506f9..e0413d3 100644
--- a/internal/game/cmd_map.go
+++ b/internal/game/cmd_map.go
@@ -1,11 +1,8 @@
package game
import (
- "strings"
-
"thirdcollapse/internal/net"
"thirdcollapse/internal/player"
- "thirdcollapse/internal/world"
)
func (g *Game) doMap(sess *net.Session) {
@@ -38,103 +35,3 @@ func (g *Game) doMap(sess *net.Session) {
sess.WriteLine(line)
}
}
-
-func stripBlankRows(lines []string) []string {
- var out []string
- for _, line := range lines {
- if strings.TrimSpace(line) != "" {
- out = append(out, line)
- }
- }
- return out
-}
-
-func leftTrimCommon(lines []string) []string {
- min := -1
- for _, line := range lines {
- if strings.TrimSpace(line) == "" {
- continue
- }
- n := 0
- for _, r := range line {
- if r == ' ' {
- n++
- } else {
- break
- }
- }
- if min < 0 || n < min {
- min = n
- }
- }
- if min <= 0 {
- return lines
- }
- result := make([]string, len(lines))
- for i, line := range lines {
- if len(line) <= min {
- result[i] = ""
- } else {
- result[i] = line[min:]
- }
- }
- return result
-}
-
-func buildFullMap(g *Game, roomID, mapWidth, mapHeight int) []string {
- mg := buildGraph(g, roomID)
-
- grid := make([][]rune, mapHeight)
- for i := range grid {
- grid[i] = make([]rune, mapWidth)
- for j := range grid[i] {
- grid[i][j] = ' '
- }
- }
-
- cx := mapWidth / 2
- cy := mapHeight / 2
-
- for pos, rid := range mg.posToRoom {
- gr := cy + pos[1]*2
- gc := cx + pos[0]*2
- if gr < 0 || gr >= mapHeight || gc < 0 || gc >= mapWidth {
- continue
- }
- if rid == roomID {
- grid[gr][gc] = '@'
- } else {
- grid[gr][gc] = roomMapSymbol(g, rid)
- }
- }
-
- for pos, rid := range mg.posToRoom {
- x, y := pos[0], pos[1]
-
- if rightID, ok := mg.posToRoom[[2]int{x + 1, y}]; ok {
- if exitsConnect(g, rid, rightID, world.East, world.West) {
- gr := cy + y*2
- gc := cx + x*2 + 1
- if gr >= 0 && gr < mapHeight && gc >= 0 && gc < mapWidth {
- grid[gr][gc] = '─'
- }
- }
- }
-
- if bottomID, ok := mg.posToRoom[[2]int{x, y + 1}]; ok {
- if exitsConnect(g, rid, bottomID, world.South, world.North) {
- gr := cy + y*2 + 1
- gc := cx + x*2
- if gr >= 0 && gr < mapHeight && gc >= 0 && gc < mapWidth {
- grid[gr][gc] = '│'
- }
- }
- }
- }
-
- lines := make([]string, mapHeight)
- for i := range grid {
- lines[i] = string(grid[i])
- }
- return lines
-}