Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
- [void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
- #1..8 | ForEach {Get-Random -Minimum 1 -Maximum 20}
- Function Roll-Dice()
- {
- $Top3 = 1..4 | foreach {Get-Random -min 1 -max 7} | Sort -Descending | Select -First 3
- $TOPROLL = $Top3[0] + $Top3[1] + $Top3[2]
- Invoke-Expression -command $TOPROLL
- }
- $Items = Roll-Dice
- $objForm = New-Object System.Windows.Forms.Form
- $objForm.Text = "Take Hitpoints"
- $objForm.Size = New-Object System.Drawing.Size(380,300)
- $objForm.StartPosition = "CenterScreen"
- $objForm.KeyPreview = $True
- # Dice Roll Labels
- $objStrRollLabel = New-Object System.Windows.Forms.Label
- $objStrRollLabel.Location = New-Object System.Drawing.Size(50,15)
- $objStrRollLabel.Size = New-Object System.Drawing.Size(30,15)
- $objStrRollLabel.Text = "Str"
- $objForm.Controls.Add($objStrRollLabel)
- $objConRollLabel = New-Object System.Windows.Forms.Label
- $objConRollLabel.Location = New-Object System.Drawing.Size(100,15)
- $objConRollLabel.Size = New-Object System.Drawing.Size(30,15)
- $objConRollLabel.Text = "Con"
- $objForm.Controls.Add($objConRollLabel)
- $objIntRollLabel = New-Object System.Windows.Forms.Label
- $objIntRollLabel.Location = New-Object System.Drawing.Size(150,15)
- $objIntRollLabel.Size = New-Object System.Drawing.Size(30,15)
- $objIntRollLabel.Text = "Int"
- $objForm.Controls.Add($objIntRollLabel)
- $objWisRollLabel = New-Object System.Windows.Forms.Label
- $objWisRollLabel.Location = New-Object System.Drawing.Size(200,15)
- $objWisRollLabel.Size = New-Object System.Drawing.Size(30,15)
- $objWisRollLabel.Text = "Wis"
- $objForm.Controls.Add($objWisRollLabel)
- $objChaRollLabel = New-Object System.Windows.Forms.Label
- $objChaRollLabel.Location = New-Object System.Drawing.Size(250,15)
- $objChaRollLabel.Size = New-Object System.Drawing.Size(30,15)
- $objChaRollLabel.Text = "Cha"
- $objForm.Controls.Add($objChaRollLabel)
- $objDexRollLabel = New-Object System.Windows.Forms.Label
- $objDexRollLabel.Location = New-Object System.Drawing.Size(300,15)
- $objDexRollLabel.Size = New-Object System.Drawing.Size(30,15)
- $objDexRollLabel.Text = "Dex"
- $objForm.Controls.Add($objDexRollLabel)
- # Dice Roll Fields
- $objStrRoll = New-Object System.Windows.Forms.Listbox
- $objStrRoll.Location = New-Object System.Drawing.Size(50,40)
- $objStrRoll.Size = New-Object System.Drawing.Size(30,20)
- $objForm.Controls.Add($objStrRoll)
- $objConRoll = New-Object System.Windows.Forms.Listbox
- $objConRoll.Location = New-Object System.Drawing.Size(100,40)
- $objConRoll.Size = New-Object System.Drawing.Size(30,20)
- $objForm.Controls.Add($objConRoll)
- $objIntRoll = New-Object System.Windows.Forms.Listbox
- $objIntRoll.Location = New-Object System.Drawing.Size(150,40)
- $objIntRoll.Size = New-Object System.Drawing.Size(30,20)
- $objForm.Controls.Add($objIntRoll)
- $objWisRoll = New-Object System.Windows.Forms.Listbox
- $objWisRoll.Location = New-Object System.Drawing.Size(200,40)
- $objWisRoll.Size = New-Object System.Drawing.Size(30,20)
- $objForm.Controls.Add($objWisRoll)
- $objChaRoll = New-Object System.Windows.Forms.Listbox
- $objChaRoll.Location = New-Object System.Drawing.Size(250,40)
- $objChaRoll.Size = New-Object System.Drawing.Size(30,20)
- $objForm.Controls.Add($objChaRoll)
- $objDexRoll = New-Object System.Windows.Forms.Listbox
- $objDexRoll.Location = New-Object System.Drawing.Size(300,40)
- $objDexRoll.Size = New-Object System.Drawing.Size(30,20)
- $objForm.Controls.Add($objDexRoll)
- # Dice Roll Clicks
- $objStrRoll.Add_Click(
- {
- $cmdlet = $objStrRoll.SelectedItem
- $objStatStr.Items.Clear()
- If ($cmdlet –ne $Null){[void] $objStatStr.Items.Add($cmdlet)}
- })
- $objConRoll.Add_Click(
- {
- $cmdlet = $objConRoll.SelectedItem
- $objStatCon.Items.Clear()
- If ($cmdlet –ne $Null){[void] $objStatCon.Items.Add($cmdlet)}
- })
- $objIntRoll.Add_Click(
- {
- $cmdlet = $objIntRoll.SelectedItem
- $objStatInt.Items.Clear()
- If ($cmdlet –ne $Null){[void] $objStatInt.Items.Add($cmdlet)}
- })
- $objWisRoll.Add_Click(
- {
- $cmdlet = $objWisRoll.SelectedItem
- $objStatWis.Items.Clear()
- If ($cmdlet –ne $Null){[void] $objStatWis.Items.Add($cmdlet)}
- })
- $objChaRoll.Add_Click(
- {
- $cmdlet = $objChaRoll.SelectedItem
- $objStatCha.Items.Clear()
- If ($cmdlet –ne $Null){[void] $objStatCha.Items.Add($cmdlet)}
- })
- $objDexRoll.Add_Click(
- {
- $cmdlet = $objDexRoll.SelectedItem
- $objStatDex.Items.Clear()
- If ($cmdlet –ne $Null){[void] $objStatDex.Items.Add($cmdlet)}
- })
- # Buttons
- $DiceRollButton = New-Object System.Windows.Forms.Button
- $DiceRollButton.Location = New-Object System.Drawing.Size(280,80)
- $DiceRollButton.Size = New-Object System.Drawing.Size(50,23)
- $DiceRollButton.Text = "Roll All"
- $DiceRollButton.Add_Click(
- {
- #Clear Selected Stats
- $objStatStr.Items.Clear();$objStatCon.Items.Clear();$objStatInt.Items.Clear();$objStatWis.Items.Clear();$objStatCha.Items.Clear();$objStatDex.Items.Clear()
- #Clear all current rolls
- $objStrRoll.Items.Clear();$objConRoll.Items.Clear();$objIntRoll.Items.Clear();$objWisRoll.Items.Clear();$objChaRoll.Items.Clear();$objDexRoll.Items.Clear()
- #Populate new rolls for all stat roll fields
- foreach ($item in Roll-Dice){[void] $objStrRoll.Items.Add($item)}
- foreach ($item in Roll-Dice){[void] $objConRoll.Items.Add($item)}
- foreach ($item in Roll-Dice){[void] $objIntRoll.Items.Add($item)}
- foreach ($item in Roll-Dice){[void] $objWisRoll.Items.Add($item)}
- foreach ($item in Roll-Dice){[void] $objChaRoll.Items.Add($item)}
- ForEach ($item in Roll-Dice){[void] $objDexRoll.Items.Add($item)}
- })
- $objForm.Controls.Add($DiceRollButton)
- # Stat Labels
- # This label site left of the Stat field
- $objStatStrLabel = New-Object System.Windows.Forms.Label
- $objStatStrLabel.Location = New-Object System.Drawing.Size(20,90)
- $objStatStrLabel.Size = New-Object System.Drawing.Size(25,20)
- $objStatStrLabel.Text = "Str"
- $objForm.Controls.Add($objStatStrLabel)
- $objStatConLabel = New-Object System.Windows.Forms.Label
- $objStatConLabel.Location = New-Object System.Drawing.Size(20,120)
- $objStatConLabel.Size = New-Object System.Drawing.Size(25,20)
- $objStatConLabel.Text = "Con"
- $objForm.Controls.Add($objStatConLabel)
- $objStatIntLabel = New-Object System.Windows.Forms.Label
- $objStatIntLabel.Location = New-Object System.Drawing.Size(20,150)
- $objStatIntLabel.Size = New-Object System.Drawing.Size(25,20)
- $objStatIntLabel.Text = "Int"
- $objForm.Controls.Add($objStatIntLabel)
- $objStatWisLabel = New-Object System.Windows.Forms.Label
- $objStatWisLabel.Location = New-Object System.Drawing.Size(20,180)
- $objStatWisLabel.Size = New-Object System.Drawing.Size(25,20)
- $objStatWisLabel.Text = "Wis"
- $objForm.Controls.Add($objStatWisLabel)
- $objStatChaLabel = New-Object System.Windows.Forms.Label
- $objStatChaLabel.Location = New-Object System.Drawing.Size(20,210)
- $objStatChaLabel.Size = New-Object System.Drawing.Size(25,20)
- $objStatChaLabel.Text = "Cha"
- $objForm.Controls.Add($objStatChaLabel)
- $objStatDexLabel = New-Object System.Windows.Forms.Label
- $objStatDexLabel.Location = New-Object System.Drawing.Size(20,240)
- $objStatDexLabel.Size = New-Object System.Drawing.Size(25,20)
- $objStatDexLabel.Text = "Dex"
- $objForm.Controls.Add($objStatDexLabel)
- # Stat Fields
- # This sites to the right of the Stat Label
- $objStatStr = New-Object System.Windows.Forms.Listbox
- $objStatStr.Location = New-Object System.Drawing.Size(50,90)
- $objStatStr.Size = New-Object System.Drawing.Size(40,20)
- $objForm.Controls.Add($objStatStr)
- $objStatCon = New-Object System.Windows.Forms.Listbox
- $objStatCon.Location = New-Object System.Drawing.Size(50,120)
- $objStatCon.Size = New-Object System.Drawing.Size(40,20)
- $objForm.Controls.Add($objStatCon)
- $objStatInt = New-Object System.Windows.Forms.Listbox
- $objStatInt.Location = New-Object System.Drawing.Size(50,150)
- $objStatInt.Size = New-Object System.Drawing.Size(40,20)
- $objForm.Controls.Add($objStatInt)
- $objStatWis = New-Object System.Windows.Forms.Listbox
- $objStatWis.Location = New-Object System.Drawing.Size(50,180)
- $objStatWis.Size = New-Object System.Drawing.Size(40,20)
- $objForm.Controls.Add($objStatWis)
- $objStatCha = New-Object System.Windows.Forms.Listbox
- $objStatCha.Location = New-Object System.Drawing.Size(50,210)
- $objStatCha.Size = New-Object System.Drawing.Size(40,20)
- $objForm.Controls.Add($objStatCha)
- $objStatDex = New-Object System.Windows.Forms.Listbox
- $objStatDex.Location = New-Object System.Drawing.Size(50,240)
- $objStatDex.Size = New-Object System.Drawing.Size(40,20)
- $objForm.Controls.Add($objStatDex)
- $objForm.Add_Shown({$objForm.Activate()})
- [void] $objForm.ShowDialog()
Advertisement
Add Comment
Please, Sign In to add comment