I'm new to swift and I want to know if I'm doing something wrong or a harder way. I made a simple war game app. Tames of variables aren't correct, I know, but I was doing it quickly and I didn't worry about names of variables in that small project so I named them in English with Polish grammar.
import UIKit
class ViewController: UIViewController {
@IBOutlet weak var LeftCardOutlet: UIImageView!
@IBOutlet weak var RightcardOutlet: UIImageView!
@IBOutlet weak var LeftScoreOutlet: UILabel!
@IBOutlet weak var RightscoreOutlet: UILabel!
var karty = ["card2","card3","card4","card5","card6","card7","card8","card9","card10","jack","queen","king"]
var scoreplayer:Int=0
var CPUscore:Int=0
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
@IBAction func DealClicked(_ sender: UIButton) {
var random1:Int = 0
var random2:Int = 0
random1 = Int(arc4random_uniform(UInt32(12)))
random2 = Int(arc4random_uniform(UInt32(12)))
var im1=UIImage(named:"\(karty[random1])")
var im2=UIImage(named: "\(karty[random2])")
LeftCardOutlet.image=im1
RightcardOutlet.image=im2
if random1>random2 {
scoreplayer+=1
LeftScoreOutlet.text=String(scoreplayer)
}
if random1<random2 {
CPUscore+=1
RightscoreOutlet.text=String(CPUscore)
}
}
}