Advertisement
jason-niehoff

Character Creation

Dec 1st, 2017
917
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Clear-Host
  2. class DiceRoll
  3. {
  4.     DiceRoll ()
  5.     {
  6.     }
  7.    
  8.     [int] d3 ()
  9.     {
  10.         $roll = Get-Random -Minimum 1 -Maximum 3
  11.         return $roll
  12.     }
  13.     [int] d4 ()
  14.     {
  15.         $roll = Get-Random -Minimum 1 -Maximum 4
  16.         return $roll
  17.     }
  18.     [int] d4x3 ()
  19.     {
  20.         $roll1 = Get-Random -Minimum 1 -Maximum 4
  21.         $roll2 = Get-Random -Minimum 1 -Maximum 4
  22.         $roll3 = Get-Random -Minimum 1 -Maximum 4
  23.         $roll = $roll1 + $roll2 + $roll3
  24.         return $roll
  25.     }
  26.     [int] d6 ()
  27.     {
  28.         $roll = Get-Random -Minimum 1 -Maximum 6
  29.         return $roll
  30.     }
  31.     [int] d6x2 ()
  32.     {
  33.         $roll1 = Get-Random -Minimum 1 -Maximum 6
  34.         $roll2 = Get-Random -Minimum 1 -Maximum 6
  35.         $roll = $roll1 + $roll2
  36.         return $roll
  37.     }
  38.     [int] d6x3 ()
  39.     {
  40.         $roll1 = Get-Random -Minimum 1 -Maximum 6
  41.         $roll2 = Get-Random -Minimum 1 -Maximum 6
  42.         $roll3 = Get-Random -Minimum 1 -Maximum 6
  43.         $roll = $roll1 + $roll2 + $roll3
  44.         return $roll
  45.     }
  46.     [int] d8 ()
  47.     {
  48.         $roll = Get-Random -Minimum 1 -Maximum 8
  49.         return $roll
  50.     }
  51.     [int] d10 ()
  52.     {
  53.         $roll = Get-Random -Minimum 1 -Maximum 10
  54.         return $roll
  55.     }
  56.     [int] d12 ()
  57.     {
  58.         $roll = Get-Random -Minimum 1 -Maximum 12
  59.         return $roll
  60.     }
  61.     [int] d20 ()
  62.     {
  63.         $roll = Get-Random -Minimum 1 -Maximum 20
  64.         return $roll
  65.     }
  66.     [int] d100 ()
  67.     {
  68.         $roll = Get-Random -Minimum 1 -Maximum 100
  69.         return $roll
  70.     }
  71.    
  72. }
  73. class Character
  74. {
  75.     [string]$race
  76.     [string]$firstName
  77.     [string]$lastName
  78.     [int16]$charisma
  79.     [int16]$chaModifier
  80.     [string]$class
  81.     [int]$age
  82.     [string]$background
  83.     [string]$parents
  84.     [switch]$parentsKnown
  85.     [string]$nonHumanParents
  86.     [string]$birthplace
  87.     [int]$siblingCount
  88.     [hashtable]$siblings
  89.     [string]$family
  90.     [array]$familyLifestyle
  91.     [string]$childhoodHome
  92.     [string]$childhoodMemories
  93.     [string]$backgroundInfo
  94.     [string]$classTraining
  95.     [array]$lifeEvent
  96.     [int]$lifeEventCount
  97.     $strength
  98.     $dexterity
  99.     $constitution
  100.     $intelligence
  101.     $wisdom
  102.  
  103.     Character ()
  104.     {
  105.        
  106.     }
  107. }
  108.  
  109. class StatsGenerator
  110. {
  111.     $dice
  112.     $str
  113.     $dex
  114.     $con
  115.     $int
  116.     $wis
  117.     $cha
  118.  
  119.     StatsGenerator ()
  120.     {
  121.         $this.dice = [DiceRoll]::new()
  122.         $this.str = @(
  123.             $this.dice.d6(),
  124.             $this.dice.d6(),
  125.             $this.dice.d6(),
  126.             $this.dice.d6()
  127.         )
  128.         $this.dex = @(
  129.             $this.dice.d6(),
  130.             $this.dice.d6(),
  131.             $this.dice.d6(),
  132.             $this.dice.d6()
  133.         )
  134.         $this.con = @(
  135.             $this.dice.d6(),
  136.             $this.dice.d6(),
  137.             $this.dice.d6(),
  138.             $this.dice.d6()
  139.         )
  140.         $this.int = @(
  141.             $this.dice.d6(),
  142.             $this.dice.d6(),
  143.             $this.dice.d6(),
  144.             $this.dice.d6()
  145.         )
  146.         $this.wis = @(
  147.             $this.dice.d6(),
  148.             $this.dice.d6(),
  149.             $this.dice.d6(),
  150.             $this.dice.d6()
  151.         )
  152.         $this.cha = @(
  153.             $this.dice.d6(),
  154.             $this.dice.d6(),
  155.             $this.dice.d6(),
  156.             $this.dice.d6()
  157.         )
  158.     }
  159. }
  160. class OriginsTables
  161. {
  162.     $supplementalTable
  163.     $dice
  164.     OriginsTables ()
  165.     {
  166.         $this.supplementalTable = [SupplementalTables]::new()
  167.         $this.dice = [DiceRoll]::new()
  168.     }
  169.     [string] nonHumanParents ($race)
  170.     {
  171.         $parents = $null
  172.         $roll = $this.dice.d8()
  173.    
  174.         if ($race.toLower() -like 'half-elf')
  175.         {
  176.             if ($roll -ge 1 -and $roll -le 5)
  177.             {
  178.                 $parents = "One parent was an elf and the other was a human."  
  179.             }
  180.             elseif ($roll -eq 6)
  181.             {
  182.                 $parents = "One parent was an elf and the other was a half-elf."
  183.             }
  184.             elseif ($roll -eq 7)
  185.             {
  186.                 $parents = "One parent was a human and the other was a half-elf."
  187.             }
  188.             elseif ($roll -eq 8)
  189.             {
  190.                 $parents = "Both parents were half-elves."
  191.             }
  192.         }
  193.    
  194.         elseif ($race.toLower() -like 'half-orc')
  195.         {
  196.             if ($roll -ge 1 -and $roll -le 3)
  197.             {
  198.                 $parents = "One parent was an orc and the other was a human."
  199.             }
  200.             elseif ($roll -ge 4 -and $roll -le 5)
  201.             {
  202.                 $parents = "One parent was an orc and the other was a half-orc."    
  203.             }
  204.             elseif ($roll -ge 6 -and $roll -le 7)
  205.             {
  206.                 $parents = "One parent was a human and the other was a half-orc."    
  207.             }
  208.             elseif ($roll -eq 8)
  209.             {
  210.                 $parents = "Both parents were half-orcs."    
  211.             }
  212.         }
  213.    
  214.         elseif ($race.toLower() -like 'tiefling')
  215.         {
  216.             if ($roll -ge 1 -and $roll -le 4)
  217.             {
  218.                 $parents = "Both parents were humans, their infernal heritage dormant until you came along."
  219.             }
  220.             elseif ($roll -ge 5 -and $roll -le 6)
  221.             {
  222.                 $parents = "One parent was a tiefling and the other was a human."    
  223.             }
  224.             elseif ($roll -eq 7)
  225.             {
  226.                 $parents = "One parent was a tiefling and the other was a devil."    
  227.             }
  228.             elseif ($roll -eq 8)
  229.             {
  230.                 $parents = "One parent was a human and the other was a devil."    
  231.             }
  232.         }
  233.         return $parents
  234.     }
  235.     [switch] parentsKnown ()
  236.     {
  237.         $roll = $this.dice.d100()
  238.             if ($roll -ge 1 -and $roll -le 95)
  239.             {
  240.                 return $true
  241.             }
  242.             Else
  243.             {
  244.                 return $false
  245.             }
  246.     }
  247.     [string] birthplace ()
  248.     {
  249.         $place = $null
  250.         $roll = $this.dice.d100()
  251.  
  252.         if ($roll-ge 1 -and $roll -le 50)
  253.         {
  254.             $place = "Home."
  255.         }
  256.         elseif ($roll -ge 51 -and $roll -le 55)
  257.         {
  258.             $place = "Home of a family friend."    
  259.         }
  260.         elseif ($roll -ge 56 -and $roll -le 63)
  261.         {
  262.             $place = "Home of a healer or midwife."    
  263.         }
  264.         elseif ($roll -ge 64 -and $roll -le 65)
  265.         {
  266.             $place = "Carriage, cart, or wagon."    
  267.         }
  268.         elseif ($roll -ge 66 -and $roll -le 68)
  269.         {
  270.             $place = "Barn, shed, or other outbuilding."    
  271.         }
  272.         elseif ($roll -ge 69 -and $roll -le 70)
  273.         {
  274.             $place = "Cave."    
  275.         }
  276.         elseif ($roll -ge 71 -and $roll -le 72)
  277.         {
  278.             $place = "Field."    
  279.         }
  280.         elseif ($roll -ge 73 -and $roll -le 74)
  281.         {
  282.             $place = "Forest."    
  283.         }
  284.         elseif ($roll -ge 75 -and $roll -le 77)
  285.         {
  286.             $place = "Temple."    
  287.         }
  288.         elseif ($roll -eq 78)
  289.         {
  290.             $place = "Battlefield."    
  291.         }
  292.         elseif ($roll -ge 79 -and $roll -le 80)
  293.         {
  294.             $place = "Alley or street."    
  295.         }
  296.         elseif ($roll -ge 81 -and $roll -le 82)
  297.         {
  298.             $place = "Brothel, tavern, or inn."    
  299.         }
  300.         elseif ($roll -ge 83 -and $roll -le 84)
  301.         {
  302.             $place = "Castle, keep, tower, or palace."    
  303.         }
  304.         elseif ($roll -eq 85)
  305.         {
  306.             $place = "Sewer or rubbish heap."    
  307.         }
  308.         elseif ($roll -ge 86 -and $roll -le 88)
  309.         {
  310.             $place = "Among people of a different race."    
  311.         }
  312.         elseif ($roll -ge 89 -and $roll -le 91)
  313.         {
  314.             $place = "On board a boat or ship."    
  315.         }
  316.         elseif ($roll -ge 92 -and $roll -le 93)
  317.         {
  318.             $place = "In a prision or in the headquarters of a secret organization."    
  319.         }
  320.         elseif ($roll -ge 94 -and $roll -le 95)
  321.         {
  322.             $place = "In a sage's laboratory."
  323.         }
  324.         elseif ($roll -eq 96)
  325.         {
  326.             $place = "In the Feywild."    
  327.         }
  328.         elseif ($roll -eq 97)
  329.         {
  330.             $place = "In the Shadowfell."    
  331.         }
  332.         elseif ($roll -eq 98)
  333.         {
  334.             $place = "On the Astral Place or the Ethereal Plane."    
  335.         }
  336.         elseif ($roll -eq 99)
  337.         {
  338.             $place = "On an Inner Plane of your choice."    
  339.         }
  340.         elseif ($roll -eq 100)
  341.         {
  342.             $place = "On an Outer Plance of your choice."    
  343.         }
  344.    
  345.         return $place
  346.     }
  347.     [int] numberOfSiblings ($race)
  348.     {
  349.         $roll = $this.dice.d10()
  350.         $number = $null
  351.         if ($race -like 'dwarf' -or $race -like 'elf')
  352.         {
  353.             $roll = $roll - 2    
  354.         }
  355.         if ($roll -le 2)
  356.         {
  357.             $number = 0    
  358.         }
  359.         elseif ($roll -ge 3 -and $roll -le 4)
  360.         {
  361.             $number = $this.dice.d3()
  362.             $number = $number + 1    
  363.         }
  364.         elseif ($roll -ge 5 -and $roll -le 6)
  365.         {
  366.             $number = $this.dice.d4()
  367.             $number = $number + 1      
  368.         }
  369.         elseif ($roll -ge 7 -and $roll -le 8)
  370.         {
  371.             $number = $this.dice.d6()
  372.             $number = $number + 2      
  373.         }
  374.         elseif ($roll -ge 9 -and $roll -le 10)
  375.         {
  376.             $number = $this.dice.d8()
  377.             $number = $number + 3
  378.         }
  379.    
  380.         return $number
  381.     }
  382.     [string] family ([switch]$parentsKnow)
  383.     {
  384.         $family = $null
  385.         $roll = $this.dice.d100()
  386.         $parent = $null
  387.         if ($roll -eq 1)
  388.         {
  389.             $family = "None."
  390.             if ($parentsKnow -eq $true)
  391.             {
  392.                 $parent = $this.absentParent()
  393.             }
  394.             else {
  395.                 $parent = $null
  396.             }
  397.         }
  398.         elseif ($roll -eq 2)
  399.         {
  400.             $family = "Institution, such as an asylum."
  401.             if ($parentsKnow -eq $true)
  402.             {
  403.                 $parent = $this.absentParent()  
  404.             }
  405.             else
  406.             {
  407.                 $parent = $null
  408.             }
  409.         }
  410.         elseif ($roll -eq 3)
  411.         {
  412.            $family = "Temple."
  413.            if ($parentsKnow -eq $true)
  414.            {
  415.                 $parent = $this.absentParent()  
  416.            }
  417.            else
  418.            {
  419.                 $parent = $null
  420.            }
  421.            
  422.         }
  423.         elseif ($roll -ge 4 -and $roll -le 5)
  424.         {
  425.             $family = "Orphanage."
  426.             if ($parentsKnow -eq $true)
  427.             {
  428.                  $parent = $this.absentParent()    
  429.             }
  430.             else
  431.             {
  432.                  $parent = $null
  433.             }  
  434.         }
  435.         elseif ($roll -ge 6 -and $roll -le 7)
  436.         {
  437.             $family = "Guardian."
  438.             if ($parentsKnow -eq $true)
  439.             {
  440.                  $parent = $this.absentParent()  
  441.             }
  442.             else
  443.             {
  444.                  $parent = $null
  445.             }    
  446.         }
  447.         elseif ($roll -ge 8 -and $roll -le 15)
  448.         {
  449.             $family = "Paternal or maternal aunt, uncle, or both; or extended family such as a tribe or clan."
  450.             if ($parentsKnow -eq $true)
  451.             {
  452.                  $parent = $this.absentParent()  
  453.             }
  454.             else
  455.             {
  456.                  $parent = $null
  457.             }
  458.         }
  459.         elseif ($roll -ge 16 -and $roll -le 25)
  460.         {
  461.             $family = "Paternal or maternal grandparent(s)."
  462.             if ($parentsKnow -eq $true)
  463.             {
  464.                  $parent = $this.absentParent()
  465.             }
  466.             else
  467.             {
  468.                  $parent = $null
  469.             }    
  470.         }
  471.         elseif ($roll -ge 26 -and $roll -le 35)
  472.         {
  473.             $family = "Adoptive family (same or different race)."
  474.             if ($parentsKnow -eq $true)
  475.             {
  476.                  $parent = $this.absentParent()
  477.             }
  478.             else
  479.             {
  480.                  $parent = $null
  481.             }    
  482.         }
  483.         elseif ($roll -ge 36 -and $roll -le 55)
  484.         {
  485.             $family = "Single father or stepfather."    
  486.         }
  487.         elseif ($roll -ge 56 -and $roll -le 75)
  488.         {
  489.             $family = "Single mother or stepmother."    
  490.         }
  491.         elseif ($roll -ge 76 -and $roll -le 100)
  492.         {
  493.             $family = "Mother and father."    
  494.         }
  495.    
  496.         if (![string]::IsNullOrEmpty($parent))
  497.         {
  498.             $familyDetail = ($family, $parent) -join " "
  499.                
  500.         }
  501.         else
  502.         {
  503.             $familyDetail = $family
  504.         }
  505.        
  506.         return $familyDetail
  507.     }
  508.     [string] absentParent ()
  509.     {
  510.         $roll = $this.dice.d4()
  511.         $parent = $null    
  512.         if ($roll -eq 1)
  513.         {
  514.             $death = $this.supplementalTable.causeOfDeathTable()
  515.             $parent = "$death"
  516.         }
  517.         elseif ($roll -eq 2)
  518.         {
  519.             $parent = "Your parent was imprisoned, enslaved, or otherwise taken away."    
  520.         }
  521.         elseif ($roll -eq 3)
  522.         {
  523.             $parent = "Your parent abandoned you."    
  524.         }
  525.         elseif ($roll -eq 4)
  526.         {
  527.             $parent = "Your parent disappeared to an unknown fate."    
  528.         }
  529.         return $parent
  530.     }
  531.     [array] familyLifestyle ()
  532.     {
  533.         $lifeStyle = $null
  534.         $modifier = $null
  535.         $roll = $this.dice.d6x3()
  536.        
  537.         if ($roll -eq 3)
  538.         {
  539.             $lifeStyle = "Wretched"
  540.             $modifier = -40    
  541.         }
  542.         elseif ($roll -ge 4 -and $roll -le 5)
  543.         {
  544.             $lifeStyle = "Squalid"
  545.             $modifier = -20    
  546.         }
  547.         elseif ($roll -ge 6 -and $roll -le 8)
  548.         {
  549.             $lifeStyle = "Poor"
  550.             $modifier = -10    
  551.         }
  552.         elseif ($roll -ge 9 -and $roll -le 12)
  553.         {
  554.             $lifeStyle = "Modest"
  555.             $modifier = 0    
  556.         }
  557.         elseif ($roll -ge 13 -and $roll -le 15)
  558.         {
  559.             $lifeStyle = "Comfortable"
  560.             $modifier = 10    
  561.         }
  562.         elseif ($roll -ge 16 -and $roll -le 17)
  563.         {
  564.             $lifeStyle = "Wealthy"
  565.             $modifier = 20    
  566.         }
  567.         elseif ($roll -eq 18)
  568.         {
  569.             $lifeStyle = "Aristocratic"
  570.             $modifier = 40    
  571.         }
  572.         $lifestyleArray = @(
  573.             $lifeStyle,
  574.             $modifier
  575.         )
  576.         return $lifestyleArray
  577.     }
  578.     [string] childhoodHome ($modifier)
  579.     {
  580.         $roll = $this.dice.d100()
  581.         $roll = $roll + $modifier
  582.         $homeType = $null
  583.    
  584.         if ($roll -le 0)
  585.         {
  586.             $homeType = "On the streets."
  587.         }
  588.         elseif ($roll -ge 1 -and $roll -le 20)
  589.         {
  590.             $homeType = "Rundown shack."    
  591.         }
  592.         elseif ($roll -ge 21 -and $roll -le 30)
  593.         {
  594.             $homeType = "No permanent residence; you moved around a lot."    
  595.         }
  596.         elseif ($roll -ge 31 -and $roll -le 40)
  597.         {
  598.             $homeType = "Encampment or village in the wilderness."    
  599.         }
  600.         elseif ($roll -ge 41 -and $roll -le 50)
  601.         {
  602.             $homeType = "Apartment in a rundown neighborhood."    
  603.         }
  604.         elseif ($roll -ge 51 -and $roll -le 70)
  605.         {
  606.             $homeType = "Small house."    
  607.         }
  608.         elseif ($roll -ge 71 -and $roll -le 90)
  609.         {
  610.             $homeType = "Large house."    
  611.         }
  612.         elseif ($roll -ge 91 -and $roll -le 110)
  613.         {
  614.             $homeType = "Mansion."
  615.         }
  616.         elseif ($roll -ge 111)
  617.         {
  618.             $homeType = "Palace or castle."    
  619.         }
  620.    
  621.         return $homeType
  622.     }
  623.     [string] childhoodMemories ($chaModifier)
  624.     {
  625.         $roll = $this.dice.d6x3()
  626.         $roll = $roll + $chaModifier
  627.         $memory = $null
  628.    
  629.         if ($roll -le 3)
  630.         {
  631.             $memory = "I am still haunted by my childhood, when I was treated badly by my peers."
  632.         }
  633.         elseif ($roll -ge 4 -and $roll -le 5)
  634.         {
  635.             $memory = "I spent most of my childhood alone, with no close friends."    
  636.         }
  637.         elseif ($roll -ge 6 -and $roll -le 8)
  638.         {
  639.             $memory = "Others saw me as being diiferent or strange, and so I had few companions."    
  640.         }
  641.         elseif ($roll -ge 9 -and $roll -le 12)
  642.         {
  643.             $memory = "I had a few close friends and lived an ordinary childhood."    
  644.         }
  645.         elseif ($roll -ge 13 -and $roll -le 15)
  646.         {
  647.             $memory = "I had several friends, and my childhood was generally a happy one."    
  648.         }
  649.         elseif ($roll -ge 16 -and $roll -le 17)
  650.         {
  651.             $memory = "I always found it easy to make Friends, and I loved being around people."    
  652.         }
  653.         elseif ($roll -ge 18)
  654.         {
  655.             $memory = "Everyone knew who I was, and I had friends everywhere I went."    
  656.         }
  657.    
  658.         return $memory  
  659.     }
  660. }
  661.  
  662. class SiblingDetail
  663. {
  664.     [string] $job
  665.     [string] $alignment
  666.     [string] $status
  667.     [string] $relationship
  668.     [string] $birthOrder
  669.     $dice
  670.  
  671.  
  672.     SiblingDetail ()
  673.     {
  674.         $supplementalTable = [SupplementalTables]::new()
  675.         $this.dice = [DiceRoll]::new()
  676.         $this.job = $supplementalTable.occupationTable()
  677.         $this.alignment = $supplementalTable.alignmentTable()
  678.         $this.status = $supplementalTable.statusTable()
  679.         $this.relationship = $supplementalTable.relationshipTable()
  680.         $this.birthOrder = $this.birthOrderTable()
  681.     }
  682.  
  683.     [string] birthOrderTable ()
  684.     {
  685.         $birthOrderRoll = $this.dice.d6x2()
  686.         $order = $null
  687.         if ($birthOrderRoll -eq 2)
  688.         {
  689.             $order = "Twin, triplet, or quadruplet"    
  690.         }
  691.         elseif ($birthOrderRoll -ge 3 -and $birthOrderRoll -le 7)
  692.         {
  693.             $order = "Older"    
  694.         }
  695.         elseif ($birthOrderRoll -ge 8 -and $birthOrderRoll -le 12)
  696.         {
  697.             $order = "Younger"    
  698.         }
  699.         return $order
  700.     }
  701. }
  702.  
  703. class SupplementalTables
  704. {
  705.     $dice
  706.     SupplementalTables ()
  707.     {
  708.         $this.dice = [DiceRoll]::new()
  709.     }
  710.     [string] alignmentTable ()
  711.     {
  712.         $alignmentRoll = $this.dice.d6x3()
  713.         $alignmentResult = $null
  714.         if ($alignmentRoll -eq 3)
  715.         {
  716.             $alignmentArray = @(
  717.                 'Chaotics Evil',
  718.                 'Chaotic Neutral'
  719.             )
  720.             $alignmentResult = Get-Random -InputObject $alignmentArray    
  721.         }
  722.         elseif ($alignmentRoll -ge 4 -and $alignmentRoll -le 5)
  723.         {
  724.             $alignmentResult = "Lawful Evil"    
  725.         }
  726.         elseif ($alignmentRoll -ge 6 -and $alignmentRoll -le 8)
  727.         {
  728.             $alignmentResult = "Neutral Evil"    
  729.         }
  730.         elseif ($alignmentRoll -ge 9 -and $alignmentRoll -le 12)
  731.         {
  732.             $alignmentResult = "Neutral"    
  733.         }
  734.         elseif ($alignmentRoll -ge 13 -and $alignmentRoll -le 15)
  735.         {
  736.             $alignmentResult = "Neutral Good"    
  737.         }
  738.         elseif ($alignmentRoll -ge 16 -and $alignmentRoll -le 17)
  739.         {
  740.             $alignmentArray = @(
  741.                 "Lawful Good",
  742.                 "Lawful Neutral"
  743.             )
  744.             $alignmentResult = Get-Random -InputObject $alignmentArray
  745.         }
  746.         elseif ($alignmentRoll -eq 18)
  747.         {
  748.             $alignmentArray = @(
  749.                 "Chaotic Good",
  750.                 "Chaotic Neutral"
  751.             )
  752.             $alignmentResult = Get-Random -InputObject $alignmentArray
  753.         }
  754.         return $alignmentResult
  755.     }
  756.     [string] causeOfDeathTable ()
  757.     {
  758.         $causeOfDeathRoll = $this.dice.d12()
  759.         $cause = $null
  760.         if ($causeOfDeathRoll -eq 1)
  761.         {
  762.             $cause = "Unknown"    
  763.         }
  764.         elseif ($causeOfDeathRoll -eq 2)
  765.         {
  766.             $cause = "Murdered"    
  767.         }
  768.         elseif ($causeOfDeathRoll -eq 3)
  769.         {
  770.             $cause = "Killed in battle"    
  771.         }
  772.         elseif ($causeOfDeathRoll -eq 4)
  773.         {
  774.             $cause = "Accident related to class or occupation"    
  775.         }
  776.         elseif ($causeOfDeathRoll -eq 5)
  777.         {
  778.             $cause = "Accident unrelated to class or occupation"    
  779.         }
  780.         elseif ($causeOfDeathRoll -ge 6 -and $causeOfDeathRoll -le 7)
  781.         {
  782.             $cause = "Natural causes, such as disease or old age"    
  783.         }
  784.         elseif ($causeOfDeathRoll -eq 8)
  785.         {
  786.             $cause = "Apparent suicide"    
  787.         }
  788.         elseif ($causeOfDeathRoll -eq 9)
  789.         {
  790.             $cause = "Torn apart by an animal or a natural disaster"    
  791.         }
  792.         elseif ($causeOfDeathRoll -eq 10)
  793.         {
  794.             $cause = "Consumed by a monster"    
  795.         }
  796.         elseif ($causeOfDeathRoll -eq 11)
  797.         {
  798.             $cause = "Executed for a crime or tortured to death"    
  799.         }
  800.         elseif ($causeOfDeathRoll -eq 12)
  801.         {
  802.             $cause = "Bizarre event, such as being hit by a meteorite, struck down by an angry god, or killed by a hatching slaad egg"    
  803.         }
  804.         return $cause
  805.     }
  806.     [string] classTable ()
  807.     {
  808.         $classRoll = $this.dice.d100()
  809.         $classResult = $null
  810.         if ($classRoll -ge 1 -and $classRoll -le 7)
  811.         {
  812.             $classResult = "Barbarian"    
  813.         }
  814.         elseif ($classRoll -ge 8 -and $classRoll -le 14)
  815.         {
  816.             $classResult = "Bard"    
  817.         }
  818.         elseif ($classRoll -ge 15 -and $classRoll -le 29)
  819.         {
  820.             $classResult = "Cleric"    
  821.         }
  822.         elseif ($classRoll -ge 30 -and $classRoll -le 36)
  823.         {
  824.             $classResult = "Druid"    
  825.         }
  826.         elseif ($classRoll -ge 37 -and $classRoll -le 52)
  827.         {
  828.             $classResult = "Fighter"    
  829.         }
  830.         elseif ($classRoll -ge 53 -and $classRoll -le 58)
  831.         {
  832.             $classResult = "Monk"    
  833.         }
  834.         elseif ($classRoll -ge 59 -and $classRoll -le 64)
  835.         {
  836.             $classResult = "Paladin"    
  837.         }
  838.         elseif ($classRoll -ge 65 -and $classRoll -le 70)
  839.         {
  840.             $classResult = "Ranger"    
  841.         }
  842.         elseif ($classRoll -ge 71 -and $classRoll -le 84)
  843.         {
  844.             $classResult = "Rogue"    
  845.         }
  846.         elseif ($classRoll -ge 85 -and $classRoll -le 89)
  847.         {
  848.             $classResult = "Sorcerer"    
  849.         }
  850.         elseif ($classRoll -ge 90 -and $classRoll -le 94)
  851.         {
  852.             $classResult = "Warlock"    
  853.         }
  854.         elseif ($classRoll -ge 95 -and $classRoll -le 100)
  855.         {
  856.             $classResult = "Wizard"    
  857.         }
  858.         return $classResult
  859.     }
  860.     [string] occupationTable ()
  861.     {
  862.         $occupationRoll = $this.dice.d100()
  863.         $occupation = $null
  864.         if ($occupationRoll -ge 1 -and $occupationRoll -le 5)
  865.         {
  866.             $occupation = "Academic"    
  867.         }
  868.         elseif ($occupationRoll -ge 6 -and $occupationRoll -le 10)
  869.         {
  870.             $occupation = $this.classTable()  
  871.         }
  872.         elseif ($occupationRoll -eq 11)
  873.         {
  874.             $occupation = "Aristocrat"    
  875.         }
  876.         elseif ($occupationRoll -ge 12 -and $occupationRoll -le 26)
  877.         {
  878.             $occupation = "Artisan or guild member"    
  879.         }
  880.         elseif ($occupationRoll -ge 27 -and $occupationRoll -le 31)
  881.         {
  882.             $occupation = "Criminal"    
  883.         }
  884.         elseif ($occupationRoll -ge 32 -and $occupationRoll -le 36)
  885.         {
  886.             $occupation = "Entertainer"    
  887.         }
  888.         elseif ($occupationRoll -ge 37 -and $occupationRoll -le 38)
  889.         {
  890.             $occupation = "Exile, hermit, or refugee"    
  891.         }
  892.         elseif ($occupationRoll -ge 39 -and $occupationRoll -le 43)
  893.         {
  894.             $occupation = "Explorer or wanderer"    
  895.         }
  896.         elseif ($occupationRoll -ge 44 -and $occupationRoll -le 55)
  897.         {
  898.             $occupation = "Farmer or herder"    
  899.         }
  900.         elseif ($occupationRoll -ge 56 -and $occupationRoll -le 60)
  901.         {
  902.             $occupation = "Hunter or trapper"    
  903.         }
  904.         elseif ($occupationRoll -ge 61 -and $occupationRoll -le 75)
  905.         {
  906.             $occupation = "Laborer"    
  907.         }
  908.         elseif ($occupationRoll -ge 76 -and $occupationRoll -le 80)
  909.         {
  910.             $occupation = "Merchant"    
  911.         }
  912.         elseif ($occupationRoll -ge 81 -and $occupationRoll -le 85)
  913.         {
  914.             $occupation = "Politician or bureaucrat"    
  915.         }
  916.         elseif ($occupationRoll -ge 86 -and $occupationRoll -le 90)
  917.         {
  918.             $occupation = "Priest"    
  919.         }
  920.         elseif ($occupationRoll -ge 91 -and $occupationRoll -le 95)
  921.         {
  922.             $occupation = "Sailor"    
  923.         }
  924.         elseif ($occupationRoll -ge 96 -and $occupationRoll -le 100)
  925.         {
  926.             $occupation = "Soldier"    
  927.         }
  928.         return $occupation
  929.     }
  930.     [string] raceTable ()
  931.     {
  932.         $raceRoll = $this.dice.d100()
  933.         $race = $null  
  934.         if ($raceRoll =ge 1 =and $raceRoll =le 40)
  935.         {
  936.             $race = "Human"    
  937.         }
  938.         elseif ($raceRoll -ge 41 -and $raceRoll -le 50)
  939.         {
  940.             $race = "Dwarf"    
  941.         }
  942.         elseif ($raceRoll =ge 51 =and $raceRoll =le 60)
  943.         {
  944.             $race = "Elf"  
  945.         }
  946.         elseif ($raceRoll =ge 61 = and $raceRoll -le 70)
  947.         {
  948.             $race = "Halfling"    
  949.         }
  950.         elseif ($raceRoll -ge 71 -and $raceRoll -le 75)
  951.         {
  952.             $race = "Dragonborn"    
  953.         }
  954.         elseif ($raceRoll -ge 76 -and $raceRoll -le 80)
  955.         {
  956.             $race = "Gnome"  
  957.         }
  958.         elseif ($raceRoll -ge 81 -and $raceRoll -le 85)
  959.         {
  960.             $race = "Half-elf"
  961.         }
  962.         elseif ($raceRoll =ge 86 -and -$raceRoll =le 90)
  963.         {
  964.             $race = "Half-orc"    
  965.         }
  966.         elseif ($raceRoll -ge 91 -and $raceRoll -le 95)
  967.         {
  968.             $race = "Tiefling"    
  969.         }
  970.         elseif ($raceRoll =ge 96 -and $raceRoll =le 100)
  971.         {
  972.             $race = "DM's choice"    
  973.         }
  974.         return $race
  975.     }
  976.     [string] relationshipTable ()
  977.     {
  978.         $relationshipRoll = $this.dice.d4x3()
  979.         $relationship = $null
  980.         if ($relationshipRoll -ge 3 -and $relationshipRoll -le 4)
  981.         {
  982.             $relationship = "Hostile"    
  983.         }
  984.         elseif ($relationshipRoll -ge 5 -and $relationshipRoll -le 10)
  985.         {
  986.             $relationship = "Friendly"    
  987.         }
  988.         elseif ($relationshipRoll -ge 11 -and $relationshipRoll -le 12)
  989.         {
  990.             $relationship = "Indifferent"    
  991.         }
  992.         return $relationship
  993.     }
  994.     [string] statusTable ()
  995.     {
  996.         $statusRoll = $this.dice.d6x3()
  997.         $status = $null
  998.         if ($statusRoll -eq 3)
  999.         {
  1000.             $death = $this.causeOfDeathTable()
  1001.             $status = "Dead. Cause of death was $death"
  1002.         }
  1003.         elseif ($statusRoll -ge 4 -and $statusRoll -le 5)
  1004.         {
  1005.             $status = "Missing or unknown"    
  1006.         }
  1007.         elseif ($statusRoll -ge 6 -and $statusRoll -le 8)
  1008.         {
  1009.             $status = "Alive, but doing poorly due to injury, financial trouble, or relationship difficulties"    
  1010.         }
  1011.         elseif ($statusRoll -ge 9 -and $statusRoll -le 12)
  1012.         {
  1013.             $status = "Alive and well"    
  1014.         }
  1015.         elseif ($statusRoll -ge 13 -and $statusRoll -le 15)
  1016.         {
  1017.             $status = "Alive and quite successful"    
  1018.         }
  1019.         elseif ($statusRoll -ge 16 -and $statusRoll -le 17)
  1020.         {
  1021.             $status = "Alive and infamous"    
  1022.         }
  1023.         elseif ($statusRoll -eq 18)
  1024.         {
  1025.             $status = "Alive and famous"    
  1026.         }
  1027.         return $status
  1028.     }
  1029. }
  1030.  
  1031. class BackgroundDecisionTables
  1032. {
  1033.     $dice
  1034.     BackgroundDecisionTables ()
  1035.     {
  1036.         $this.dice = [DiceRoll]::new()
  1037.     }
  1038.     [string] acolyte ()
  1039.     {
  1040.         $decision = $null
  1041.         $roll = $this.dice.d6()
  1042.         if ($roll -eq 1)
  1043.         {
  1044.             $decision = "I ran away from home at an early age and found refuge in a temple. "
  1045.         }
  1046.         elseif ($roll -eq 2)
  1047.         {
  1048.             $decision = "My family gave me to a temple, since they were unable or unwilling to care for me."    
  1049.         }
  1050.         elseif ($roll -eq 3)
  1051.         {
  1052.             $decision = "I grew up in a household with strong religious convictions. Entering the service of one or more gods seemed natural."    
  1053.         }
  1054.         elseif ($roll -eq 4)
  1055.         {
  1056.             $decision = "An impassioned sermon struck a chord deep in my soul and moved me to serve the faith."    
  1057.         }
  1058.         elseif ($roll -eq 5)
  1059.         {
  1060.             $decision = "I followed a childhood friend, a respected acquaintance, or someone I loved into religious service."    
  1061.         }
  1062.         elseif ($roll -eq 6)
  1063.         {
  1064.             $decision = "After encountering a true servant ofthe gods, I was so inspired that I immediately entered the service ofa religious group."    
  1065.         }
  1066.         return $decision
  1067.     }
  1068.     [string] charlatan ()
  1069.     {
  1070.         $decision = $null
  1071.         $roll = $this.dice.d6()
  1072.         if ($roll -eq 1)
  1073.         {
  1074.             $decision = "I was left to my own devices, and my knack for manipulating others helped me survive."
  1075.         }
  1076.         elseif ($roll -eq 2)
  1077.         {
  1078.             $decision = "I learned early on that people are gullible and easy to exploit."    
  1079.         }
  1080.         elseif ($roll -eq 3)
  1081.         {
  1082.             $decision = "I often got in trouble, but I managed to talk my way out of it every time."    
  1083.         }
  1084.         elseif ($roll -eq 4)
  1085.         {
  1086.             $decision = "I took up with a confidence artist, from whom I learned my craft."    
  1087.         }
  1088.         elseif ($roll -eq 5)
  1089.         {
  1090.             $decision = "After a charlatan fleeced my family, I decided to learn the trade so I would never be fooled by such deception again."    
  1091.         }
  1092.         elseif ($roll -eq 6)
  1093.         {
  1094.             $decision = "I was poor or I feared becoming poor, so I learned the tricks I needed to keep myself out of poverty."    
  1095.         }
  1096.         return $decision
  1097.     }
  1098.     [string] criminal ()
  1099.     {
  1100.         $decision = $null
  1101.         $roll = $this.dice.d6()
  1102.         if ($roll -eq 1)
  1103.         {
  1104.             $decision = "I resented authority in my younger days and saw a life of crime as the best way to fight against tyranny and oppression."
  1105.         }
  1106.         elseif ($roll -eq 2)
  1107.         {
  1108.             $decision = "Necessity forced me to take up the life, since it was the only way I could survive."    
  1109.         }
  1110.         elseif ($roll -eq 3)
  1111.         {
  1112.             $decision = "I fell in with a gang of reprobates and ne’er-do-wells, and I learned my specialty from them."    
  1113.         }
  1114.         elseif ($roll -eq 4)
  1115.         {
  1116.             $decision = "A parent or relative taught me my criminal specialty to prepare me for the family business."    
  1117.         }
  1118.         elseif ($roll -eq 5)
  1119.         {
  1120.             $decision = "I left home and found a place in a thieves’ guild or some other criminal organization."    
  1121.         }
  1122.         elseif ($roll -eq 6)
  1123.         {
  1124.             $decision = "I was always bored, so I turned to crime to pass the time and discovered I was quite good at it."    
  1125.         }
  1126.         return $decision
  1127.     }
  1128.     [string] entertainer ()
  1129.     {
  1130.         $decision = $null
  1131.         $roll = $this.dice.d6()
  1132.         if ($roll -eq 1) {
  1133.             $decision = "Members of my family made ends meet by performing, so it was fitting for me to follow their example."
  1134.         }
  1135.         elseif ($roll -eq 2)
  1136.         {
  1137.             $decision = "I always had a keen insight into other people, enough so that I could make them laugh or cry with my stories or songs."    
  1138.         }
  1139.         elseif ($roll -eq 3)
  1140.         {
  1141.             $decision = "I ran away from home to follow a minstrel troupe."    
  1142.         }
  1143.         elseif ($roll -eq 4)
  1144.         {
  1145.             $decision = "I saw a bard perform once, and I knew from that moment on what I was born to do."    
  1146.         }
  1147.         elseif ($roll -eq 5)
  1148.         {
  1149.             $decision = "I earned coin by performing on street corners and eventually made a name for myself."    
  1150.         }
  1151.         elseif ($roll -eq 6)
  1152.         {
  1153.             $decision = "A traveling entertainer took me in and taught me the trade."    
  1154.         }
  1155.         return $decision
  1156.     }
  1157.     [string] folkHero ()
  1158.     {
  1159.         $decision = $null
  1160.         $roll = $this.dice.d6()
  1161.         if ($roll -eq 1) {
  1162.             $decision = "I learned what was right and wrong from my family."
  1163.         }
  1164.         elseif ($roll -eq 2)
  1165.         {
  1166.             $decision = "I was always enamored by tales of heroes and wished I could be something more than ordinary."    
  1167.         }
  1168.         elseif ($roll -eq 3)
  1169.         {
  1170.             $decision = "I hated my mundane life, so when it was time for someone to step up and do the right thing, I took my chance."    
  1171.         }
  1172.         elseif ($roll -eq 4)
  1173.         {
  1174.             $decision = "A parent or one of my relatives was an adventurer, and I was inspired by that person’s courage."    
  1175.         }
  1176.         elseif ($roll -eq 5)
  1177.         {
  1178.             $decision = "A mad old hermit spoke a prophecy when I was born, saying that I would accomplish great things."    
  1179.         }
  1180.         elseif ($roll -eq 6)
  1181.         {
  1182.             $decision = "I have always stood up for those who are weaker than I am."    
  1183.         }
  1184.         return $decision
  1185.     }
  1186.     [string] guildArtisan ()
  1187.     {
  1188.         $decision = $null
  1189.         $roll = $this.dice.d6()
  1190.         if ($roll -eq 1) {
  1191.             $decision = "I was apprenticed to a master who taught me the guild’s business."
  1192.         }
  1193.         elseif ($roll -eq 2)
  1194.         {
  1195.             $decision = "I helped a guild artisan keep a secret or complete a task, and in return I was taken on as an apprentice."    
  1196.         }
  1197.         elseif ($roll -eq 3)
  1198.         {
  1199.             $decision = "One of my family members who belonged to the guild made a place for me."    
  1200.         }
  1201.         elseif ($roll -eq 4)
  1202.         {
  1203.             $decision = "I was always good with my hands, so I took the opportunity to learn a trade."    
  1204.         }
  1205.         elseif ($roll -eq 5)
  1206.         {
  1207.             $decision = "I wanted to get away from my home situation and start a new life."    
  1208.         }
  1209.         elseif ($roll -eq 6)
  1210.         {
  1211.             $decision = "I learned the essentials of my craft from a mentor but had to join the guild to finish my training."    
  1212.         }
  1213.         return $decision
  1214.     }
  1215.     [string] hermit ()
  1216.     {
  1217.         $decision = $null
  1218.         $roll = $this.dice.d6()
  1219.         if ($roll -eq 1)
  1220.         {
  1221.             $decision = "My enemies ruined my reputation, and I fled to the wilds to avoid further disparagement."
  1222.         }
  1223.         elseif ($roll -eq 2)
  1224.         {
  1225.             $decision = "I am comfortable with being isolated, as I seek inner peace."    
  1226.         }
  1227.         elseif ($roll -eq 3)
  1228.         {
  1229.             $decision = "I never liked the people I called my friends, so it was easy for me to strike out on my own."    
  1230.         }
  1231.         elseif ($roll -eq 4)
  1232.         {
  1233.             $decision = "I felt compelled to forsake my past, but did so with great reluctance, and sometimes I regret making that decision."
  1234.         }
  1235.         elseif ($roll -eq 5)
  1236.         {
  1237.             $decision = "I lost everything - my home, my family, my friends. Going it alone was all I could do."    
  1238.         }
  1239.         elseif ($roll -eq 6)
  1240.         {
  1241.             $decision = "Society's decadence disgusted me, so I decided to leave it behind."    
  1242.         }
  1243.         return $decision
  1244.     }
  1245.     [string] noble ()
  1246.     {
  1247.         $decision = $null
  1248.         $roll = $this.dice.d6()
  1249.         if ($roll -eq 1) {
  1250.             $decision = "I come from an old and storied family, and it fell to me to preserve the family name."
  1251.         }
  1252.         elseif ($roll -eq 2)
  1253.         {
  1254.             $decision = "My family has been disgraced, and I intend to clear our name."    
  1255.         }
  1256.         elseif ($roll -eq 3)
  1257.         {
  1258.             $decision = "My family recently came by its title, and that elevation thrust us into a new and strange world."    
  1259.         }
  1260.         elseif ($roll -eq 4)
  1261.         {
  1262.             $decision = "My family has a title, but none of my ancestors have distinguished themselves since we gained it."    
  1263.         }
  1264.         elseif ($roll -eq 5)
  1265.         {
  1266.             $decision = "My family is filled with remarkable people. I hope to live up to their example."    
  1267.         }
  1268.         elseif ($roll -eq 6)
  1269.         {
  1270.             $decision = "I hope to increase my family’s power and influence."    
  1271.         }
  1272.         return $decision
  1273.     }
  1274.     [string] outlander ()
  1275.     {
  1276.         $decision = $null
  1277.         $roll = $this.dice.d6()
  1278.         if ($roll -eq 1) {
  1279.             $decision = "I spent a lot oftime in the wilderness as a youngster, and I came to love that way of life."
  1280.         }
  1281.         elseif ($roll -eq 2)
  1282.         {
  1283.             $decision = "From a young age, I couldn't abide the stink ofthe cities and preferred to spend my time in nature."    
  1284.         }
  1285.         elseif ($roll -eq 3)
  1286.         {
  1287.             $decision = "I came to understand the darkness that lurks in the wilds, and l vowed to combat it."    
  1288.         }
  1289.         elseif ($roll -eq 4)
  1290.         {
  1291.             $decision = "My people lived on the edges ofcivilization, and I learned the methods ofsurvival from my family."    
  1292.         }
  1293.         elseif ($roll -eq 5)
  1294.         {
  1295.             $decision = "After a tragedy l retreated to the wilderness, leaving my old life behind."    
  1296.         }
  1297.         elseif ($roll -eq 6)
  1298.         {
  1299.             $decision = "My family moved away from civilization, and I learned to adapt to my new environment."    
  1300.         }
  1301.         return $decision
  1302.     }
  1303.     [string] sage ()
  1304.     {
  1305.         $decision = $null
  1306.         $roll = $this.dice.d6()
  1307.         if ($roll -eq 1) {
  1308.             $decision = "I was naturally curious, so I packed up and went to a university to learn more about the world."
  1309.         }
  1310.         elseif ($roll -eq 2)
  1311.         {
  1312.             $decision = "My mentor’s teachings opened my mind to new possibilities in that field of study."    
  1313.         }
  1314.         elseif ($roll -eq 3)
  1315.         {
  1316.             $decision = "I was always an avid reader, and I learned much I about my favorite topic on my own."    
  1317.         }
  1318.         elseif ($roll -eq 4)
  1319.         {
  1320.             $decision = "I discovered an old library and pored over the texts I found there. That experience awakened a hunger I for more knowledge."    
  1321.         }
  1322.         elseif ($roll -eq 5)
  1323.         {
  1324.             $decision = "I impressed a wizard who told me I was squandering my talents and should seek out an education to take advantage of my gifts."    
  1325.         }
  1326.         elseif ($roll -eq 6)
  1327.         {
  1328.             $decision = "One of my parents or a relative gave me a basic education that whetted my appetite, and I left home to build on what I had learned."    
  1329.         }
  1330.         return $decision
  1331.     }
  1332.     [string] sailor ()
  1333.     {
  1334.         $decision = $null
  1335.         $roll = $this.dice.d6()
  1336.         if ($roll -eq 1) {
  1337.             $decision = "I was press-ganged by pirates and forced to serve on their ship until I finally escaped."
  1338.         }
  1339.         elseif ($roll -eq 2)
  1340.         {
  1341.             $decision = "I wanted to see the world, so I signed on as a deck-hand for a merchant ship."    
  1342.         }
  1343.         elseif ($roll -eq 3)
  1344.         {
  1345.             $decision = "One of my relatives was a sailor who took me to sea."    
  1346.         }
  1347.         elseif ($roll -eq 4)
  1348.         {
  1349.             $decision = "I needed to escape my community quickly, so I stowed away on a ship. When the crew found me, I was forced to work for my passage."    
  1350.         }
  1351.         elseif ($roll -eq 5)
  1352.         {
  1353.             $decision = "Reavers attacked my community, so I found refuge on a ship until I could seek vengeance."    
  1354.         }
  1355.         elseif ($roll -eq 6)
  1356.         {
  1357.             $decision = "I had few prospects where I was living, so I left to find my fortune elsewhere."    
  1358.         }
  1359.         return $decision
  1360.     }
  1361.     [string] soldier ()
  1362.     {
  1363.         $decision = $null
  1364.         $roll = $this.dice.d6()
  1365.         if ($roll -eq 1) {
  1366.             $decision = "I joined the militia to help protect my community from monsters."
  1367.         }
  1368.         elseif ($roll -eq 2)
  1369.         {
  1370.             $decision = "A relative of mine was a soldier, and I wanted to I carry on the family tradition."    
  1371.         }
  1372.         elseif ($roll -eq 3)
  1373.         {
  1374.             $decision = "The local lord forced me to enlist in the army."    
  1375.         }
  1376.         elseif ($roll -eq 4)
  1377.         {
  1378.             $decision = "War ravaged my homeland while I was growing up. Fighting was the only life I ever knew."    
  1379.         }
  1380.         elseif ($roll -eq 5)
  1381.         {
  1382.             $decision = "I wanted fame and fortune, so i joined a mercenary company, selling my sword to the highest bidder."    
  1383.         }
  1384.         elseif ($roll -eq 6)
  1385.         {
  1386.             $decision = "invaders attacked my homeland. It was my duty to take up arms in defense of my people."    
  1387.         }
  1388.         return $decision
  1389.     }
  1390.     [string] urchin ()
  1391.     {
  1392.         $decision = $null
  1393.         $roll = $this.dice.d6()
  1394.         if ($roll -eq 1) {
  1395.             $decision = "Wanderlust caused me to leave my family to see the world. I look after myself."
  1396.         }
  1397.         elseif ($roll -eq 2)
  1398.         {
  1399.             $decision = "I ran away from a bad situation at home and made I my own way in the world."    
  1400.         }
  1401.         elseif ($roll -eq 3)
  1402.         {
  1403.             $decision = "Monsters wiped out my village, and I was the sole survivor. I had to find a way to survive."    
  1404.         }
  1405.         elseif ($roll -eq 4)
  1406.         {
  1407.             $decision = "A notorious thief looked after me and other orphans, and we spied and stole to earn our keep."    
  1408.         }
  1409.         elseif ($roll -eq 5)
  1410.         {
  1411.             $decision = "One day I woke up on the streets, alone and hungry, with no memory of my early childhood."    
  1412.         }
  1413.         elseif ($roll -eq 6)
  1414.         {
  1415.             $decision = "My parents died, leaving no one to look after me. I raised myself."    
  1416.         }
  1417.         return $decision
  1418.     }
  1419.  
  1420. }
  1421.  
  1422. class ClassTrainingDecisionTables
  1423. {
  1424.     $dice
  1425.     ClassTrainingDecisionTables ()
  1426.     {
  1427.         $this.dice = [DiceRoll]::new()
  1428.     }
  1429.     [string] barbarian ()
  1430.     {
  1431.         $decision = $null
  1432.         $roll = $this.dice.d6()
  1433.         if ($roll -eq 1)
  1434.         {
  1435.             $decision = "My devotion to my people lifted me in battle, making me powerful and dangerous."
  1436.         }
  1437.         elseif ($roll -eq 2)
  1438.         {
  1439.             $decision = "The spirits of my ancestors called on me to carry out a great task."    
  1440.         }
  1441.         elseif ($roll -eq 3)
  1442.         {
  1443.             $decision = "I lost control in battle one day, and it was as if something else was manipulating my body, forcing it to kill every foe I could reach."    
  1444.         }
  1445.         elseif ($roll -eq 4)
  1446.         {
  1447.             $decision = "I went on a spiritual journey to find myself and instead found a spirit animal to guide, protect, and inspire me."    
  1448.         }
  1449.         elseif ($roll -eq 5)
  1450.         {
  1451.             $decision = "I was struck by lightning and lived. Afterward, I found a new strength within me that let me push beyond my limitations."    
  1452.         }
  1453.         elseif ($roll -eq 6)
  1454.         {
  1455.             $decision = "My anger needed to be channeled into battle, or I risked becoming an indiscriminate killer."    
  1456.         }
  1457.         return $decision
  1458.     }
  1459.     [string] bard ()
  1460.     {
  1461.         $decision = $null
  1462.         $roll = $this.dice.d6()
  1463.         if ($roll -eq 1) {
  1464.             $decision = "I awakened my latent bardic abilities through trial and error."
  1465.         }
  1466.         elseif ($roll -eq 2)
  1467.         {
  1468.             $decision = "I was a gifted performer and attracted the attention of a master bard who schooled me in the old techniques."    
  1469.         }
  1470.         elseif ($roll -eq 3)
  1471.         {
  1472.             $decision = "I joined a loose society of scholars and orators to learn new techniques of performance and magic."    
  1473.         }
  1474.         elseif ($roll -eq 4)
  1475.         {
  1476.             $decision = "I felt a calling to recount the deeds of champions and heroes, to bring them alive in song and story."    
  1477.         }
  1478.         elseif ($roll -eq 5)
  1479.         {
  1480.             $decision = "I joined one of the great colleges to learn old lore, the secrets of magic, and the art of performance."    
  1481.         }
  1482.         elseif ($roll -eq 6)
  1483.         {
  1484.             $decision = "I picked up a musical instrument one day and instantly discovered that I could play it."    
  1485.         }
  1486.         return $decision
  1487.     }
  1488.     [string] cleric ()
  1489.     {
  1490.         $decision = $null
  1491.         $roll = $this.dice.d6()
  1492.         if ($roll -eq 1) {
  1493.             $decision = "A supernatural being in service to the gods called me to become a divine agent in the world."
  1494.         }
  1495.         elseif ($roll -eq 2)
  1496.         {
  1497.             $decision = "I saw the injustice and horror in the world and felt moved to take a stand against them."    
  1498.         }
  1499.         elseif ($roll -eq 3)
  1500.         {
  1501.             $decision = "My god gave me an unmistakable sign. I dropped everything to serve the divine."    
  1502.         }
  1503.         elseif ($roll -eq 4)
  1504.         {
  1505.             $decision = "Although I was always devout, it wasn't until I completed a pilgrimage that I knew my true calling."    
  1506.         }
  1507.         elseif ($roll -eq 5)
  1508.         {
  1509.             $decision = "I used to serve in my religion's bureaucracy but found I needed to work in the world, to bring the message of my faith to the darkest corners of the land."    
  1510.         }
  1511.         elseif ($roll -eq 6)
  1512.         {
  1513.             $decision = "I realize that my god works through me, and I do as commanded, even though I don’t know why I was chosen to serve."    
  1514.         }
  1515.         return $decision
  1516.     }
  1517.     [string] druid ()
  1518.     {
  1519.         $decision = $null
  1520.         $roll = $this.dice.d6()
  1521.         if ($roll -eq 1) {
  1522.             $decision = "I saw too much devastation in the wild places, too much of nature’s splendor ruined by the despoilers. I joined a circle of druids to fight back against the enemies of nature."
  1523.         }
  1524.         elseif ($roll -eq 2)
  1525.         {
  1526.             $decision = "I found a place among a group of druids after I fled a catastrophe."    
  1527.         }
  1528.         elseif ($roll -eq 3)
  1529.         {
  1530.             $decision = "I have always had an affinity for animals, so I explored my talent to see how I could best use it."    
  1531.         }
  1532.         elseif ($roll -eq 4)
  1533.         {
  1534.             $decision = "I befriended a druid and was moved by druidic teachings. I decided to follow my friend’s guidance and give something back to the world."    
  1535.         }
  1536.         elseif ($roll -eq 5)
  1537.         {
  1538.             $decision = "while I was growing up, I saw spirits all around me - entities no one else could perceive. I sought out the druids to help me understand the visions and communicate with these beings."    
  1539.         }
  1540.         elseif ($roll -eq 6)
  1541.         {
  1542.             $decision = "I have always felt disgust for creatures of unnatural origin. For this reason, I immersed myself in the study of the druidic mysteries and became a champion of the natural order."    
  1543.         }
  1544.         return $decision
  1545.     }
  1546.     [string] fighter ()
  1547.     {
  1548.         $decision = $null
  1549.         $roll = $this.dice.d6()
  1550.         if ($roll -eq 1) {
  1551.             $decision = "I wanted to hone my combat skills, and so I joined a war college."
  1552.         }
  1553.         elseif ($roll -eq 2)
  1554.         {
  1555.             $decision = "I squired for a knight who taught me how to fight, care for a steed, and conduct myselfwith honor. I decided to take up that path for myself."    
  1556.         }
  1557.         elseif ($roll -eq 3)
  1558.         {
  1559.             $decision = "Horrible monsters descended on my community, killing someone I loved. I took up arms to destroy those creatures and others ofa similar nature."    
  1560.         }
  1561.         elseif ($roll -eq 4)
  1562.         {
  1563.             $decision = "I joined the army and learned how to fight as part of a group."    
  1564.         }
  1565.         elseif ($roll -eq 5)
  1566.         {
  1567.             $decision = "I grew up fighting, and I refined my talents by defending myself against people who crossed me."    
  1568.         }
  1569.         elseif ($roll -eq 6)
  1570.         {
  1571.             $decision = "I could always pick up just about any weapon and know how to use it effectively."    
  1572.         }
  1573.         return $decision
  1574.     }
  1575.     [string] monk ()
  1576.     {      
  1577.         $decision = $null
  1578.         $roll = $this.dice.d6()
  1579.         if ($roll -eq 1) {
  1580.             $decision = "I was chosen to study at a secluded monastery. There, I was taught the fundamental techniques required to eventually master a tradition."
  1581.         }
  1582.         elseif ($roll -eq 2)
  1583.         {
  1584.             $decision = "I sought instruction to gain a deeper understanding of existence and my place in the world."    
  1585.         }
  1586.         elseif ($roll -eq 3)
  1587.         {
  1588.             $decision = "I stumbled into a portal to the Shadowfell and took refuge in a strange monastery, where I learned how to defend myself against the forces of darkness."    
  1589.         }
  1590.         elseif ($roll -eq 4)
  1591.         {
  1592.             $decision = "I was overwhelmed with grief after losing someone close to me, and I sought the advice of philosophers to help me cope with my loss."    
  1593.         }
  1594.         elseif ($roll -eq 5)
  1595.         {
  1596.             $decision = "I could feel that a special sort of power lay within me, so I sought out those who could help me call it forth and master it."    
  1597.         }
  1598.         elseif ($roll -eq 6)
  1599.         {
  1600.             $decision = "I was wild and undisciplined as a youngster, but then I realized the error of my ways. I applied to a monastery and became a monk as a way to live a life of discipline."    
  1601.         }
  1602.         return $decision
  1603.     }
  1604.     [string] paladin ()
  1605.     {
  1606.         $decision = $null
  1607.         $roll = $this.dice.d6()
  1608.         if ($roll -eq 1) {
  1609.             $decision = "A fantastical being appeared before me and called on me to undertake a holy quest."
  1610.         }
  1611.         elseif ($roll -eq 2)
  1612.         {
  1613.             $decision = "One of my ancestors left a holy quest unfulfilled, so I intend to finish that work."    
  1614.         }
  1615.         elseif ($roll -eq 3)
  1616.         {
  1617.             $decision = "The world is a dark and terrible place. I decided to serve as a beacon of light shining out against the gathering shadows."    
  1618.         }
  1619.         elseif ($roll -eq 4)
  1620.         {
  1621.             $decision = "I served as a paladin’s squire, learning all I needed to swear my own sacred oath."    
  1622.         }
  1623.         elseif ($roll -eq 5)
  1624.         {
  1625.             $decision = "Evil must be opposed on all fronts. I feel compelled to seek out wickedness and purge it from the world."    
  1626.         }
  1627.         elseif ($roll -eq 6)
  1628.         {
  1629.             $decision = "Becoming a paladin was a natural consequence of my unwavering faith. In taking my vows, I became the holy sword of my religion."    
  1630.         }
  1631.         return $decision
  1632.     }
  1633.     [string] ranger ()
  1634.     {
  1635.         $decision = $null
  1636.         $roll = $this.dice.d6()
  1637.         if ($roll -eq 1) {
  1638.             $decision = "I found purpose while I honed my hunting skills by bringing down dangerous animals at the edge of civilization."
  1639.         }
  1640.         elseif ($roll -eq 2)
  1641.         {
  1642.             $decision =  "I always had a way with animals, able to calm them with a soothing word and a touch."    
  1643.         }
  1644.         elseif ($roll -eq 3)
  1645.         {
  1646.             $decision = "I suffer from terrible wanderlust, so being a ranger gave me a reason not to remain in one place for too long."    
  1647.         }
  1648.         elseif ($roll -eq 4)
  1649.         {
  1650.             $decision = "I have seen what happens when the monsters come out from the dark. I took it upon myself to become the first line of defense against the evils that lie beyond civilization's borders."    
  1651.         }
  1652.         elseif ($roll -eq 5)
  1653.         {
  1654.             $decision = "I met a grizzled ranger who taught me woodcraft and the secrets of the wild lands."    
  1655.         }
  1656.         elseif ($roll -eq 6)
  1657.         {
  1658.             $decision = "I served in an army, learning the precepts of my profession while blazing trails and scouting enemy encampments."    
  1659.         }
  1660.         return $decision
  1661.     }
  1662.     [string] rogue ()
  1663.     {
  1664.         $decision = $null
  1665.         $roll = $this.dice.d6()
  1666.         if ($roll -eq 1) {
  1667.             $decision = "I've always been nimble and quick ofwit, so I decided to use those talents to help me make my way in the world."
  1668.         }
  1669.         elseif ($roll -eq 2)
  1670.         {
  1671.             $decision = "An assassin or a thief wronged me, so I focused my training on mastering the skills of my enemy to better combat foes of that sort."    
  1672.         }
  1673.         elseif ($roll -eq 3)
  1674.         {
  1675.             $decision = "An experienced rogue saw something in me and taught me several useful tricks."
  1676.         }
  1677.         elseif ($roll -eq 4)
  1678.         {
  1679.             $decision = "I decided to turn my natural lucky streak into the basis of a career, though I still realize that improving my skills is essential."    
  1680.         }
  1681.         elseif ($roll -eq 5)
  1682.         {
  1683.             $decision = "I took up with a group of ruffians who showed me how to get what I want through sneakiness rather than direct confrontation."    
  1684.         }
  1685.         elseif ($roll -eq 6)
  1686.         {
  1687.             $decision = "I’m a sucker for a shiny bauble or a sack of coins, as long as I can get my hands on it without risking life and limb."    
  1688.         }
  1689.         return $decision
  1690.     }
  1691.     [string] sorcerer ()
  1692.     {
  1693.         $decision = $null
  1694.         $roll = $this.dice.d6()
  1695.         if ($roll -eq 1) {
  1696.             $decision = "when I was born, all the water in the house froze solid. the milk spoiled, or all the iron turned to copper. My family is convinced that this event was a harbinger of stranger things to come for me."
  1697.         }
  1698.         elseif ($roll -eq 2)
  1699.         {
  1700.             $decision = "I suffered a terrible emotional or physical strain, which brought forth my latent magical power. l have fought to control it ever since."    
  1701.         }
  1702.         elseif ($roll -eq 3)
  1703.         {
  1704.             $decision = "My immediate family never spoke of my ancestors, and when I asked, they would change the subject. It wasn't until I started displaying strange talents that the full truth of my heritage came out."    
  1705.         }
  1706.         elseif ($roll -eq 4)
  1707.         {
  1708.             $decision = "When a monster threatened one of my friends, I became filled with anxiety. I lashed out instinctively and blasted the wretched thing with a force that came from within me."    
  1709.         }
  1710.         elseif ($roll -eq 5)
  1711.         {
  1712.             $decision = "Sensing something special in me, a stranger taught me how to control my gift."    
  1713.         }
  1714.         elseif ($roll -eq 6)
  1715.         {
  1716.             $decision = "After I escaped from a magical conflagration, I realized that though I was unharmed, I was not unchanged. I began to exhibit unusual abilities that I am just beginning to understand."    
  1717.         }
  1718.         return $decision
  1719.     }
  1720.     [string] warlock ()
  1721.     {
  1722.         $decision = $null
  1723.         $roll = $this.dice.d6()
  1724.         if ($roll -eq 1) {
  1725.             $decision = "While wandering around in a forbidden place, I encountered an otherworldly being that offered to enter into a pact with me."
  1726.         }
  1727.         elseif ($roll -eq 2)
  1728.         {
  1729.             $decision = "I was examining a strange tome I found in an abandoned library when the entity that would become my patron suddenly appeared before me."    
  1730.         }
  1731.         elseif ($roll -eq 3)
  1732.         {
  1733.             $decision = "I stumbled into the clutches of my patron after I accidentally stepped through a magical doorway."    
  1734.         }
  1735.         elseif ($roll -eq 4)
  1736.         {
  1737.             $decision = "When I was faced with a terrible crisis, I prayed to any being who would listen, and the creature that answered became my patron."    
  1738.         }
  1739.         elseif ($roll -eq 5)
  1740.         {
  1741.             $decision = "My future patron visited me in my dreams and offered great power in exchange for my service."    
  1742.         }
  1743.         elseif ($roll -eq 6)
  1744.         {
  1745.             $decision = "One of my ancestors had a pact with my patron, so that entity was determined to bind me to the same agreement."    
  1746.         }
  1747.         return $decision
  1748.     }
  1749.     [string] wizard ()
  1750.     {
  1751.         $decision = $null
  1752.         $roll = $this.dice.d6()
  1753.         if ($roll -eq 1) {
  1754.             $decision = "An old wizard chose me from among several candidates to serve an apprenticeship."
  1755.         }
  1756.         elseif ($roll -eq 2)
  1757.         {
  1758.             $decision = "When I became lost in a forest, a hedge wizard found me, took me in, and taught me the rudiments of magic."    
  1759.         }
  1760.         elseif ($roll -eq 3)
  1761.         {
  1762.             $decision = "I grew up listening to tales of great wizards and knew I wanted to follow their path. I strove to be accepted at an academy of magic and succeeded."    
  1763.         }
  1764.         elseif ($roll -eq 4)
  1765.         {
  1766.             $decision = "One of my relatives was an accomplished wizard who decided I was smart enough to learn the craft."    
  1767.         }
  1768.         elseif ($roll -eq 5)
  1769.         {
  1770.             $decision = "While exploring an old tomb, library, or temple, I found a spellbook. I was immediately driven to learn all I could about becoming a wizard."    
  1771.         }
  1772.         elseif ($roll -eq 6)
  1773.         {
  1774.             $decision = "I was a prodigy who demonstrated mastery of the arcane arts at an early age. When I became old enough to set out on my own, I did so to learn more magic and expand my power."    
  1775.         }
  1776.         return $decision
  1777.     }    
  1778. }
  1779.  
  1780. class LifeEventsTable
  1781. {
  1782.     $age
  1783.     $totalEvents
  1784.     $secondaryTable
  1785.     $dice
  1786.     LifeEventsTable ()
  1787.     {
  1788.         $this.secondaryTable = [SecondaryTables]::new()
  1789.         $this.dice = [DiceRoll]::new()
  1790.         $roll = $this.dice.d100()
  1791.         if ($roll -ge 1 -and $roll -le 20)
  1792.         {
  1793.             $this.totalEvents = 1
  1794.             $this.age = Get-Random -Minimum 15 -Maximum 20
  1795.         }
  1796.         elseif ($roll -ge 21 -and $roll -le 59)
  1797.         {
  1798.             $this.totalEvents = $this.dice.d4()
  1799.             $this.age = Get-Random -Minimum 21 -Maximum 30    
  1800.         }
  1801.         elseif ($roll -ge 60 -and $roll -le 69 )
  1802.         {
  1803.             $this.totalEvents = $this.dice.d6()
  1804.             $this.age = Get-Random -Minimum 31 -Maximum 40
  1805.         }
  1806.         elseif ($roll -ge 70 -and $roll -le 89)
  1807.         {
  1808.             $this.totalEvents = $this.dice.d8()
  1809.             $this.age = Get-Random -Minimum 41 -Maximum 50
  1810.         }
  1811.         elseif ($roll -ge 90 -and $roll -le 99)
  1812.         {
  1813.             $this.totalEvents = $this.dice.d10()
  1814.             $this.age = Get-Random -Minimum 51 -Maximum 60    
  1815.         }
  1816.         elseif ($roll -eq 100)
  1817.         {
  1818.             $this.totalEvents = $this.dice.d12()
  1819.             $this.age = Get-Random -Minimum 61 -Maximum 100    
  1820.         }
  1821.     }
  1822.     [string] event ()
  1823.     {
  1824.         $events = $null
  1825.         $roll = $this.dice.d100()
  1826.  
  1827.         if ($roll -ge 1 -and $roll -le 10)
  1828.         {
  1829.             $events = $this.secondaryTable.tragedies()  
  1830.         }
  1831.         elseif ($roll -ge 11 -and $roll -le 20)
  1832.         {
  1833.             $events = $this.secondaryTable.boons()  
  1834.         }
  1835.         elseif ($roll -ge 21 -and $roll -le 30)
  1836.         {
  1837.             $events = "You fell in love or got married. If you get this result more than once, you can choose to have a child instead. Work with your DM to determine the identity of your love interest."    
  1838.         }
  1839.         elseif ($roll -ge 31 -and $roll -le 40)
  1840.         {
  1841.             $fault = $this.dice.d6()
  1842.             if ($fault -eq 1 -or $fault -eq 3 -or $fault -eq 5)
  1843.             {
  1844.                 $events = "You made an enemy of an adventurer. You are at fault for this rift. Use the supplemental tables and work with your DM to determine this hostile character's identity and the danger this enemy poses to you."    
  1845.             }
  1846.             elseif ($fault -eq 2 -or $fault -eq 4 -or $fault -eq 6)
  1847.             {
  1848.                 $events = "You made an enemy of an adventurer. You are blameless for this rift. Use the supplemental tables and work with your DM to determine this hostile character's identity and the danger this enemy poses to you."    
  1849.             }
  1850.         }
  1851.         elseif ($roll -ge 41 -and $roll -le 50)
  1852.         {
  1853.             $events = "You made a friend of an adventurer. Use the supplemental tables and work with your DM to add more detail to this friendly character and establish how your friendship began."    
  1854.         }
  1855.         elseif ($roll -ge 51 -and $roll -le 70)
  1856.         {
  1857.             $gold = $this.dice.d6x2()
  1858.             $events = "You Spent time working in a job related to your background. Start the game with an extra $gold gp."    
  1859.         }
  1860.         elseif ($roll -ge 71 -and $roll -le 75)
  1861.         {
  1862.             $events = "You met someone important. Use the supplemental tables to determine this character's identity and how this individual feels about you. Work out additional details with your DM as needed to fit this character into your backstory."    
  1863.         }
  1864.         elseif ($roll -ge 76 -and $roll -le 80)
  1865.         {
  1866.             $events = $this.secondaryTable.adventures()  
  1867.         }
  1868.         elseif ($roll -ge 81 -and $roll -le 85)
  1869.         {
  1870.             $events = $this.secondaryTable.supernaturalEvents()
  1871.         }
  1872.         elseif ($roll -ge 86 -and $roll -le 90)
  1873.         {
  1874.             $events = $this.secondaryTable.war()    
  1875.         }
  1876.         elseif ($roll -ge 91 -and $roll -le 95)
  1877.         {
  1878.             $events = ("You commited a crime. That crime was", $this.secondaryTable.crime()) -join " "
  1879.         }
  1880.         elseif ($roll -ge 96 -and $roll -le 99)
  1881.         {
  1882.             $events = $this.secondaryTable.arcaneMatters()  
  1883.         }
  1884.         elseif ($roll -eq 100)
  1885.         {
  1886.             $events = $this.secondaryTable.weirdStuff()  
  1887.         }
  1888.         return $events
  1889.     }
  1890. }
  1891.  
  1892. class SecondaryTables
  1893. {
  1894.     $supplementalTable
  1895.     $dice
  1896.     SecondaryTables ()
  1897.     {
  1898.         $this.dice = [DiceRoll]::new()
  1899.         $this.supplementalTable = [SupplementalTables]::new()
  1900.     }
  1901.     [string] adventures ()
  1902.     {
  1903.         $adventureRoll = $this.dice.d100()
  1904.         $adventure = $null
  1905.         if ($adventureRoll -ge 1 -and $adventureRoll -le 10)
  1906.         {
  1907.             $fingers = $this.dice.d3()
  1908.             $toes = $this.dice.d4()
  1909.             $adventure = "You nearly died. You have nasty scars on your body, and you are missing an ear, $fingers fingers, or $toes toes."    
  1910.         }
  1911.         elseif ($adventureRoll -ge 11 -and $adventureRoll -le 20)
  1912.         {
  1913.             $adventure = "You suffered a grievous injury. Although the wound healed, it still pains you from time to time."
  1914.         }
  1915.         elseif ($adventureRoll -ge 21 -and $adventureRoll -le 30)
  1916.         {
  1917.             $adventure = "You were wounded, but in time you fully recovered."
  1918.         }
  1919.         elseif ($adventureRoll -ge 31 -and $adventureRoll -le 40)
  1920.         {
  1921.             $adventure = "You contracted a disease while exploring a filthy warren. You recovered from the disease, but you have a persistent cough, pockmarks on your skin, or prematurely gray hair."
  1922.         }
  1923.         elseif ($adventureRoll -ge 41 -and $adventureRoll -le 50)
  1924.         {
  1925.             $adventure = "You were poisoned by a trap or a monster. You recovered, but the next time you must make a savin throw against poison, you make the saving throw with disadvantage."
  1926.         }
  1927.         elseif ($adventureRoll -ge 51 -and $adventureRoll -le 60)
  1928.         {
  1929.             $adventure = "You lost something of sentimental value to you during your adventure. Remove one trinket from your possessions."
  1930.         }
  1931.         elseif ($adventureRoll -ge 61 -and $adventureRoll -le 70)
  1932.         {
  1933.             $adventure = "You were terribly frightened by something you encountered and ran away, abandoning your companions to their fate."
  1934.         }
  1935.         elseif ($adventureRoll -ge 71 -and $adventureRoll -le 80)
  1936.         {
  1937.             $adventure = "You learned a great deal during your adventure. The next time you make an ability check or a saving throw, you have advantage on the roll."
  1938.         }
  1939.         elseif ($adventureRoll -ge 81 -and $adventureRoll -le 90)
  1940.         {
  1941.             $gold = $this.dice.d6x2()
  1942.             $adventure = "You found some treasure on your adventure. You have $gold gp left from your share of it."
  1943.         }
  1944.         elseif ($adventureRoll -ge 91 -and $adventureRoll -le 99)
  1945.         {
  1946.             $gold = $this.dice.d20()
  1947.             $treasure = $gold + 50
  1948.             $adventure = "You found a considerable amount of treasure on your adventure. You have $treasure gp left from your share of it."
  1949.         }
  1950.         elseif ($adventureRoll -eq 100)
  1951.         {
  1952.             $adventure = "You came across a common magic item (of the DM’s choice)."
  1953.         }
  1954.         return $adventure
  1955.     }
  1956.     [string] arcaneMatters ()
  1957.     {
  1958.         $arcaneMattersRoll = $this.dice.d10()
  1959.         $magicalEvent = $null
  1960.         if ($arcaneMattersRoll -eq 1)
  1961.         {
  1962.             $magicalEvent = "You were charmed or frightened by a spell."
  1963.            
  1964.         }
  1965.         elseif ($arcaneMattersRoll -eq 2 )
  1966.         {
  1967.             $magicalEvent = "You were injured by the effect of a spell."
  1968.         }
  1969.         elseif ($arcaneMattersRoll -eq 3)
  1970.         {
  1971.            
  1972.             $casterList = @(
  1973.                 "a cleric",
  1974.                 "a druid",
  1975.                 "a sorcerer",
  1976.                 "a warlock",
  1977.                 "a wizard."
  1978.             )
  1979.             $caster = Get-Random -InputObject $casterList
  1980.             $magicalEvent = "You witnessed a powerful spell being cast by a $caster  "
  1981.         }
  1982.         elseif ($arcaneMattersRoll -eq 4 )
  1983.         {
  1984.             $magicalEvent = "You drank a potion (of the DM's choice)."
  1985.         }
  1986.         elseif ($arcaneMattersRoll -eq 5 )
  1987.         {
  1988.             $magicalEvent = "You found a spell scroll (of the DM's choice) and succeeded in casting the Spell it contained."
  1989.         }
  1990.         elseif ($arcaneMattersRoll -eq 6)
  1991.         {
  1992.             $magicalEvent = "You were affected by teleportation magic."
  1993.         }
  1994.         elseif ($arcaneMattersRoll -eq 7)
  1995.         {
  1996.             $magicalEvent = "You turned invisible for a time."
  1997.         }
  1998.         elseif ($arcaneMattersRoll -eq 8)
  1999.         {
  2000.             $magicalEvent = "You identified an illusion for what it was."
  2001.         }
  2002.         elseif ($arcaneMattersRoll -eq 9)
  2003.         {
  2004.             $magicalEvent = "You saw a creature being conjured by magic."
  2005.         }
  2006.         elseif ($arcaneMattersRoll -eq 10)
  2007.         {
  2008.             $magicalEvent = "Your fortune was read by a diviner. Roll twice on the Life Events table, but don’t apply the results. Instead, the DM picks one event as a portent of your future (which might or might not come true)."
  2009.         }
  2010.         return $magicalEvent
  2011.     }
  2012.     [string] boons ()
  2013.     {
  2014.         $boonsRoll = $this.dice.d10()
  2015.         $boon = $null
  2016.         if ($boonsRoll -eq 1)
  2017.         {
  2018.             $boon = "A friendly wizard gave you a spell scroll containing one cantrip (ofthe DM's choice)."
  2019.         }
  2020.         elseif ($boonsRoll -eq 2)
  2021.         {
  2022.             $boon = "You saved the life ofa commoner, who now owes you a life debt. This individual accompanies you on your travels and performs mundane tasks for you, but will leave if neglected, abused, or imperiled. Determine details about this character by using the supplemental tables and working with your DM."
  2023.         }
  2024.         elseif ($boonsRoll -eq 3)
  2025.         {
  2026.             $boon = "You found a riding horse."    
  2027.         }
  2028.         elseif ($boonsRoll -eq 4)
  2029.         {
  2030.             $gold = $this.dice.d20()
  2031.             $boon = "You found some money. You have $gold gp in addition to your regular starting funds."
  2032.         }
  2033.         elseif ($boonsRoll -eq 5)
  2034.         {
  2035.            $boon = "A relative bequeathed you a simple weapon of your choice."
  2036.         }
  2037.         elseif ($boonsRoll -eq 6)
  2038.         {
  2039.             $boon = "You found something interesting. You gain one additional trinket."    
  2040.         }
  2041.         elseif ($boonsRoll -eq 7)
  2042.         {
  2043.             $boon = "You once performed a service for a local temple. The next time you visit the temple, you can receive healing up to your hit point maximum."    
  2044.         }
  2045.         elseif ($boonsRoll -eq 8)
  2046.         {
  2047.             $boon = "A friendly alchemist gifted you with a potion of healing or a flask of acid, as you choose."    
  2048.         }
  2049.         elseif ($boonsRoll -eq 9)
  2050.         {
  2051.             $boon = "You found a treasure map."    
  2052.         }
  2053.         elseif ($boonsRoll -eq 10)
  2054.         {
  2055.             $years = $this.dice.d20()
  2056.             $boon = "A distant relative left you a stipend that enables you to live at the comfortable lifestyle for $years years. If you choose to live at a higher lifestyle, you reduce the price ofthe lifestyle by 2 gp during that time period."    
  2057.         }
  2058.         return $boon
  2059.     }
  2060.     [string] crime ()
  2061.     {
  2062.         $crimeRoll = $this.dice.d8()
  2063.         $crime = $null
  2064.         if ($crimeRoll -eq 1)
  2065.         {
  2066.             $crime = "Murder."
  2067.         }
  2068.         elseif ($crimeRoll -eq 2)
  2069.         {
  2070.             $crime = "Theft."
  2071.         }
  2072.         elseif ($crimeRoll -eq 3)
  2073.         {
  2074.             $crime = "Burglary."
  2075.         }
  2076.         elseif ($crimeRoll -eq 4)
  2077.         {
  2078.             $crime = "Assault."
  2079.         }
  2080.         elseif ($crimeRoll -eq 5)
  2081.         {
  2082.             $crime = "Smuggling."
  2083.         }
  2084.         elseif ($crimeRoll -eq 6)
  2085.         {
  2086.             $crime = "Kidnapping."
  2087.         }
  2088.         elseif ($crimeRoll -eq 7)
  2089.         {
  2090.             $crime = "Extortion."
  2091.         }
  2092.         elseif ($crimeRoll -eq 8)
  2093.         {
  2094.             $crime = "Counterfeiting."
  2095.         }
  2096.         return $crime
  2097.     }
  2098.     [string] punishment ()
  2099.     {
  2100.         $punishmentRoll = $this.dice.d12()
  2101.         $punishment = $null
  2102.         if ($punishmentRoll -ge 1 -and $punishmentRoll -le 3)
  2103.         {
  2104.             $punishment = " You did not commit the crime and were exonerated after being accused."    
  2105.         }
  2106.         elseif ($punishmentRoll -ge 4 -and $punishmentRoll -le 6)
  2107.         {
  2108.             $punishment = "You committed the crime or helped do so, but nonetheless the authorities found you not guilty."    
  2109.         }
  2110.         elseif ($punishmentRoll -ge 7 -and $punishmentRoll -le 8)
  2111.         {
  2112.             $punishment = "You were nearly caught in the act. You had to flee and are wanted in the community where the crime occurred."    
  2113.         }
  2114.         elseif ($punishmentRoll -ge 9 -and $punishmentRoll -le 12)
  2115.         {
  2116.             $sentance = $this.dice.d4()
  2117.             $punishment = "You were caught and convicted. You spent time in jail, chained to an oar, or performing hard labor. You served a sentence of $sentance years or succeeded in escaping after that much time."    
  2118.         }
  2119.         return $punishment
  2120.     }
  2121.     [string] supernaturalEvents ()
  2122.     {
  2123.         $supernaturalRoll =$this.dice.d100()
  2124.         $supernaturalEvent = $null
  2125.         if ($supernaturalRoll -ge 1 -and $supernaturalRoll -le 5)
  2126.         {
  2127.             $ensorcelled = $this.dice.d6()
  2128.             $supernaturalEvent = "You were ensorcelled by a fey and enslaved for $ensorcelled years before you escaped."    
  2129.         }
  2130.         elseif ($supernaturalRoll -ge 6 -and $supernaturalRoll -le 10)
  2131.         {
  2132.             $supernaturalEvent = "You saw a demon and ran away before it could do anything to you."    
  2133.         }
  2134.         elseif ($supernaturalRoll -ge 11 -and $supernaturalRoll -le 15)
  2135.         {
  2136.             $supernaturalEvent = "A devil tempted you. Make a DC 10 Wisdom saving throw. On a failed save, your alignment shifts one step toward evil (if it's not evil already), and you start the game with an additional 1d20 + 50 gp."    
  2137.         }
  2138.         elseif ($supernaturalRoll -ge 16 -and $supernaturalRoll -le 20)
  2139.         {
  2140.             $supernaturalEvent = "You woke up one morning miles from your home, with no idea how you got there."    
  2141.         }
  2142.         elseif ($supernaturalRoll -ge 21 -and $supernaturalRoll -le 30)
  2143.         {
  2144.             $supernaturalEvent = "You visited a holy site and felt the presence ofthe divine there."    
  2145.         }
  2146.         elseif ($supernaturalRoll -ge 31 -and $supernaturalRoll -le 40)
  2147.         {
  2148.             $supernaturalEvent = "You witnessed a falling red star, a face appearing in the frost, or some other bizarre happening. You are certain that it was an omen of some sort."    
  2149.         }
  2150.         elseif ($supernaturalRoll -ge 41 -and $supernaturalRoll -le 50)
  2151.         {
  2152.             $supernaturalEvent = "You escaped certain death and believe it was the intervention of a god that saved you."    
  2153.         }
  2154.         elseif ($supernaturalRoll -ge 51 -and $supernaturalRoll -le 60)
  2155.         {
  2156.             $supernaturalEvent = " You witnessed a minor miracle."    
  2157.         }
  2158.         elseif ($supernaturalRoll -ge 61 -and $supernaturalRoll -le 70)
  2159.         {
  2160.             $supernaturalEvent = "You explored an empty house and found it to be haunted."    
  2161.         }
  2162.         elseif ($supernaturalRoll -ge 71 -and $supernaturalRoll -le 75)
  2163.         {
  2164.             $possessionRoll = $this.dice.d6()
  2165.             $possession = $null
  2166.             if ($possessionRoll -eq 1)
  2167.             {
  2168.                 $possession = "celestial"    
  2169.             }
  2170.             elseif ($possessionRoll -eq 2)
  2171.             {
  2172.                 $possession = "devil"    
  2173.             }
  2174.             elseif ($possessionRoll -eq 3)
  2175.             {
  2176.                 $possession = "demon"    
  2177.             }
  2178.             elseif ($possessionRoll -eq 4)
  2179.             {
  2180.                 $possession = "fey"    
  2181.             }
  2182.             elseif ($possessionRoll -eq 5)
  2183.             {
  2184.                 $possession = "elemental"    
  2185.             }
  2186.             elseif ($possessionRoll -eq 6)
  2187.             {
  2188.                 $possession = "undead"    
  2189.             }
  2190.             $supernaturalEvent = " You were briefly possessed by a $possession."  
  2191.         }
  2192.         elseif ($supernaturalRoll -ge 76 -and $supernaturalRoll -le 80)
  2193.         {
  2194.             $supernaturalEvent = "You saw a ghost."    
  2195.         }
  2196.         elseif ($supernaturalRoll -ge 81 -and $supernaturalRoll -le 85)
  2197.         {
  2198.             $supernaturalEvent = "You saw a ghoul feeding on a corpse."    
  2199.         }
  2200.         elseif ($supernaturalRoll -ge 86 -and $supernaturalRoll -le 90)
  2201.         {
  2202.             $supernaturalEvent = "A celestial or a fiend visited you in your dreams to give a warning of dangers to come."    
  2203.         }
  2204.         elseif ($supernaturalRoll -ge 91 -and $supernaturalRoll -le 95)
  2205.         {
  2206.             $supernaturalEvent = "You briefly visited the Feywild or the Shadowfell."    
  2207.         }
  2208.         elseif ($supernaturalRoll -ge 96 -and $supernaturalRoll -le 100)
  2209.         {
  2210.             $supernaturalEvent = "You saw a portal that you believe leads to another plane of existence."    
  2211.         }
  2212.         return $supernaturalEvent  
  2213.     }
  2214.     [string] tragedies ()
  2215.     {
  2216.         $tragedyRoll = $this.dice.d12()
  2217.         $tragedy = $null
  2218.         if ($tragedyRoll -ge 1 -and $tragedyRoll -le 2)
  2219.         {
  2220.             $death = $this.supplementalTable.causeOfDeathTable
  2221.             $tragedy = "A family member or a close friend died due to $death"
  2222.         }
  2223.         elseif ($tragedyRoll -eq 3)
  2224.         {
  2225.             $tragedy = "A friendship ended bitterly, and the other person is now hostile to you. The cause might have been a misunderstanding or something you or the former friend did."    
  2226.         }
  2227.         elseif ($tragedyRoll -eq 4)
  2228.         {
  2229.             $tragedy = " You lost all your possessions in a disaster, and you had to rebuild your life."    
  2230.         }
  2231.         elseif ($tragedyRoll -eq 5)
  2232.         {
  2233.             $years = $this.dice.d6()
  2234.             $tragedy = "You were imprisoned for a crime you didn’t commit and spent $years years at hard labor, in jail, or shackled to an oar in a slave galley."    
  2235.         }
  2236.         elseif ($tragedyRoll -eq 6)
  2237.         {
  2238.             $tragedy = "War ravaged your home community, reducing everything to rubble and ruin. in the aftermath, you either helped your town rebuild or moved somewhere else."    
  2239.         }
  2240.         elseif ($tragedyRoll -eq 7)
  2241.         {
  2242.             $tragedy = " A lover disappeared without a trace. You have been looking for that person ever since."    
  2243.         }
  2244.         elseif ($tragedyRoll -eq 8)
  2245.         {
  2246.             $tragedy = "A terrible blight in your home community caused crops to fail, and many starved. You lost a sibling or some other family member."    
  2247.         }
  2248.         elseif ($tragedyRoll -eq 9)
  2249.         {
  2250.             $tragedy = "You did something that brought terrible shame to you in the eyes of your family. You might have been involved in a scandal, dabbled in dark magic, or offended someone important. The attitude of your family members toward you becomes indifferent at best, though they might eventually forgive you."    
  2251.         }
  2252.         elseif ($tragedyRoll -eq 10)
  2253.         {
  2254.             $tragedy = " For a reason you were never told, you were exiled from your community. You then either wandered in the wilderness for a time or promptly found a new place to live."    
  2255.         }
  2256.         elseif ($tragedyRoll -eq 11)
  2257.         {
  2258.             $endingRoll = $this.dice.d6x3()
  2259.             $result = evenOdd -number $endingRoll
  2260.             if ($result -eq $true)
  2261.             {
  2262.                 $ending = "ended amicably."      
  2263.             }
  2264.             else
  2265.             {
  2266.                 $ending = "ended with bad feelings."
  2267.             }
  2268.             $tragedy = "A romantic relationship $ending"    
  2269.         }
  2270.         elseif ($tragedyRoll -eq 12)
  2271.         {
  2272.             $death = causeOfDeath
  2273.             $tragedy = "A current or prospective romantic partner of yours died. Roll on the Cause of Death supplemental table to find out how. If the result is murder, roll a d12. On a 1, you were responsible, whether directly orindirectly."    
  2274.         }
  2275.         return $tragedy
  2276.     }
  2277.     [string] war ()
  2278.     {
  2279.         $warRoll = $this.dice.d12()
  2280.         $war = $null
  2281.         if ($warRoll -eq 1)
  2282.         {
  2283.             $war = "You were knocked out and left for dead. You woke up hours later with no recollection of the battle."    
  2284.         }
  2285.         elseif ($warRoll -ge 2 -and $warRoll -le 3)
  2286.         {
  2287.             $war = "You were badly injured in the fight, and you still bear the awful scars of those wounds."    
  2288.         }
  2289.         elseif ($warRoll -eq 4)
  2290.         {
  2291.             $war = "You ran away from the battle to save your life, but you still feel shame for your cowardice."    
  2292.         }
  2293.         elseif ($warRoll -ge 5 -and $warRoll -le 7)
  2294.         {
  2295.             $war = "You suffered only minor injuries, and the wounds all healed without leaving scars."    
  2296.         }
  2297.         elseif ($warRoll -ge 8 -and $warRoll -le 9)
  2298.         {
  2299.             $war = "You survived the battle, but you suffer from terrible nightmares in which you relive the experience."    
  2300.         }
  2301.         elseif ($warRoll -ge 10 -and $warRoll -le 11)
  2302.         {
  2303.             $war = "You escaped the battle unscathed, though many of your Friends were injured or lost."    
  2304.         }
  2305.         elseif ($warRoll -eq 12)
  2306.         {
  2307.             $war = "You acquitted yourself well in battle and are remembered as a hero. You might have received a medal for your bravery."    
  2308.         }
  2309.         return $war
  2310.     }
  2311.     [string] weirdStuff ()
  2312.     {
  2313.         $weirdStuffRoll = $this.dice.d12()
  2314.         $weirdResult = $null
  2315.         if ($weirdStuffRoll -eq 1)
  2316.         {
  2317.             $weeks = $this.dice.d4()
  2318.             $weirdResult = "You were turned into a toad and remained in that form for $weeks weeks."    
  2319.         }
  2320.         elseif ($weirdStuffRoll -eq 2)
  2321.         {
  2322.             $weirdResult = "You were petrified and remained a stone statue for a time until someone freed you."    
  2323.         }
  2324.         elseif ($weirdStuffRoll -eq 3)
  2325.         {
  2326.             $years = $this.dice.d6()
  2327.             $weirdResult = "You were enslaved by a hag, a satyr, or some other being and lived in that creature’s thrall for $years years."    
  2328.         }
  2329.         elseif ($weirdStuffRoll -eq 4)
  2330.         {
  2331.             $months = $this.dice.d4
  2332.             $weirdResult = "A dragon held you as a prisoner for $months months until adventurers killed it."    
  2333.         }
  2334.         elseif ($weirdStuffRoll -eq 5)
  2335.         {
  2336.             $weirdResult = "You were taken captive by a race of evil humanoids such as drow, kuo-toa, or quaggoths. You lived as a slave in the Underdark until you escaped."    
  2337.         }
  2338.         elseif ($weirdStuffRoll -eq 6)
  2339.         {
  2340.             $weirdResult = "You served a powerful adventurer as a hireling. You have only recently left that service. Use the supplemental tables and work with your DM to determine the basic details about your former employer."    
  2341.         }
  2342.         elseif ($weirdStuffRoll -eq 7)
  2343.         {
  2344.             $years = $this.dice.d6()
  2345.             $weirdResult = "You went insane for $years years and recently regained your sanity. A tic or some other bit ofodd behavior might linger."    
  2346.         }
  2347.         elseif ($weirdStuffRoll -eq 8)
  2348.         {
  2349.             $weirdResult = "A lover of yours was secretly a silver dragon."    
  2350.         }
  2351.         elseif ($weirdStuffRoll -eq 9)
  2352.         {
  2353.             $weirdResult = "You were captured by a cult and nearly sacrificed on an altar to the foul being the cultists served. You escaped, but you fear they will find you."    
  2354.         }
  2355.         elseif ($weirdStuffRoll -eq 10)
  2356.         {
  2357.             $metArray = @(
  2358.                 "a demigod",
  2359.                 "an archdevil",
  2360.                 "an archfey",
  2361.                 "a demon lord",
  2362.                 "a titan"
  2363.             )
  2364.             $met = Get-Random -InputObject $metArray
  2365.             $weirdResult = "You met $met, and you lived to tell the tale."    
  2366.         }
  2367.         elseif ($weirdStuffRoll -eq 11)
  2368.         {
  2369.             $weirdResult = "You were swallowed by a giant fish and spent a month in its gullet before you escaped."    
  2370.         }
  2371.         elseif ($weirdStuffRoll -eq 12)
  2372.         {
  2373.             $weirdResult = "A powerful being granted you a wish, but you squandered it on something frivolous."    
  2374.         }
  2375.         return $weirdResult
  2376.     }
  2377. }
  2378.  
  2379. function modifier ($abilityScore)
  2380. {
  2381.     $modifier = $null
  2382.     if ($abilityScore -eq 1)
  2383.     {
  2384.         $modifier = -5    
  2385.     }
  2386.     elseif ($abilityScore -eq 2 -or $abilityScore -eq 3)
  2387.     {
  2388.         $modifier = -4    
  2389.     }
  2390.     elseif ($abilityScore -eq 4 -or $abilityScore -eq 5)
  2391.     {
  2392.         $modifier = -3    
  2393.     }
  2394.     elseif ($abilityScore -eq 6 -or $abilityScore -eq 7)
  2395.     {
  2396.         $modifier = -2  
  2397.     }
  2398.     elseif ($abilityScore -eq 8 -or $abilityScore -eq 9)
  2399.     {
  2400.         $modifier = -1    
  2401.     }
  2402.     elseif ($abilityScore -eq 10 -or $abilityScore -eq 11)
  2403.     {
  2404.         $modifier = 0    
  2405.     }
  2406.     elseif ($abilityScore -eq 12 -or $abilityScore -eq 13)
  2407.     {
  2408.         $modifier = 1    
  2409.     }
  2410.     elseif ($abilityScore -eq 14 -or $abilityScore -eq 15)
  2411.     {
  2412.         $modifier = 2  
  2413.     }
  2414.     elseif ($abilityScore -eq 16 -or $abilityScore -eq 17)
  2415.     {
  2416.         $modifier = 3  
  2417.     }
  2418.     elseif ($abilityScore -eq 18 -or $abilityScore -eq 19)
  2419.     {
  2420.         $modifier = 4    
  2421.     }
  2422.     elseif ($abilityScore -eq 20)
  2423.     {
  2424.         $modifier = 5  
  2425.     }
  2426.     return $modifier
  2427. }
  2428. function evenOdd ($number)
  2429. {
  2430.     $result = $number % 2
  2431.     if ($result -eq 0)
  2432.     {
  2433.         return $true    
  2434.     }
  2435.     else
  2436.     {
  2437.         return $false
  2438.     }
  2439. }
  2440. function dropLowest ($stat)
  2441. {
  2442.     [System.Collections.ArrayList] $array = $stat|Sort-Object
  2443.     $index = 0
  2444.     $minIndex = 0
  2445.     $minValue = [int]::MaxValue
  2446.     foreach($statRoll in $array)
  2447.     {
  2448.         if ($minValue -gt $_)
  2449.         {
  2450.             $minValue = $_; $minIndex = $index
  2451.        
  2452.         }
  2453.        
  2454.         $index++
  2455.     }
  2456.    
  2457.     $array.RemoveAt($minIndex)
  2458.  
  2459.     $arrayConvert = $array.ToArray()
  2460.     $arraySum = ($arrayConvert|Measure-Object -Sum).Sum
  2461.     return $arraySum
  2462. }
  2463.  
  2464. #Build Character
  2465. $character = [Character]::new()
  2466. $originTable = [OriginsTables]::new()
  2467. $supplementalTable = [SupplementalTables]::new()
  2468. $backgroundTable = [BackgroundDecisionTables]::new()
  2469. $classDecisionTable = [ClassTrainingDecisionTables]::new()
  2470. $lifeEventsTable = [LifeEventsTable]::new()
  2471. $statsGenerator = [StatsGenerator]::new()
  2472. $character.race = Read-Host -Prompt "Input your race"
  2473. $character.background = Read-Host -Prompt "Input your background"
  2474. $character.class = Read-Host -Prompt "Input your class"
  2475.  
  2476. $strRoll = "Strength Rolls:"
  2477. $chaRoll = "Charisma Rolls:"
  2478. $intRoll = "Intelligence Rolls:"
  2479. $dexRoll = "Dexterity Rolls:"
  2480. $wisRoll = "Wisdom Rolls:"
  2481.  
  2482. $conRoll = "Constitution Rolls:"
  2483. Write-Output "`n"
  2484. write-output $strRoll
  2485. write-output $statsGenerator.str
  2486. Write-Output "`n"
  2487. Write-Output $chaRoll
  2488. Write-Output $statsGenerator.cha
  2489. Write-Output "`n"
  2490. Write-Output $intRoll
  2491. write-output $statsGenerator.int
  2492. Write-Output "`n"
  2493. Write-Output $dexRoll
  2494. Write-Output $statsGenerator.dex
  2495. Write-Output "`n"
  2496. write-output $conRoll
  2497. $statsGenerator.con
  2498. Write-Output "`n"
  2499. write-output $wisRoll
  2500. write-output $statsGenerator.wis
  2501. Write-Output "`n"
  2502.  
  2503. $character.strength = dropLowest ($statsGenerator.str)
  2504. $character.charisma = dropLowest ($statsGenerator.cha)
  2505. $character.dexterity = dropLowest ($statsGenerator.dex)
  2506. $character.intelligence = dropLowest ($statsGenerator.int)
  2507. $character.constitution = droplowest ($statsGenerator.con)
  2508. $character.wisdom = dropLowest ($statsGenerator.wis)
  2509. $character.chaModifier = modifier($character.charisma)
  2510. $character.age = $lifeEventsTable.Age
  2511. $character.lifeEventCount = $lifeEventsTable.totalEvents
  2512. $character.parentsKnown = $originTable.parentsKnown()
  2513.  
  2514. if ($character.race.ToLower() -like 'half-elf' -or $character.race.ToLower() -like 'half-orc' -or $character.race.tolower() -like 'tiefling')
  2515. {
  2516.     $character.nonHumanParents = $originTable.nonHumanParents($character.race)
  2517. }
  2518. else
  2519. {
  2520.     $character.nonHumanParents = $null
  2521. }
  2522. if ($character.parentsKnown -eq $false)
  2523. {
  2524.     $character.parents = "You do not know who your parents were."    
  2525. }
  2526. else
  2527. {
  2528.     $character.parents = ("You know who your parents are or were.", $character.nonHumanParents) -join " "
  2529. }
  2530.  
  2531. $character.birthplace = $originTable.birthplace()
  2532. $character.siblingCount = $originTable.numberOfSiblings($character.race)
  2533. $siblingArray = @{}
  2534. $sibling=0
  2535. if ($character.siblingCount -gt 0) {
  2536.     while ($sibling -lt $character.siblingCount)
  2537.     {
  2538.         $sibling++
  2539.         $siblingNumber = $sibling
  2540.         $siblingDetail = [SiblingDetail]::new()
  2541.         $siblingArray[$siblingNumber] = @{
  2542.             "Name" = ("Sibling", $siblingNumber) -join " "
  2543.             "Alignment" = $siblingDetail.alignment
  2544.             "Relationship" = $siblingDetail.relationship
  2545.             "Status" = $siblingDetail.status
  2546.             "BirthOrder" = $siblingDetail.birthOrder
  2547.             "Job" = $siblingDetail.job
  2548.         }
  2549.     }
  2550. }
  2551. else {
  2552.     $character.siblings = $null
  2553. }
  2554.  
  2555. $character.siblings = $siblingArray
  2556. $character.family = $originTable.family($character.parentsKnown)
  2557. $character.familyLifestyle = $originTable.familyLifestyle()
  2558. $character.childhoodHome = $originTable.childhoodHome($character.familyLifestyle[1])
  2559. $character.childhoodMemories = $originTable.childhoodMemories($character.chaModifier)
  2560. $background = $character.background.ToLower()
  2561. $character.backgroundInfo = $backgroundTable.$background()
  2562. $class = $character.class.ToLower()
  2563. $character.classTraining = $classDecisionTable.$class()
  2564. $eventsTotal = 0
  2565. $lifeEventArray = @()
  2566. while ($eventsTotal -lt $character.lifeEventCount)
  2567. {
  2568.     $eventsTotal++
  2569.     $eventHappens = $lifeEventsTable.event()
  2570.     $lifeEventArray += $eventHappens
  2571. }
  2572. $character.lifeEvent = $lifeEventArray
  2573.  
  2574. #Build Output from Character
  2575. #Origins Output
  2576. $originOut = New-Object psobject -Property @{
  2577.     Parents = $character.parents
  2578.     Birthplace = $character.birthplace
  2579.     Family = $character.family
  2580.     FamilyLifestyle = $character.familyLifestyle[0]
  2581.     ChildhoodHome = $character.childhoodHome
  2582.     ChildhoodMemories = $character.childhoodMemories
  2583. }
  2584. #Sibling Output
  2585. $siblingItem = $character.siblings.Values
  2586. $siblingOutputArray = foreach ($sibling in $siblingItem)
  2587. {
  2588.     New-Object psobject -Property $sibling  
  2589. }
  2590. $parentsOut = ("Parents:", $originOut.Parents) -join " "
  2591. $birthplaceOut = ("Birthplace:",$originOut.Birthplace) -join " "
  2592. $familyOut = ("Family:",$originOut.family) -join " "
  2593. $familyLifestyleOut = ("Family Lifestyle:",$originOut.familyLifestyle) -join " "
  2594. $childhoodHomeOut = ("Childhood Home:", $originOut.ChildhoodHome) -join " "
  2595. $childhoodMemoriesOut = ("Childhood Memories:", $originOut.childhoodMemories) -join " "
  2596.  
  2597. #Personal Decisions Output
  2598. $backgroundInfoOut = ("I became a", $character.background, "because:", $character.backgroundInfo) -join " "
  2599. $classTrainingOut = ("I became a", $character.class, "because:", $character.classTraining) -join " "
  2600.  
  2601. #Stats Output
  2602. $statsOutput = New-Object psobject -Property @{
  2603.     Strength = $character.strength
  2604.     Dexterity = $character.dexterity
  2605.     Constitution = $character.constitution
  2606.     Intelligence = $character.intelligence
  2607.     Wisdom = $character.wisdom
  2608.     Charisma = $character.charisma
  2609. }
  2610. Write-Output "Your character stats are listed below"
  2611. Write-Output "`n"
  2612. Write-Output $statsOutput
  2613. Write-Output "`n"
  2614. Write-Output $parentsOut
  2615. Write-Output "`n"
  2616. Write-Output $birthplaceOut
  2617. Write-Output "`n"
  2618. Write-Output $familyOut
  2619. Write-Output "`n"
  2620. Write-Output $familyLifestyleOut
  2621. Write-Output "`n"
  2622. Write-Output $childhoodHomeOut
  2623. Write-Output "`n"
  2624. Write-Output $childhoodMemoriesOut
  2625. Write-Output "`n"
  2626. if ($character.siblingCount -gt 0)
  2627. {
  2628.     $siblingOutputString = ("Siblings:",$character.siblingCount.ToString(),"Their information is displayed below:") -join " "
  2629.     Write-Output $siblingOutputString
  2630.     Write-Output $siblingOutputArray|Select-Object Name,BirthOrder,Relationship,Alignment,Status|Sort-Object -Property Name|Format-Table -Wrap    
  2631. }
  2632. #Life Events output
  2633. Write-Output $backgroundInfoOut
  2634. Write-Output "`n"
  2635. Write-Output $classTrainingOut
  2636. Write-Output "`n"
  2637. $ageOutput = ("You are", $character.age, "years old. You've had", $character.lifeEventCount, "life events. They are detailed below:") -join " "
  2638. Write-Output $ageOutput
  2639. Write-Output "`n"
  2640. while ($eventCount -lt $character.lifeEventCount)
  2641. {
  2642.     $eventCount++
  2643.     $index = $eventCount -1    
  2644.     Write-Output $character.lifeEvent[$index]
  2645.     Write-Output "`n"
  2646. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement