Dim Choice(1 To 3) As String
Dim YourChoice As String
Sub Rock()
Range("C4").Value = "Rock"
YourChoice = "Rock"
PC_Choice
End Sub
Sub Paper()
Range("C4").Value = "Paper"
YourChoice = "Paper"
PC_Choice
End Sub
Sub Scissors()
Range("C4").Value = "Scissors"
YourChoice = "Scissors"
PC_Choice
End Sub
Sub PC_Choice()
Choice(1) = "Rock"
Choice(2) = "Paper"
Choice(3) = "Scissors"
Application.Wait (Now + TimeValue("00:00:01"))
PCChoice = Choice(Int(3 * Rnd + 1))
Range("A4").Value = PCChoice
If PCChoice = "Rock" And YourChoice = "Scissors" Then
Call EditCells("A4", "C4")
ElseIf PCChoice = "Rock" And YourChoice = "Paper" Then
Call EditCells("C4", "A4")
ElseIf PCChoice = "Paper" And YourChoice = "Rock" Then
Call EditCells("A4", "C4")
ElseIf PCChoice = "Paper" And YourChoice = "Scissors" Then
Call EditCells("C4", "A4")
ElseIf PCChoice = "Scissors" And YourChoice = "Paper" Then
Call EditCells("A4", "C4")
ElseIf PCChoice = "Scissors" And YourChoice = "Rock" Then
Call EditCells("C4", "A4")
Else
Application.Wait (Now + TimeValue("00:00:01"))
Range("A4") = ""
Range("C4") = ""
End If
End Sub
Sub EditCells(Winner As String, Loser As String)
Application.Wait (Now + TimeValue("00:00:01"))
Range(Loser).Font.Strikethrough = True
Application.Wait (Now + TimeValue("00:00:01"))
Range(Left(Winner, 1) & "2") = Range(Left(Winner, 1) & "2") + 1
Range(Loser).Font.Strikethrough = False
Range("A4") = ""
Range("C4") = ""
End Sub
Sub ResetGame()
Range("A2") = 0
Range("C2") = 0
End Sub
Hiç yorum yok:
Yorum Gönder