I am pretty new to powershell but in my current program I need to assign a variable to a Word
$BtnEntrer2.Add_Click({
if ($Cbchoix.Text -eq "Quitter"){
$tabControl.SelectedTab = $TabPage5
Sleep 3
$FormRPS.Close()
This part is the bugged part
if ($Cbchoix.Text -eq "Roche") {$playerMove = "Rock"
$computerMove = Get-Random "Rock","Paper" ,"Scissors"}
if ($Cbchoix.Text -eq "Papier") {$playerMove = "Paper"
$computerMove = Get-Random "Rock","Paper" ,"Scissors"}
if ($Cbchoix.Text -eq "Ciseau") {$playerMove = "Scissors"
$computerMove = Get-Random "Rock","Paper" ,"Scissors"}
Then after the computer move is chosen i got this code going on
switch ($computerMove)
{
"Rock" { #The computer picked rock)
if ($playerMove -eq "Rock") {
$noTied += 1 #Increment count by 1
$percentageTied = ($noTied / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage6
}
if ($playerMove -eq "Paper") {
$noWon += 1 #Increment count by 1
$percentageWon = ($noWon / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage3
}
if ($playerMove -eq "Scissors") {
$noLost += 1 #Increment count by 1
$percentageLost = ($noLost / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage4
}
}
"Paper" { #The computer picked paper
if ($playerMove -eq "Rock") {
$noLost += 1 #Increment count by 1
$percentageLost = ($noLost / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage4
}
if ($playerMove -eq "Paper") {
$noTied += 1 #Increment count by 1
$percentageTied = ($noTied / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage6
}
if ($playerMove -eq "Scissors") {
$noWon += 1 #Increment count by 1
$percentageWon = ($noWon / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage3
}
}
"Scissors" { #The computer picked Scissors
if ($playerMove -eq "Rock") {
$noWon += 1 #Increment count by 1
$percentageWon = ($noWon / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage3
}
if ($playerMove -eq "Paper") {
$noLost += 1 #Increment count by 1
$percentageLost = ($noLost / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage4
}
if ($playerMove -eq "Scissors") {
$noTied += 1 #Increment count by 1
$percentageTied = ($noTied / $noPlayed) * 100
$tabControl.SelectedTab =$TabPage6
}
}
}
Basically I want the $computermove to pick either Rock paper or scissor then i want to change the tab depending on if its a win a lost or a tie (tabpage3 is win 4 is lost and 6 is tie)
Aucun commentaire:
Enregistrer un commentaire