You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
206 lines
5.6 KiB
206 lines
5.6 KiB
package tables
|
|
|
|
import (
|
|
"mazeratsgen/internal/data"
|
|
"mazeratsgen/internal/dice"
|
|
"mazeratsgen/internal/helpers"
|
|
"strings"
|
|
)
|
|
|
|
type MazeTable struct {
|
|
Roller *dice.Roller
|
|
}
|
|
|
|
type Room struct {
|
|
Type string
|
|
Detail string
|
|
}
|
|
|
|
type Maze struct {
|
|
Form string
|
|
Entrance string
|
|
Layout string
|
|
Ruination string
|
|
Reward string
|
|
Activities []string
|
|
Rooms []string
|
|
Tricks []string
|
|
Hazards []string
|
|
TrapEffects []string
|
|
TrapTriggers []string
|
|
Seed int64
|
|
}
|
|
|
|
func (t MazeTable) Generate() Maze {
|
|
total_rooms := 5
|
|
roomTypes := helpers.GenUniqueItems(total_rooms, t.DungeonRoom, t.Roller.Seed)
|
|
roomDetails := helpers.GenUniqueItems(total_rooms, t.DungeonRoomDetail, t.Roller.Seed)
|
|
rooms := []string{}
|
|
for i := 0; i < total_rooms; i++ {
|
|
room := roomTypes[i] + " with " + strings.ToLower(roomDetails[i])
|
|
rooms = append(rooms, room)
|
|
}
|
|
return Maze{
|
|
Form: t.DungeonForm(t.Roller.TableRoll()),
|
|
Entrance: t.DungeonEntrance(t.Roller.TableRoll()),
|
|
Layout: t.DungeonLayout(t.Roller.TableRoll()),
|
|
Ruination: t.DungeonRuination(t.Roller.TableRoll()),
|
|
Reward: t.DungeonReward(t.Roller.TableRoll()),
|
|
Activities: helpers.GenUniqueItems(5, t.DungeonActivity, t.Roller.Seed),
|
|
Rooms: rooms,
|
|
Hazards: helpers.GenUniqueItems(5, t.DungeonHazard, t.Roller.Seed),
|
|
Tricks: helpers.GenUniqueItems(5, t.DungeonTrick, t.Roller.Seed),
|
|
TrapEffects: helpers.GenUniqueItems(5, t.TrapEffect, t.Roller.Seed),
|
|
TrapTriggers: helpers.GenUniqueItems(5, t.TrapTrigger, t.Roller.Seed),
|
|
Seed: t.Roller.Seed,
|
|
}
|
|
}
|
|
|
|
func (t MazeTable) Template() string {
|
|
return strings.TrimSpace(`
|
|
Form: {{.Form}}
|
|
Entrance: {{.Entrance}}
|
|
Layout: {{.Layout}}
|
|
Ruination: {{.Ruination}}
|
|
Reward: {{.Reward}}
|
|
Activities:
|
|
{{- range $activity := .Activities}}
|
|
{{$activity}}
|
|
{{- end}}
|
|
Rooms:
|
|
{{- range $room := .Rooms}}
|
|
{{$room}}
|
|
{{- end}}
|
|
Tricks:
|
|
{{- range $trick := .Tricks}}
|
|
{{$trick}}
|
|
{{- end}}
|
|
Hazards:
|
|
{{- range $hazard := .Hazards}}
|
|
{{$hazard}}
|
|
{{- end}}
|
|
Trap Effects:
|
|
{{- range $trapEffect := .TrapEffects}}
|
|
{{$trapEffect}}
|
|
{{- end}}
|
|
Trap Triggers:
|
|
{{- range $trapTrigger := .TrapTriggers}}
|
|
{{$trapTrigger}}
|
|
{{- end}}
|
|
Seed: {{.Seed}}
|
|
`)
|
|
}
|
|
|
|
func (t MazeTable) DungeonEntrance(roll [2]int) string {
|
|
roll[0], roll[1] = roll[0]-1, roll[0]-1
|
|
return data.Tables.Maze.DungeonEntrances[roll[0]][roll[1]]
|
|
}
|
|
|
|
func (t MazeTable) DungeonForm(roll [2]int) string {
|
|
cityTable := CityTable{Roller: t.Roller}
|
|
switch roll {
|
|
case [2]int{2, 1}:
|
|
return cityTable.BuildingRoom(t.Roller.TableRoll())
|
|
case [2]int{2, 6}:
|
|
return t.DungeonRoom(t.Roller.TableRoll())
|
|
case [2]int{3, 5}:
|
|
return cityTable.LowerClassBuilding(t.Roller.TableRoll()).Type
|
|
case [2]int{6, 3}:
|
|
return cityTable.UpperClassBuilding(t.Roller.TableRoll()).Type
|
|
}
|
|
return data.Tables.Maze.DungeonForms[roll[0]-1][roll[1]-1]
|
|
}
|
|
|
|
func (t MazeTable) DungeonLayout(roll [2]int) string {
|
|
return data.Tables.Maze.DungeonLayout[roll[0]-1][roll[1]-1]
|
|
}
|
|
|
|
func (t MazeTable) DungeonRuination(roll [2]int) string {
|
|
magicTable := MagicTable{Roller: t.Roller}
|
|
switch roll {
|
|
case [2]int{4, 2}:
|
|
return magicTable.Insanity(t.Roller.TableRoll())
|
|
case [2]int{5, 1}:
|
|
return magicTable.Mutation(t.Roller.TableRoll())
|
|
}
|
|
return data.Tables.Maze.DungeonRuinations[roll[0]-1][roll[1]-1]
|
|
}
|
|
|
|
func (t MazeTable) DungeonReward(roll [2]int) string {
|
|
treasureTable := TreasureTable{Roller: t.Roller}
|
|
switch roll {
|
|
case [2]int{3, 6}:
|
|
return "Magic " + treasureTable.TreasureItem(t.Roller.TableRoll())
|
|
case [2]int{4, 5}:
|
|
return "Generate monster as an ally"
|
|
case [2]int{6, 2}:
|
|
return treasureTable.TreasureItem(t.Roller.TableRoll())
|
|
case [2]int{5, 4}:
|
|
return treasureTable.ValuableMaterial(t.Roller.TableRoll())
|
|
}
|
|
return data.Tables.Maze.DungeonRewards[roll[0]-1][roll[1]-1]
|
|
}
|
|
|
|
func (t MazeTable) DungeonActivity(roll [2]int) string {
|
|
cityTable := CityTable{Roller: t.Roller}
|
|
monTable := MonsterTable{Roller: t.Roller}
|
|
switch roll {
|
|
case [2]int{1, 3}:
|
|
return cityTable.CityActivity(t.Roller.TableRoll())
|
|
case [2]int{1, 3}:
|
|
return monTable.Tactic(t.Roller.TableRoll())
|
|
case [2]int{6, 5}:
|
|
return monTable.Tactic(t.Roller.TableRoll())
|
|
}
|
|
return data.Tables.Maze.DungeonActivities[roll[0]-1][roll[1]-1]
|
|
}
|
|
|
|
func (t MazeTable) DungeonRoom(roll [2]int) string {
|
|
cityTable := CityTable{Roller: t.Roller}
|
|
switch roll {
|
|
case [2]int{1, 4}:
|
|
return cityTable.BuildingRoom(t.Roller.TableRoll())
|
|
case [2]int{3, 5}:
|
|
return cityTable.LowerClassBuilding(t.Roller.TableRoll()).Type
|
|
case [2]int{6, 3}:
|
|
return cityTable.UpperClassBuilding(t.Roller.TableRoll()).Type
|
|
}
|
|
return data.Tables.Maze.DungeonRooms[roll[0]-1][roll[1]-1]
|
|
}
|
|
|
|
func (t MazeTable) DungeonRoomDetail(roll [2]int) string {
|
|
return data.Tables.Maze.DungeonRoomDetails[roll[0]-1][roll[1]-1]
|
|
}
|
|
|
|
func (t MazeTable) DungeonTrick(roll [2]int) string {
|
|
magicTable := MagicTable{Roller: t.Roller}
|
|
npcTable := NPCTable{Roller: t.Roller}
|
|
switch roll {
|
|
case [2]int{2, 6}:
|
|
return magicTable.EtherealEffect(t.Roller.TableRoll())
|
|
case [2]int{3, 6}:
|
|
return npcTable.Mission(t.Roller.TableRoll())
|
|
case [2]int{4, 3}:
|
|
return magicTable.PhysicalEffect(t.Roller.TableRoll())
|
|
default:
|
|
return data.Tables.Maze.DungeonTricks[roll[0]-1][roll[1]-1]
|
|
}
|
|
}
|
|
|
|
func (t MazeTable) DungeonHazard(roll [2]int) string {
|
|
return data.Tables.Maze.DungeonHazards[roll[0]-1][roll[1]-1]
|
|
}
|
|
|
|
func (t MazeTable) TrapEffect(roll [2]int) string {
|
|
switch roll {
|
|
case [2]int{4, 5}:
|
|
roll, _ := t.Roller.Roll("1d6")
|
|
return MonsterTable{Roller: t.Roller}.Base(roll[0]) + " freed"
|
|
default:
|
|
return data.Tables.Maze.TrapEffects[roll[0]-1][roll[1]-1]
|
|
}
|
|
}
|
|
|
|
func (t MazeTable) TrapTrigger(roll [2]int) string {
|
|
return data.Tables.Maze.TrapTriggers[roll[0]-1][roll[1]-1]
|
|
}
|
|
|