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.
298 lines
8.1 KiB
298 lines
8.1 KiB
package tables
|
|
|
|
import (
|
|
"mazeratsgen/internal/data"
|
|
"mazeratsgen/internal/dice"
|
|
"mazeratsgen/internal/helpers"
|
|
"strings"
|
|
)
|
|
|
|
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
|
|
Seed int64
|
|
}
|
|
|
|
func (t *NPCTable) Generate() NPC {
|
|
var occupation, class, gender string
|
|
|
|
occupationRoll, _ := t.Roller.Roll("1d3")
|
|
switch occupationRoll[0] {
|
|
case 1:
|
|
occupation = t.CivilizedNPC(t.Roller.TableRoll())
|
|
case 2:
|
|
occupation = t.UnderworldNPC(t.Roller.TableRoll())
|
|
case 3:
|
|
occupation = t.WildernessNPC(t.Roller.TableRoll())
|
|
}
|
|
|
|
classRoll, _ := t.Roller.Roll("1d2")
|
|
if classRoll[0] == 1 {
|
|
class = "Upperclass"
|
|
} else {
|
|
class = "Lowerclass"
|
|
}
|
|
|
|
genderRoll, _ := t.Roller.Roll("1d2")
|
|
if genderRoll[0] == 1 {
|
|
gender = "Male"
|
|
} else {
|
|
gender = "Female"
|
|
}
|
|
|
|
return NPC{
|
|
Name: GenName(class, gender, t.Roller.Seed).FullName,
|
|
Gender: gender,
|
|
Occupation: occupation,
|
|
Class: class,
|
|
Appearance: t.Appearance(t.Roller.TableRoll()),
|
|
PhysicalDetail: t.PhysicalDetail(t.Roller.TableRoll()),
|
|
Clothing: t.Clothing(t.Roller.TableRoll()),
|
|
Personality: t.Personality(t.Roller.TableRoll()),
|
|
Mannerism: t.Mannerism(t.Roller.TableRoll()),
|
|
Secret: t.Secret(t.Roller.TableRoll()),
|
|
Reputation: t.Reputation(t.Roller.TableRoll()),
|
|
Relationship: t.Relationship(t.Roller.TableRoll()),
|
|
Hobby: t.Hobby(t.Roller.TableRoll()),
|
|
DivineDomain: t.DivineDomain(t.Roller.TableRoll()),
|
|
AfterTheParty: t.AfterTheParty(t.Roller.TableRoll()),
|
|
Assets: helpers.GenUniqueItems(3, t.Asset, t.Roller.Seed),
|
|
Liabilities: helpers.GenUniqueItems(3, t.Liability, t.Roller.Seed),
|
|
Goals: helpers.GenUniqueItems(3, t.NPCGoal, t.Roller.Seed),
|
|
Misfortunes: helpers.GenUniqueItems(3, t.Misfortune, t.Roller.Seed),
|
|
Missions: helpers.GenUniqueItems(3, t.Mission, t.Roller.Seed),
|
|
Methods: helpers.GenUniqueItems(3, t.Method, t.Roller.Seed),
|
|
Seed: t.Roller.Seed,
|
|
}
|
|
}
|
|
|
|
func (t *NPCTable) Template() string {
|
|
return strings.TrimSpace(`
|
|
Name: {{.Name}}
|
|
Gender: {{.Gender}}
|
|
Class: {{.Class}}
|
|
Occupation: {{.Occupation}}
|
|
Appearance: {{.Appearance}}
|
|
Physical Detail: {{.PhysicalDetail}}
|
|
Clothing: {{.Clothing}}
|
|
Personality: {{.Personality}}
|
|
Mannerism: {{.Mannerism}}
|
|
Secret: {{.Secret}}
|
|
Reputation: {{.Reputation}}
|
|
Relationship: {{.Relationship}}
|
|
Hobby: {{.Hobby}}
|
|
Divine Domain: {{.DivineDomain}}
|
|
After The Party: {{.AfterTheParty}}
|
|
Assets:
|
|
{{- range $asset := .Assets }}
|
|
{{$asset}}
|
|
{{- end}}
|
|
Liabilities:
|
|
{{- range $liability := .Liabilities }}
|
|
{{$liability}}
|
|
{{- end}}
|
|
Goal:
|
|
{{- range $goal := .Goals }}
|
|
{{$goal}}
|
|
{{- end}}
|
|
Misfortunes:
|
|
{{- range $misfortune := .Misfortunes }}
|
|
{{$misfortune}}
|
|
{{- end}}
|
|
Missions:
|
|
{{- range $mission := .Missions }}
|
|
{{$mission}}
|
|
{{- end}}
|
|
Methods:
|
|
{{- range $method := .Methods }}
|
|
{{$method}}
|
|
{{- end}}
|
|
Seed: {{.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]
|
|
}
|
|
}
|
|
|