<commit_before>//
//  RoundRouletteViewController.swift
//  GameOfGames
//
//  Created by <NAME> on 6/1/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

class RoundRouletteViewController: UIViewController {

    @IBOutlet weak var team1Name: UILabel!
    @IBOutlet weak var team2Name: UILabel!
    
    @IBOutlet weak var team1Chance: UILabel!
    @IBOutlet weak var team2Chance: UILabel!
    
    @IBOutlet weak var rolledNumber: UILabel!
    @IBOutlet weak var chosenTeam: UILabel!
    
    @IBOutlet weak var rollButton: UIButton!
    
    let game : Game = Game.getInstance()
    
    var rolled:Bool = false;
    
    var team1Cards:Int = 0;
    var team2Cards:Int = 0;
    var totalCards:Int = 0;
    
    var timer:NSTimer?
    
    var delay:Double = 0.01;
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        alert("It is the end of round \(game.getCurrentRound()-1). It is time to roll to see who drinks the center cup");
        
        self.rolled = false;
        
        team1Name.text = "\(game.getTeamName(1))"
        team2Name.text = "\(game.getTeamName(2))"
        
        //chance that team 1 drinks is proportional to the number of cards team 2 got
        //need the last round version because current it is the next round
        team1Cards = game.getTeamCardsInLastRound(1)
        team2Cards = game.getTeamCardsInLastRound(2)
        
        totalCards = team1Cards+team2Cards;
        
        if (totalCards > 0)
        {
            if (team2Cards > 0)
            {
                let flstring = String(format:"%.2f", 100*Double(team2Cards)/Double(totalCards))
                team1Chance.text = "1-\(team2Cards) (\(flstring)%)"
            }
            else
            {
                //team 2 got no cards, team 1 chance is 0
                team1Chance.text = "0 (0%)"
            }
            
            if (team1Cards > 0)
            {
                let flstring = String(format:"%.2f", 100*Double(team1Cards)/Double(totalCards))
                team2Chance.text = "\(team2Cards+1)-\(totalCards) (\(flstring)%)"
            }
            else
            {
                //team 1 got no cards, team 2 chance is 0
                team2Chance.text = "0 (0%)"
            }
            
            rolledNumber.text = ""
            chosenTeam.text = ""
            
            rollButton.setTitle("Roll", forState: .Normal)
        }
        else
        {
            //nobody has won any cards... just go back
            
            team1Chance.text = "0"
            team2Chance.text = "0"
            
            rolledNumber.text = ""
            
            chosenTeam.text = "Nobody has won any cards this round"
            rollButton.setTitle("Continue", forState: .Normal)
            self.rolled = true;
        }
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func timerFire(thisTimer:NSTimer)
    {
        print("delay: \(delay)")
        
        print("timer interval: \(timer!.timeInterval)")
        if (delay > 0.5)
        {
            //done with the rolling
            let rand = Int(arc4random_uniform(UInt32(totalCards)))+1
            rolledNumber.text = "\(rand)";
            rollButton.hidden = false;
            rollButton.setTitle("Continue", forState: .Normal)
            if (rand <= team2Cards)
            {
                chosenTeam.text = game.getTeamName(1)
            }
            else
            {
                chosenTeam.text = game.getTeamName(2);
            }

        }
        else
        {
            
            let rand = Int(arc4random_uniform(UInt32(totalCards)))+1
            rolledNumber.text = "\(rand)";
            
            //update delay rule<commit_msg>made it roll one more time and fixed it showing "Roll" before changing to "Continue"<commit_after>//
//  RoundRouletteViewController.swift
//  GameOfGames
//
//  Created by <NAME> on 6/1/16.
//  Copyright © 2016 <NAME>. All rights reserved.
//

import UIKit

class RoundRouletteViewController: UIViewController {

    @IBOutlet weak var team1Name: UILabel!
    @IBOutlet weak var team2Name: UILabel!
    
    @IBOutlet weak var team1Chance: UILabel!
    @IBOutlet weak var team2Chance: UILabel!
    
    @IBOutlet weak var rolledNumber: UILabel!
    @IBOutlet weak var chosenTeam: UILabel!
    
    @IBOutlet weak var rollButton: UIButton!
    
    let game : Game = Game.getInstance()
    
    var rolled:Bool = false;
    
    var team1Cards:Int = 0;
    var team2Cards:Int = 0;
    var totalCards:Int = 0;
    
    var timer:NSTimer?
    
    var delay:Double = 0.01;
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        alert("It is the end of round \(game.getCurrentRound()-1). It is time to roll to see who drinks the center cup");
        
        self.rolled = false;
        
        team1Name.text = "\(game.getTeamName(1))"
        team2Name.text = "\(game.getTeamName(2))"
        
        //chance that team 1 drinks is proportional to the number of cards team 2 got
        //need the last round version because current it is the next round
        team1Cards = game.getTeamCardsInLastRound(1)
        team2Cards = game.getTeamCardsInLastRound(2)
        
        totalCards = team1Cards+team2Cards;
        
        if (totalCards > 0)
        {
            if (team2Cards > 0)
            {
                let flstring = String(format:"%.2f", 100*Double(team2Cards)/Double(totalCards))
                team1Chance.text = "1-\(team2Cards) (\(flstring)%)"
            }
            else
            {
                //team 2 got no cards, team 1 chance is 0
                team1Chance.text = "0 (0%)"
            }
            
            if (team1Cards > 0)
            {
                let flstring = String(format:"%.2f", 100*Double(team1Cards)/Double(totalCards))
                team2Chance.text = "\(team2Cards+1)-\(totalCards) (\(flstring)%)"
            }
            else
            {
                //team 1 got no cards, team 2 chance is 0
                team2Chance.text = "0 (0%)"
            }
            
            rolledNumber.text = ""
            chosenTeam.text = ""
            
            rollButton.setTitle("Roll", forState: .Normal)
        }
        else
        {
            //nobody has won any cards... just go back
            
            team1Chance.text = "0"
            team2Chance.text = "0"
            
            rolledNumber.text = ""
            
            chosenTeam.text = "Nobody has won any cards this round"
            rollButton.setTitle("Continue", forState: .Normal)
            self.rolled = true;
        }
        // Do any additional setup after loading the view.
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    
    func timerFire(thisTimer:NSTimer)
    {
        //print("\(delay)")
        
        //print("timer interval: \(timer!.timeInterval)")
        if (delay > 0.75)
        {
            //done with the rolling
            let rand = Int(arc4random_uniform(UInt32(totalCards)))+1
            rolledNumber.text = "\(rand)";
            rollButton.setTitle("Continue", forState: .Normal)
            rollButton.hidden = false;
            if (rand <= team2Cards)
            {
                chosenTeam.text = game.getTeamName(1)
            }
            else
            {
                chosenTeam.text = game.getTeamName(2);
            }

        }
        else
        {
            
            let rand = Int(arc4random_uniform(UInt32(totalCards)))+1
            rolledNumber.text = "\(rand)";
            
            //update delay rule
{'fraction_non_alphanumeric': 0.09981024667931689, 'fraction_numerical': 0.021125869702719798, 'mean_word_length': 1.5162316995544238, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 15, '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': '5207525', 'n_tokens_mistral': 2399, 'n_tokens_neox': 2294, 'n_words': 576}