aboutsummaryrefslogtreecommitdiff
path: root/internal/game/exit_discovery.go
blob: 1d07e132d24a34ed5e31aa2f61302d2efcb6940b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package game

import (
	"fmt"
	"strings"

	"thehouseoficarus/internal/player"
	"thehouseoficarus/internal/world"
)

func discoveredExitFlag(roomID int, dir world.ExitDir) string {
	return fmt.Sprintf("hidden_exit_%d_%s", roomID, strings.ToLower(string(dir)))
}

func (g *Game) exitDiscovered(p *player.Player, roomID int, dir world.ExitDir) bool {
	if p.GodMode {
		return true
	}
	return getPlayerFlagInt(p, discoveredExitFlag(roomID, dir)) != 0
}

func (g *Game) markExitDiscovered(p *player.Player, roomID int, dir world.ExitDir) {
	g.setPlayerFlag(p, discoveredExitFlag(roomID, dir), 1)
}

func (g *Game) exitHiddenFiltered(p *player.Player, roomID int, dir world.ExitDir, exitHidden bool) bool {
	if !exitHidden {
		return true
	}
	return g.exitDiscovered(p, roomID, dir)
}