<commit_before>//
//  RandGameLevelInfoNode.swift
//  BreakBaloon
//
//  Created by Emil on 30/07/2016.
//  Copyright © 2016 Snowy_1803. All rights reserved.
//

import Foundation
import SpriteKit

class RandGameLevelEndNode: SKNode {
    let level:RandGameLevel
    let replay: SKSpriteNode
    let back: SKSpriteNode
    let next: SKSpriteNode?
    let stars: SKSpriteNode?
    
    init(level: RandGameLevel, scene: RandGameScene, stars: Int, xpBonus: Int = -1) {
        let isBonusLevel = xpBonus > -1
        let successful = scene.points >= Int(level.numberOfBaloons - level.maxMissingBaloonToWin)
        self.level = level
        self.replay = SKSpriteNode(imageNamed: "levelreplay")
        self.back = SKSpriteNode(imageNamed: "levelback")
        if successful {
            self.next = SKSpriteNode(imageNamed: "levelnext")
            self.stars = SKSpriteNode(imageNamed: "levelstars\(stars)")
        } else {
            self.next = nil
            self.stars = nil
        }
        super.init()
        self.zPosition = 1000
        let rect = SKShapeNode(rect: CGRect(x: scene.frame.width / 6, y: scene.frame.height / 6, width: scene.frame.width / 1.5, height: scene.frame.height / 1.5))
        rect.fillColor = SKColor.lightGrayColor()
        addChild(rect)
        let tlevel = SKLabelNode(text: String(format: NSLocalizedString("gameinfo.level", comment: "Level n"), level.index + 1))
        tlevel.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 6 * 5 - 32)
        tlevel.fontSize = 24
        tlevel.fontColor = SKColor.blackColor()
        tlevel.fontName = "Copperplate-Bold"
        addChild(tlevel)
        let tstatus: SKLabelNode
        if isBonusLevel {
            tstatus = SKLabelNode(text: String(format: NSLocalizedString("gameinfo.end.bonus", comment: "Level finished with n xp"), xpBonus))
        } else {
            tstatus = SKLabelNode(text: NSLocalizedString("gameinfo.end.\(successful ? "finished" : "failed")", comment: "Level finished"))
        }
        tstatus.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 6 * 5 - 128)
        tstatus.fontSize = 24
        tstatus.fontColor = successful ? SKColor.greenColor() : SKColor.redColor()
        tstatus.fontName = "Copperplate-Bold"
        addChild(tstatus)
        if !isBonusLevel {
            let tcomplete = SKLabelNode(text: String(format: NSLocalizedString("gameinfo.complete", comment: "complete: n / n"), scene.points, level.numberOfBaloons - level.maxMissingBaloonToWin))
            tcomplete.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 6 * 5 - 160)
            tcomplete.fontSize = 24
            tcomplete.fontColor = SKColor.blackColor()
            tcomplete.fontName = "HelveticaNeue-Bold"
            addChild(tcomplete)
            
            replay.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 12 * 3)
            addChild(replay)
        }
        
        back.position = CGPointMake(scene.frame.width / 2 - 80, scene.frame.height / 12 * 3)
        addChild(back)
        if successful {
            if level.next != nil && level.next!.canPlay() {
                next!.position = CGPointMake(scene.frame.width / 2 + 80, scene.frame.height / 12 * 3)
                next!.runAction(SKAction.repeatActionForever(SKAction.sequence([SKAction.resizeToWidth(80, height: 80, duration: 0.6), SKAction.resizeToWidth(64, height: 64, duration: 0.6)])))
                addChild(next!)
            }
            self.stars!.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 6 * 5 - 224)
            addChild(self.stars!)
        } else if !isBonusLevel {
            replay.runAction(SKAction.repeatActionForever(SKAction.sequence([SKAction.resizeToWidth(80, height: 80, duration: 0.6), SKAction.resizeToWidth(64, height: 64, duration: 0.6)])))
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func click(touch: CGPoint) {
        if back.containsPoint(touch) {
            backToMenu(self.scene!.view!)
        } else if replay.containsPoint(touch) {
            setLevel(level, view: self.scene!.view!)
        } else if next != nil && next!.containsPoint(touch) {
            if level.next != nil {
                setLevel(level.next!, view: self.scene!.view!)
            } else {
                backToMenu(self.scene!.view!)
            }
        }
    }
    
    func backToMenu(view: SKView) {
        let scene = StartScene(size: self.frame.size)
        view.presentScene(scene, transition: SKTransition.flipVerticalWithDuration(NSTimeInterval(1)))
        scene.adjustPosition(false, sizeChange: true)<commit_msg>Fix #1<commit_after>//
//  RandGameLevelInfoNode.swift
//  BreakBaloon
//
//  Created by Emil on 30/07/2016.
//  Copyright © 2016 Snowy_1803. All rights reserved.
//

import Foundation
import SpriteKit

class RandGameLevelEndNode: SKNode {
    let level:RandGameLevel
    let replay: SKSpriteNode
    let back: SKSpriteNode
    let next: SKSpriteNode?
    let stars: SKSpriteNode?
    
    init(level: RandGameLevel, scene: RandGameScene, stars: Int, xpBonus: Int = -1) {
        let isBonusLevel = xpBonus > -1
        let successful = scene.points >= Int(level.numberOfBaloons - level.maxMissingBaloonToWin)
        self.level = level
        self.replay = SKSpriteNode(imageNamed: "levelreplay")
        self.back = SKSpriteNode(imageNamed: "levelback")
        if successful {
            self.next = SKSpriteNode(imageNamed: "levelnext")
            self.stars = SKSpriteNode(imageNamed: "levelstars\(stars)")
        } else {
            self.next = nil
            self.stars = nil
        }
        super.init()
        self.zPosition = 1000
        let rect = SKShapeNode(rect: CGRect(x: scene.frame.width / 6, y: scene.frame.height / 6, width: scene.frame.width / 1.5, height: scene.frame.height / 1.5))
        rect.fillColor = SKColor.lightGrayColor()
        addChild(rect)
        let tlevel = SKLabelNode(text: String(format: NSLocalizedString("gameinfo.level", comment: "Level n"), level.index + 1))
        tlevel.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 6 * 5 - 32)
        tlevel.fontSize = 24
        tlevel.fontColor = SKColor.blackColor()
        tlevel.fontName = "Copperplate-Bold"
        addChild(tlevel)
        let tstatus: SKLabelNode
        if isBonusLevel {
            tstatus = SKLabelNode(text: String(format: NSLocalizedString("gameinfo.end.bonus", comment: "Level finished with n xp"), xpBonus))
        } else {
            tstatus = SKLabelNode(text: NSLocalizedString("gameinfo.end.\(successful ? "finished" : "failed")", comment: "Level finished"))
        }
        tstatus.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 6 * 5 - 128)
        tstatus.fontSize = 24
        tstatus.fontColor = successful ? SKColor.greenColor() : SKColor.redColor()
        tstatus.fontName = "Copperplate-Bold"
        addChild(tstatus)
        if !isBonusLevel {
            let tcomplete = SKLabelNode(text: String(format: NSLocalizedString("gameinfo.complete", comment: "complete: n / n"), scene.points, level.numberOfBaloons - level.maxMissingBaloonToWin))
            tcomplete.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 6 * 5 - 160)
            tcomplete.fontSize = 24
            tcomplete.fontColor = SKColor.blackColor()
            tcomplete.fontName = "HelveticaNeue-Bold"
            addChild(tcomplete)
            
            replay.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 12 * 3)
            addChild(replay)
        }
        
        back.position = CGPointMake(scene.frame.width / 2 - 80, scene.frame.height / 12 * 3)
        addChild(back)
        if successful {
            if level.next != nil && level.next!.canPlay() {
                next!.position = CGPointMake(scene.frame.width / 2 + 80, scene.frame.height / 12 * 3)
                next!.runAction(SKAction.repeatActionForever(SKAction.sequence([SKAction.resizeToWidth(80, height: 80, duration: 0.6), SKAction.resizeToWidth(64, height: 64, duration: 0.6)])))
                addChild(next!)
            }
            self.stars!.position = CGPointMake(scene.frame.width / 2, scene.frame.height / 6 * 5 - 224)
            addChild(self.stars!)
        } else if !isBonusLevel {
            replay.runAction(SKAction.repeatActionForever(SKAction.sequence([SKAction.resizeToWidth(80, height: 80, duration: 0.6), SKAction.resizeToWidth(64, height: 64, duration: 0.6)])))
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    func click(touch: CGPoint) {
        if back.containsPoint(touch) {
            backToMenu(self.scene!.view!)
        } else if replay.containsPoint(touch) {
            setLevel(level, view: self.scene!.view!)
        } else if next != nil && next!.containsPoint(touch) {
            if level.next != nil {
                setLevel(level.next!, view: self.scene!.view!)
            } else {
                backToMenu(self.scene!.view!)
            }
        }
    }
    
    func backToMenu(view: SKView) {
        let scene = StartScene(size: self.scene!.frame.size)
        view.presentScene(scene, transition: SKTransition.flipVerticalWithDuration(NSTimeInterval(1)))
        scene.adjustPosition(false, sizeChange: true)
{'fraction_non_alphanumeric': 0.11750422297297297, 'fraction_numerical': 0.02100929054054054, 'mean_word_length': 2.391693519513068, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '7542382', 'n_tokens_mistral': 3072, 'n_tokens_neox': 2861, 'n_words': 592}