[O] Combine RPS choice into one function

This commit is contained in:
Hykilpikonna
2021-01-27 17:45:13 -05:00
parent bd5b5704d1
commit 75c9ef4a85
2 changed files with 10 additions and 26 deletions
@@ -132,26 +132,10 @@ class AlarmActivationViewController: UIViewController
/**
Gets RPS choice
*/
@IBAction func rockChoice(_ sender: Any) {
if rpsAction(choice: .rock)! {
endAlarm()
} else {
rpsResult.text = "Paper: You lost, try again"
}
}
@IBAction func paperChoice(_ sender: Any) {
if rpsAction(choice: .paper)! {
endAlarm()
} else {
rpsResult.text = "Scissors: You lost, try again"
}
}
@IBAction func scissorChoice(_ sender: Any) {
if rpsAction(choice: .scissors)! {
endAlarm()
} else {
rpsResult.text = "Rock: You lost, try again"
}
@IBAction func rpsChoice(_ sender: UIButton)
{
if rpsAction(choice: [.rock, .paper, .scissors][sender.tag])! { endAlarm() }
else { rpsResult.text = "\(["Paper", "Scissors", "Rock"][sender.tag]): You lost, try again" }
}
/**