<commit_before>//
//  GameView.swift
//  TicTacToe
//
//  Created by <NAME> on 6/18/15.
//
//

import UIKit

class GameSquareView: UIView {
    
    var gameSquarePos: GameSquarePos
    var player: Player?
    var viewLabel = UILabel()
    weak var delegate: GameView?
    
    init(squarePos: GameSquarePos, player: Player?) {

        self.gameSquarePos = squarePos
        self.player = player
        
        // some sort of default
        super.init(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        
        renderGameSquare()
        updatePlayerSymbol()
        
        // tap recognizer
        let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(GameSquareView.userDidTapGameSquare(_:)))
        self.addGestureRecognizer(tapRecognizer)
    }
    
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func updatePlayerSymbol() {

        let oldValue = viewLabel.text
        
        if let p = player {
            
            if p == .X && oldValue == "" {
                viewLabel.text = Player.X.description
                self.animatePlayerSymbolBeingPlaced()
            } else if p == .X && oldValue == "" {
                viewLabel.text = Player.O.description
                self.animatePlayerSymbolBeingPlaced()
            }
            
        } else {
            // clear label state and hide it<commit_msg>fixed bug w player O comparison<commit_after>//
//  GameView.swift
//  TicTacToe
//
//  Created by <NAME> on 6/18/15.
//
//

import UIKit

class GameSquareView: UIView {
    
    var gameSquarePos: GameSquarePos
    var player: Player?
    var viewLabel = UILabel()
    weak var delegate: GameView?
    
    init(squarePos: GameSquarePos, player: Player?) {

        self.gameSquarePos = squarePos
        self.player = player
        
        // some sort of default
        super.init(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        
        renderGameSquare()
        updatePlayerSymbol()
        
        // tap recognizer
        let tapRecognizer = UITapGestureRecognizer(target: self, action: #selector(GameSquareView.userDidTapGameSquare(_:)))
        self.addGestureRecognizer(tapRecognizer)
    }
    
    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func updatePlayerSymbol() {

        let oldValue = viewLabel.text
        
        if let p = player {
            
            if p == .X && oldValue == "" {
                viewLabel.text = Player.X.description
                self.animatePlayerSymbolBeingPlaced()
            } else if p == .O && oldValue == "" {
                viewLabel.text = Player.O.description
                self.animatePlayerSymbolBeingPlaced()
            }
            
        } else {
            // clear label state and hide it
{'fraction_non_alphanumeric': 0.09730848861283643, 'fraction_numerical': 0.008971704623878536, 'mean_word_length': 1.7928709055876686, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1425998', 'n_tokens_mistral': 896, 'n_tokens_neox': 831, 'n_words': 200}