<commit_before>//
//  ViewController.swift
//  chapter4
//
//  Created by 森崎雅之 on 2016/01/30.
//  Copyright © 2016年 <NAME>. All rights reserved.
//

import UIKit
import GameplayKit

class ViewController: UIViewController {

    let randomSource = GKRandomSource()
    
    @IBOutlet weak var computerImageView: UIImageView!
    @IBOutlet weak var playerImageView: UIImageView!
    @IBOutlet weak var messageLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        let angle:CGFloat = CGFloat(M_PI) // ラジアン180度
        computerImageView.transform = CGAffineTransformMakeRotation(angle) // ラジアンだけ回転
    }

    @IBAction func tapStart() {
        
        // 両者グー表示
        computerImageView.image = UIImage(named: "goo.png")
        playerImageView.image = UIImage(named: "goo.png")
        
        messageLabel.text = "じゃんけんするYO!!"
    }
    
    @IBAction func tapGoo() {
        playerImageView.image = UIImage(named: "goo.png")
        doComputer()
    }
    
    @IBAction func tapChoki() {
        playerImageView.image = UIImage(named: "choki.png")
        doComputer()
    }
    
    @IBAction func tapPaa() {
        playerImageView.image = UIImage(named: "paa.png")
        doComputer()
    }
    
    func doComputer() {
        // computer playing method.
        let computer = randomSource.nextIntWithUpperBound(3)
        switch computer {
        case 0:
            computerImageView.image = UIImage(named: "goo.png")
        case 1:
            computerImageView.image = UIImage(named: "choki.png")
        case 2:
            computerImageView.image = UIImage(named: "paa.png")
        default:
            break
        }
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}<commit_msg>じゃんけんの判定をして結果を表示する<commit_after>//
//  ViewController.swift
//  chapter4
//
//  Created by 森崎雅之 on 2016/01/30.
//  Copyright © 2016年 <NAME>. All rights reserved.
//

import UIKit
import GameplayKit

class ViewController: UIViewController {

    let randomSource = GKRandomSource()
    
    @IBOutlet weak var computerImageView: UIImageView!
    @IBOutlet weak var playerImageView: UIImageView!
    @IBOutlet weak var messageLabel: UILabel!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        
        let angle:CGFloat = CGFloat(M_PI) // ラジアン180度
        computerImageView.transform = CGAffineTransformMakeRotation(angle) // ラジアンだけ回転
    }

    @IBAction func tapStart() {
        
        // 両者グー表示
        computerImageView.image = UIImage(named: "goo.png")
        playerImageView.image = UIImage(named: "goo.png")
        
        messageLabel.text = "じゃんけんするYO!!"
    }
    
    @IBAction func tapGoo() {
        playerImageView.image = UIImage(named: "goo.png")
        let com = doComputer()
        judge(0, computer: com)
    }
    
    @IBAction func tapChoki() {
        playerImageView.image = UIImage(named: "choki.png")
        let com = doComputer()
        judge(1, computer: com)
    }
    
    @IBAction func tapPaa() {
        playerImageView.image = UIImage(named: "paa.png")
        let com = doComputer()
        judge(2, computer: com)
    }
    
    func doComputer() -> Int {
        // computer playing method.
        let computer = randomSource.nextIntWithUpperBound(3)
        switch computer {
        case 0:
            computerImageView.image = UIImage(named: "goo.png")
        case 1:
            computerImageView.image = UIImage(named: "choki.png")
        case 2:
            computerImageView.image = UIImage(named: "paa.png")
        default:
            break
        }
        
        return computer
    }
    
    func judge(player: Int, computer: Int) {
        if (player == computer) {
            messageLabel.text = "あいこ。"
        } else if (player == 0 && computer == 1
                || player == 1 && computer == 2
                || player == 2 && computer == 0) {
            messageLabel.text = "勝ち!!やったNe!!"
        } else {
            messageLabel.text = "負け... クソが。"
        }
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

}
{'fraction_non_alphanumeric': 0.10255834829443447, 'fraction_numerical': 0.01099640933572711, 'mean_word_length': 2.0155615696887685, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6933290', 'n_tokens_mistral': 1445, 'n_tokens_neox': 1363, 'n_words': 318}