package tables import ( "mazeratsgen/internal/data" "mazeratsgen/internal/dice" "mazeratsgen/internal/helpers" ) type WildTable struct { Roller *dice.Roller } type Inn struct { Name string Quirk string } type Wild struct { Region string Landmark string Trait string Structures []string Discoveries []string Activities []string Hazards []string WildernessHazards []string EdiblePlants []string PoisonousPlants []string Inns []Inn } // TODO: Support two nouns func GenInn(seed int64) Inn { roller := dice.NewRoller(seed) wildTable := WildTable{Roller: roller} adjective := wildTable.InnAdjective(roller.TableRoll()) noun := wildTable.InnNoun(roller.TableRoll()) quirk := wildTable.InnQuirk(roller.TableRoll()) return Inn{ Name: adjective + " " + noun, Quirk: quirk, } } func GenInnName(seed int64) string { inn := GenInn(seed) return inn.Name + " (" + inn.Quirk + ")" } func GenWild(seed int64) Wild { roller := dice.NewRoller(seed) wildTable := WildTable{Roller: roller} // TODO: Shouldn't this be genUnique var inns []Inn for i := 0; i < 4; i++ { inns = append(inns, GenInn(seed)) } return Wild{ Region: wildTable.WildernessRegion(roller.TableRoll()), Landmark: wildTable.WildernessLandmark(roller.TableRoll()), Trait: wildTable.WildernessRegionTrait(roller.TableRoll()), Structures: helpers.GenUniqueItems(5, wildTable.WildernessStructure, seed), Discoveries: helpers.GenUniqueItems(5, wildTable.WildernessDiscovery, seed), Activities: helpers.GenUniqueItems(5, wildTable.WildernessActivity, seed), Hazards: helpers.GenUniqueItems(5, wildTable.WildernessHazard, seed), EdiblePlants: helpers.GenUniqueItems(5, wildTable.EdiblePlant, seed), PoisonousPlants: helpers.GenUniqueItems(5, wildTable.PoisonousPlant, seed), Inns: inns, } } func (t WildTable) WildernessRegion(roll [2]int) string { return data.Tables.Wild.WildernessRegions[roll[0]-1][roll[1]-1] } func (t WildTable) WildernessLandmark(roll [2]int) string { return data.Tables.Wild.WildernessLandmarks[roll[0]-1][roll[1]-1] } func (t WildTable) WildernessStructure(roll [2]int) string { return data.Tables.Wild.WildernessStructures[roll[0]-1][roll[1]-1] } func (t WildTable) WildernessRegionTrait(roll [2]int) string { mazeTable := MazeTable{Roller: t.Roller} magicTable := MagicTable{Roller: t.Roller} switch roll { case [2]int{2, 3}: return mazeTable.DungeonForm(t.Roller.TableRoll()) case [2]int{2, 4}: return magicTable.EtherealEffect(t.Roller.TableRoll()) case [2]int{6, 4}: return magicTable.PhysicalEffect(t.Roller.TableRoll()) default: return data.Tables.Wild.WildernessRegionTraits[roll[0]-1][roll[1]-1] } } func (t WildTable) WildernessDiscovery(roll [2]int) string { switch roll { case [2]int{1, 5}: t := CityTable{Roller: t.Roller} return t.CityActivity(t.Roller.TableRoll()) case [2]int{1, 6}: npcTable := NPCTable{Roller: t.Roller} return npcTable.CivilizedNPC(t.Roller.TableRoll()) case [2]int{2, 3}: return MazeTable{Roller: t.Roller}.DungeonActivity(t.Roller.TableRoll()) case [2]int{3, 1}: return TreasureTable{Roller: t.Roller}.TreasureItem(t.Roller.TableRoll()) case [2]int{1, 3}: return "Lost an existing NPC" case [2]int{4, 1}: return MagicTable{Roller: t.Roller}.Mutation(t.Roller.TableRoll()) case [2]int{5, 1}: return "Lost an existing NPC" case [2]int{6, 1}: npcTable := NPCTable{Roller: t.Roller} return npcTable.UnderworldNPC(t.Roller.TableRoll()) case [2]int{6, 2}: return WildTable{Roller: t.Roller}.WildernessActivity(t.Roller.TableRoll()) case [2]int{6, 3}: return WildTable{Roller: t.Roller}.WildernessLandmark(t.Roller.TableRoll()) case [2]int{6, 4}: return WildTable{Roller: t.Roller}.WildernessStructure(t.Roller.TableRoll()) case [2]int{6, 5}: npcTable := NPCTable{Roller: t.Roller} return npcTable.WildernessNPC(t.Roller.TableRoll()) default: return data.Tables.Wild.WildernessDiscoveries[roll[0]-1][roll[1]-1] } } func (t WildTable) WildernessActivity(roll [2]int) string { switch roll { case [2]int{2, 1}: t := CityTable{Roller: t.Roller} return t.CityActivity(t.Roller.TableRoll()) case [2]int{2, 6}: return MazeTable{Roller: t.Roller}.DungeonActivity(t.Roller.TableRoll()) default: return data.Tables.Wild.WildernessActivities[roll[0]-1][roll[1]-1] } } func (t WildTable) WildernessHazard(roll [2]int) string { return data.Tables.Wild.WildernessHazards[roll[0]-1][roll[1]-1] } func (t WildTable) EdiblePlant(roll [2]int) string { return data.Tables.Wild.EdiblePlants[roll[0]-1][roll[1]-1] } func (t WildTable) PoisonousPlant(roll [2]int) string { return data.Tables.Wild.PoisonousPlants[roll[0]-1][roll[1]-1] } func (t WildTable) InnAdjective(roll [2]int) string { return data.Tables.Wild.InnAdjectives[roll[0]-1][roll[1]-1] } func (t WildTable) InnNoun(roll [2]int) string { return data.Tables.Wild.InnNouns[roll[0]-1][roll[1]-1] } func (t WildTable) InnQuirk(roll [2]int) string { cityTable := CityTable{Roller: t.Roller} mazeTable := MazeTable{Roller: t.Roller} switch roll { case [2]int{2, 3}: return cityTable.CityActivity(t.Roller.TableRoll()) case [2]int{3, 1}: return mazeTable.DungeonForm(t.Roller.TableRoll()) case [2]int{3, 3}: return "An existing faction hangout" case [2]int{3, 4}: return cityTable.FactionTrait(t.Roller.TableRoll()) case [2]int{4, 6}: buildingRoll, _ := t.Roller.Roll("1d6") return "Inn/" + cityTable.GenBuilding(buildingRoll[0]).Type case [2]int{5, 4}: return "Existing NPC hangout" default: return data.Tables.Wild.InnQuirks[roll[0]-1][roll[1]-1] } }