[O] Remove disabled code and remove smash
This commit is contained in:
@@ -27,11 +27,6 @@ func shakeAction() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func rpsAction(choice: RPS.Choice) -> Bool? {
|
|
||||||
let rps = RPS()
|
|
||||||
return rps.playRPS(you: choice, computer: RPS.randomComputerChoice())
|
|
||||||
}
|
|
||||||
|
|
||||||
// Handles the core logic behind the factoring alarm
|
// Handles the core logic behind the factoring alarm
|
||||||
func factorAction(puzzleQuestionLabel: UILabel) -> [Int] {
|
func factorAction(puzzleQuestionLabel: UILabel) -> [Int] {
|
||||||
let problem = QuadraticProb()
|
let problem = QuadraticProb()
|
||||||
@@ -43,8 +38,3 @@ func factorAction(puzzleQuestionLabel: UILabel) -> [Int] {
|
|||||||
print("Answer: \(answer)")
|
print("Answer: \(answer)")
|
||||||
return answer
|
return answer
|
||||||
}
|
}
|
||||||
|
|
||||||
func smashAction() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -85,8 +85,6 @@ class AlarmActivationViewController: UIViewController
|
|||||||
*/
|
*/
|
||||||
func runAlarm()
|
func runAlarm()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
if let alarm = currentAlarm
|
if let alarm = currentAlarm
|
||||||
{
|
{
|
||||||
switch alarm.wakeMethod.name
|
switch alarm.wakeMethod.name
|
||||||
@@ -94,12 +92,8 @@ class AlarmActivationViewController: UIViewController
|
|||||||
case "Factor":
|
case "Factor":
|
||||||
self.puzzleAnswers = factorAction(puzzleQuestionLabel: puzzleQuestionLabel)
|
self.puzzleAnswers = factorAction(puzzleQuestionLabel: puzzleQuestionLabel)
|
||||||
puzzleView.isHidden = false
|
puzzleView.isHidden = false
|
||||||
case "Smash":
|
|
||||||
print("")
|
|
||||||
case "RPS":
|
case "RPS":
|
||||||
rpsView.isHidden = false
|
rpsView.isHidden = false
|
||||||
//Get Choice here
|
|
||||||
//rpsAction(choice: choice)
|
|
||||||
case "Shake":
|
case "Shake":
|
||||||
shakeView.isHidden = false
|
shakeView.isHidden = false
|
||||||
shakeAction()
|
shakeAction()
|
||||||
@@ -130,8 +124,15 @@ class AlarmActivationViewController: UIViewController
|
|||||||
*/
|
*/
|
||||||
@IBAction func rpsChoice(_ sender: UIButton)
|
@IBAction func rpsChoice(_ sender: UIButton)
|
||||||
{
|
{
|
||||||
if rpsAction(choice: [.rock, .paper, .scissors][sender.tag])! { endAlarm() }
|
let rps = RPS()
|
||||||
else { rpsResult.text = "\(["Paper", "Scissors", "Rock"][sender.tag]): You lost, try again" }
|
if rps.playRPS(you: [.rock, .paper, .scissors][sender.tag], computer: RPS.choices.randomElement()!)
|
||||||
|
{
|
||||||
|
endAlarm()
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rpsResult.text = "\(["Paper", "Scissors", "Rock"][sender.tag]): You lost, try again"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -157,45 +157,26 @@ class QuadraticProb {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RPS {
|
/**
|
||||||
//@IBOutlet weak var resultsLabel: UILabel!
|
Rock paper scissors
|
||||||
|
*/
|
||||||
|
class RPS
|
||||||
|
{
|
||||||
|
static let choices: [Choice] = [.rock, .paper, .scissors]
|
||||||
|
|
||||||
enum Choice: String {
|
enum Choice: String
|
||||||
case rock = "ROCK"
|
{
|
||||||
case paper = "PAPER"
|
case rock = "Rock"
|
||||||
case scissors = "SCISSORS"
|
case paper = "Paper"
|
||||||
|
case scissors = "Scissors"
|
||||||
}
|
}
|
||||||
|
|
||||||
static func randomComputerChoice() -> Choice {
|
func playRPS(you: Choice, computer: Choice) -> Bool
|
||||||
let choices: [Choice] = [.rock, .paper, .scissors]
|
{
|
||||||
return choices[Int.random(in: 0...2)]
|
return you == .rock && computer == .scissors ||
|
||||||
|
you == .paper && computer == .rock ||
|
||||||
|
you == .scissors && computer == .paper
|
||||||
}
|
}
|
||||||
|
|
||||||
func playRPS(you: Choice, computer: Choice) -> Bool? {
|
|
||||||
if you == .rock && computer == .scissors { return true }
|
|
||||||
else if you == .paper && computer == .rock { return true}
|
|
||||||
else if you == .scissors && computer == .paper { return true }
|
|
||||||
else {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
@IBAction func rock(_ sender: UIButton) {
|
|
||||||
let computerChoice = Choice.randomComputerChoice()
|
|
||||||
resultsLabel.text = playRPS(you: .rock, computer: computerChoice)
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func paper(_ sender: UIButton) {
|
|
||||||
let computerChoice = Choice.randomComputerChoice()
|
|
||||||
resultsLabel.text = playRPS(you: .paper, computer: computerChoice)
|
|
||||||
}
|
|
||||||
|
|
||||||
@IBAction func scissors(_ sender: UIButton) {
|
|
||||||
let computerChoice = Choice.randomComputerChoice()
|
|
||||||
resultsLabel.text = playRPS(you: .scissors, computer: computerChoice)
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user