package tables import ( "mazeratsgen/internal/data" "mazeratsgen/internal/dice" ) type MagicTable struct { Roller *dice.Roller } func (t MagicTable) Generate() interface{} { return t.Spell(t.Roller.TableRoll()) } func (t MagicTable) Template() string { return "{{ . }}" } func (t MagicTable) Spell(roll [2]int) string { switch roll[0] { case 1: if roll[1] <= 3 { return t.PhysicalEffect(t.Roller.TableRoll()) + " " + t.PhysicalForm(t.Roller.TableRoll()) } return t.EtherealElement(t.Roller.TableRoll()) + " " + t.PhysicalForm(t.Roller.TableRoll()) case 2: if roll[1] <= 3 { return t.PhysicalEffect(t.Roller.TableRoll()) + " " + t.EtherealForm(t.Roller.TableRoll()) } return t.EtherealElement(t.Roller.TableRoll()) + " " + t.EtherealForm(t.Roller.TableRoll()) case 3: if roll[1] <= 3 { return t.EtherealEffect(t.Roller.TableRoll()) + " " + t.PhysicalForm(t.Roller.TableRoll()) } return t.PhysicalEffect(t.Roller.TableRoll()) + " " + t.EtherealElement(t.Roller.TableRoll()) case 4: if roll[1] <= 3 { return t.EtherealEffect(t.Roller.TableRoll()) + " " + t.EtherealForm(t.Roller.TableRoll()) } return t.PhysicalEffect(t.Roller.TableRoll()) + " " + t.EtherealElement(t.Roller.TableRoll()) case 5: if roll[1] <= 3 { return t.PhysicalElement(t.Roller.TableRoll()) + " " + t.PhysicalForm(t.Roller.TableRoll()) } return t.EtherealEffect(t.Roller.TableRoll()) + " " + t.PhysicalElement(t.Roller.TableRoll()) default: if roll[1] <= 3 { return t.PhysicalElement(t.Roller.TableRoll()) + " " + t.EtherealForm(t.Roller.TableRoll()) } return t.EtherealEffect(t.Roller.TableRoll()) + " " + t.EtherealElement(t.Roller.TableRoll()) } } func (t MagicTable) Element(roll int) string { if roll <= 3 { return t.PhysicalElement(t.Roller.TableRoll()) } return t.EtherealElement(t.Roller.TableRoll()) } func (t MagicTable) Effect(roll int) string { if roll <= 3 { return t.PhysicalEffect(t.Roller.TableRoll()) } return t.EtherealEffect(t.Roller.TableRoll()) } func (t MagicTable) PhysicalEffect(roll [2]int) string { return data.Tables.Magic.PhysicalEffects[roll[0]-1][roll[1]-1] } func (t MagicTable) PhysicalElement(roll [2]int) string { return data.Tables.Magic.PhysicalElements[roll[0]-1][roll[1]-1] } func (t MagicTable) PhysicalForm(roll [2]int) string { return data.Tables.Magic.PhysicalForms[roll[0]-1][roll[1]-1] } func (t MagicTable) EtherealEffect(roll [2]int) string { return data.Tables.Magic.EtherealEffects[roll[0]-1][roll[1]-1] } func (t MagicTable) EtherealElement(roll [2]int) string { return data.Tables.Magic.EtherealElements[roll[0]-1][roll[1]-1] } func (t MagicTable) EtherealForm(roll [2]int) string { return data.Tables.Magic.EtherealForms[roll[0]-1][roll[1]-1] } func (t MagicTable) Mutation(roll [2]int) string { monTable := MonsterTable{Roller: t.Roller} baseRoll, _ := t.Roller.Roll("1d6") switch roll { case [2]int{1, 6}: return monTable.Base(baseRoll[0]) + " Arms" case [2]int{2, 1}: return monTable.Base(baseRoll[0]) + " Eyes" case [2]int{2, 2}: return monTable.Base(baseRoll[0]) + " Head" case [2]int{2, 3}: return monTable.Base(baseRoll[0]) + " Legs" case [2]int{2, 4}: return monTable.Base(baseRoll[0]) + " Mouth" case [2]int{2, 5}: return monTable.Base(baseRoll[0]) + " Skin" case [2]int{2, 6}: return monTable.Base(baseRoll[0]) + " Form" case [2]int{4, 2}: return TreasureTable{Roller: t.Roller}.TreasureItem(t.Roller.TableRoll()) + " Form" case [2]int{4, 6}: return monTable.Feature(t.Roller.TableRoll()) case [2]int{5, 1}: return monTable.Trait(t.Roller.TableRoll()) case [2]int{5, 4}: return t.PhysicalElement(t.Roller.TableRoll()) + " Skin" default: return data.Tables.Magic.Mutations[roll[0]-1][roll[1]-1] } } func (t MagicTable) Insanity(roll [2]int) string { monTable := MonsterTable{Roller: t.Roller} switch roll { case [2]int{1, 3}: roll, _ := t.Roller.Roll("1d6") return monTable.Base(roll[0]) + " Form" case [2]int{5, 6}: return monTable.Ability(t.Roller.TableRoll()) case [2]int{6, 1}: return monTable.Feature(t.Roller.TableRoll()) case [2]int{6, 2}: return monTable.Trait(t.Roller.TableRoll()) case [2]int{6, 4}: return NPCTable{Roller: t.Roller}.Personality(t.Roller.TableRoll()) default: return data.Tables.Magic.Insanities[roll[0]-1][roll[1]-1] } } func (t MagicTable) Catastrophe(roll [2]int) string { switch roll { case [2]int{1, 3}: return "Animials " + t.Mutation(t.Roller.TableRoll()) case [2]int{4, 1}: return "Mass " + t.Insanity(t.Roller.TableRoll()) case [2]int{4, 2}: return "Mass " + t.Mutation(t.Roller.TableRoll()) default: return data.Tables.Magic.Catastrophes[roll[0]-1][roll[1]-1] } }