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.
 
 
 
 

252 lines
7.2 KiB

package tables
import (
"mazeratsgen/internal/data"
"mazeratsgen/internal/dice"
"mazeratsgen/internal/helpers"
)
type NPCTable struct {
Roller *dice.Roller
}
type NPC struct {
Name string
Class string
Occupation string
Gender string
Appearance string
PhysicalDetail string
Clothing string
Personality string
Mannerism string
Secret string
Reputation string
Relationship string
Hobby string
DivineDomain string
AfterTheParty string
Assets []string
Liabilities []string
Goals []string
Misfortunes []string
Missions []string
Methods []string
}
func GenNPC(seed int64) NPC {
roller := dice.NewRoller(seed)
npcTable := NPCTable{Roller: roller}
var occupation, class, gender string
occupationRoll, _ := roller.Roll("1d3")
switch occupationRoll[0] {
case 1:
occupation = npcTable.CivilizedNPC(roller.TableRoll())
case 2:
occupation = npcTable.UnderworldNPC(roller.TableRoll())
case 3:
occupation = npcTable.WildernessNPC(roller.TableRoll())
}
classRoll, _ := roller.Roll("1d2")
if classRoll[0] == 1 {
class = "Upperclass"
} else {
class = "Lowerclass"
}
genderRoll, _ := roller.Roll("1d2")
if genderRoll[0] == 1 {
gender = "Male"
} else {
gender = "Female"
}
return NPC{
Name: GenName(class, gender, seed).FullName,
Occupation: occupation,
Class: class,
Gender: gender,
Appearance: npcTable.Appearance(roller.TableRoll()),
PhysicalDetail: npcTable.PhysicalDetail(roller.TableRoll()),
Clothing: npcTable.Clothing(roller.TableRoll()),
Personality: npcTable.Personality(roller.TableRoll()),
Mannerism: npcTable.Mannerism(roller.TableRoll()),
Secret: npcTable.Secret(roller.TableRoll()),
Reputation: npcTable.Reputation(roller.TableRoll()),
Relationship: npcTable.Relationship(roller.TableRoll()),
Hobby: npcTable.Hobby(roller.TableRoll()),
DivineDomain: npcTable.DivineDomain(roller.TableRoll()),
AfterTheParty: npcTable.AfterTheParty(roller.TableRoll()),
Assets: helpers.GenUniqueItems(3, npcTable.Asset, seed),
Liabilities: helpers.GenUniqueItems(3, npcTable.Liability, seed),
Goals: helpers.GenUniqueItems(3, npcTable.NPCGoal, seed),
Misfortunes: helpers.GenUniqueItems(3, npcTable.Misfortune, seed),
Missions: helpers.GenUniqueItems(3, npcTable.Mission, seed),
Methods: helpers.GenUniqueItems(3, npcTable.Method, seed),
}
}
func (t NPCTable) CivilizedNPC(tableRole [2]int) string {
return data.Tables.NPC.CivilizedNPCs[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) UnderworldNPC(tableRole [2]int) string {
return data.Tables.NPC.UnderworldNPCs[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) WildernessNPC(tableRole [2]int) string {
return data.Tables.NPC.WildernessNPCs[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) FemaleName(tableRole [2]int) string {
return data.Tables.NPC.FemaleNames[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) MaleName(tableRole [2]int) string {
return data.Tables.NPC.MaleNames[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) UpperClassSurname(tableRole [2]int) string {
return data.Tables.NPC.UpperClassSurnames[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) LowerClassSurname(tableRole [2]int) string {
return data.Tables.NPC.LowerClassSurnames[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Asset(tableRole [2]int) string {
switch tableRole {
case [2]int{2, 3}:
return "Leader of existing faction"
case [2]int{2, 4}:
return "Member of existing faction"
default:
return data.Tables.NPC.Assets[tableRole[0]-1][tableRole[1]-1]
}
}
func (t NPCTable) Liability(tableRole [2]int) string {
switch tableRole {
case [2]int{3, 1}:
return MagicTable{Roller: t.Roller}.Insanity(t.Roller.TableRoll())
default:
return data.Tables.NPC.Liabilities[tableRole[0]-1][tableRole[1]-1]
}
}
func (t NPCTable) NPCGoal(tableRole [2]int) string {
treasureTable := TreasureTable{Roller: t.Roller}
switch tableRole {
case [2]int{1, 3}:
return "Acquire " + treasureTable.TreasureItem(t.Roller.TableRoll())
case [2]int{1, 4}:
return "Craft " + treasureTable.TreasureItem(t.Roller.TableRoll())
case [2]int{1, 5}:
return "Destroy an existing faction"
case [2]int{1, 6}:
return "Destroy " + treasureTable.TreasureItem(t.Roller.TableRoll())
case [2]int{2, 3}:
return "Found a faction"
case [2]int{2, 6}:
return "Impress an existing NPC"
case [2]int{3, 2}:
return "Infiltrate an existing faction"
case [2]int{3, 4}:
return "Kidnap an existing NPC"
case [2]int{3, 5}:
return "Lead an existing faction"
case [2]int{4, 1}:
return "Locate an existing NPC"
case [2]int{4, 6}:
return "Rescue an existing NPC"
case [2]int{5, 2}:
return "Restore an existing faction"
case [2]int{5, 5}:
return "Sabotage an existing faction"
case [2]int{6, 2}:
return "Serve an existing faction"
default:
return data.Tables.NPC.NPCGoals[tableRole[0]-1][tableRole[1]-1]
}
}
func (t NPCTable) Misfortune(tableRole [2]int) string {
return data.Tables.NPC.Misfortunes[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Mission(tableRole [2]int) string {
return data.Tables.NPC.Missions[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Method(tableRole [2]int) string {
return data.Tables.NPC.Methods[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Appearance(tableRole [2]int) string {
return data.Tables.NPC.Appearances[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) PhysicalDetail(tableRole [2]int) string {
return data.Tables.NPC.PhysicalDetails[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Clothing(tableRole [2]int) string {
return data.Tables.NPC.Clothing[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Personality(tableRole [2]int) string {
return data.Tables.NPC.Personalities[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Mannerism(tableRole [2]int) string {
return data.Tables.NPC.Mannerisms[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Secret(tableRole [2]int) string {
switch tableRole {
case [2]int{4, 5}:
return t.Misfortune(t.Roller.TableRoll())
case [2]int{5, 2}:
return "An existing NPC"
default:
return data.Tables.NPC.Secrets[tableRole[0]-1][tableRole[1]-1]
}
}
func (t NPCTable) Reputation(tableRole [2]int) string {
return data.Tables.NPC.Reputations[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Hobby(tableRole [2]int) string {
return data.Tables.NPC.Hobbies[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) Relationship(tableRole [2]int) string {
return data.Tables.NPC.Relationships[tableRole[0]-1][tableRole[1]-1]
}
func (t NPCTable) DivineDomain(tableRole [2]int) string {
switch tableRole {
case [2]int{1, 1}:
roll, _ := t.Roller.Roll("1d6")
return MonsterTable{Roller: t.Roller}.Base(roll[0])
case [2]int{2, 5}:
roll, _ := t.Roller.Roll("1d6")
return MagicTable{Roller: t.Roller}.Element(roll[0])
case [2]int{4, 1}:
return "An existing NPC"
default:
return data.Tables.NPC.DivineDomains[tableRole[0]-1][tableRole[1]-1]
}
}
func (t NPCTable) AfterTheParty(tableRole [2]int) string {
switch tableRole {
case [2]int{3, 3}:
return "Insulted an existing faction"
default:
return data.Tables.NPC.AfterTheParty[tableRole[0]-1][tableRole[1]-1]
}
}