Go binary/server for helping run/build sessions for the Maze Rats TTRPG
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.
 
 
 
 

174 lines
5.1 KiB

package tables
import (
"mazeratsgen/internal/data"
"mazeratsgen/internal/dice"
"mazeratsgen/internal/helpers"
)
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 []Room
Tricks []string
Hazards []string
TrapEffects []string
TrapTriggers []string
}
func GenMaze(seed int64) Maze {
roller := dice.NewRoller(seed)
mazeTable := MazeTable{Roller: roller}
total_rooms := 5
roomTypes := helpers.GenUniqueItems(total_rooms, mazeTable.DungeonRoom, seed)
roomDetails := helpers.GenUniqueItems(total_rooms, mazeTable.DungeonRoomDetail, seed)
rooms := []Room{}
for i := 0; i < total_rooms; i++ {
room := Room{
Type: roomTypes[i],
Detail: roomDetails[i],
}
rooms = append(rooms, room)
}
return Maze{
Form: mazeTable.DungeonForm(roller.TableRoll()),
Entrance: mazeTable.DungeonEntrance(roller.TableRoll()),
Layout: mazeTable.DungeonLayout(roller.TableRoll()),
Ruination: mazeTable.DungeonRuination(roller.TableRoll()),
Reward: mazeTable.DungeonReward(roller.TableRoll()),
Activities: helpers.GenUniqueItems(5, mazeTable.DungeonActivity, seed),
Rooms: rooms,
Hazards: helpers.GenUniqueItems(5, mazeTable.DungeonHazard, seed),
Tricks: helpers.GenUniqueItems(5, mazeTable.DungeonTrick, seed),
TrapEffects: helpers.GenUniqueItems(5, mazeTable.TrapEffect, seed),
TrapTriggers: helpers.GenUniqueItems(5, mazeTable.TrapTrigger, 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]
}