<commit_before>//
//  Fleet.swift
//  LD33
//
//  Created by <NAME> on 8/23/15.
//  Copyright © 2015 MikeDave. All rights reserved.
//

import SpriteKit

enum FleetPatternOrder {
    case Normal
    case Inverse
    case Mixed
}

protocol FleetDelegate {
    func didFinish()
}

class Fleet {
    
    let type: EnemyType
    let count: Int
    var aliveCount: Int
    private weak var scene: SKScene?
    let patternOrder: FleetPatternOrder
    let delegate: FleetDelegate?
    
    deinit {
        if let delegate = delegate {
            delegate.didFinish()
        }
    }
    
    init(type: EnemyType, count: Int, scene: SKScene?, patternOrder: FleetPatternOrder, delegate: FleetDelegate?) {
        self.type = type
        self.count = count
        self.scene = scene
        self.patternOrder = patternOrder
        self.delegate = delegate

        self.aliveCount = count
    }
    
    func attack() {
        guard let scene = scene else { return }
        
        let enemies = createEnemies()
        let paths = actionPaths(scene.size)
        let actions = enemyActions(paths)

        for (enemy, action) in zip(enemies, actions) {
            scene.addChild(enemy)
            enemy.runAction(action)
        }
    }
    
    func createPath(sceneSize: CGSize) -> CGPath {
        switch type {
        case .A:
            let start = CGPoint(x: sceneSize.width + 200, y: 200)
            let center = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
            let end = CGPoint(x: -200, y: sceneSize.height - 200)

            let bezierPath = UIBezierPath()
            bezierPath.moveToPoint(start)
            bezierPath.addCurveToPoint(center, controlPoint1: CGPointMake(start.x, start.y), controlPoint2: CGPointMake(center.x, start.y))
            bezierPath.addCurveToPoint(end, controlPoint1: CGPointMake(center.x, end.y), controlPoint2: CGPointMake(end.x, end.y))

            return bezierPath.CGPath
        case .B:
            let start = CGPoint(x: sceneSize.width + 100, y: 0)
            let center = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
            let end = CGPoint(x: -100, y: sceneSize.height)
            
            let bezierPath = UIBezierPath()
            bezierPath.moveToPoint(start)
            bezierPath.addCurveToPoint(center, controlPoint1: start, controlPoint2: CGPointMake(center.x, start.y))
            bezierPath.addCurveToPoint(end, controlPoint1: CGPointMake(center.x, end.y), controlPoint2: start)

            return bezierPath.CGPath
        }
    }
    
    func createInversePath(sceneSize: CGSize) -> CGPath {
        switch type {
        case .A:
            let start = CGPoint(x: sceneSize.width + 200, y: sceneSize.height - 200)
            let center = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
            let end = CGPoint(x: -200, y: 200)

            let bezierPath = UIBezierPath()
            bezierPath.moveToPoint(start)
            bezierPath.addCurveToPoint(center, controlPoint1: CGPointMake(start.x, start.y), controlPoint2: CGPointMake(center.x, start.y))
            bezierPath.addCurveToPoint(end, controlPoint1: CGPointMake(center.x, end.y), controlPoint2: CGPointMake(end.x, end.y))
            
            return bezierPath.CGPath
        case .B:
            let start = CGPoint(x: sceneSize.width + 100, y: sceneSize.height - 100)
            let center = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
            let end = CGPoint(x: -100, y: 100)
            
            let bezierPath = UIBezierPath()
            bezierPath.moveToPoint(start)<commit_msg>update paths<commit_after>//
//  Fleet.swift
//  LD33
//
//  Created by <NAME> on 8/23/15.
//  Copyright © 2015 MikeDave. All rights reserved.
//

import SpriteKit

enum FleetPatternOrder {
    case Normal
    case Inverse
    case Mixed
}

protocol FleetDelegate {
    func didFinish()
}

class Fleet {
    
    let type: EnemyType
    let count: Int
    var aliveCount: Int
    private weak var scene: SKScene?
    let patternOrder: FleetPatternOrder
    let delegate: FleetDelegate?
    
    deinit {
        if let delegate = delegate {
            delegate.didFinish()
        }
    }
    
    init(type: EnemyType, count: Int, scene: SKScene?, patternOrder: FleetPatternOrder, delegate: FleetDelegate?) {
        self.type = type
        self.count = count
        self.scene = scene
        self.patternOrder = patternOrder
        self.delegate = delegate

        self.aliveCount = count
    }
    
    func attack() {
        guard let scene = scene else { return }
        
        let enemies = createEnemies()
        let paths = actionPaths(scene.size)
        let actions = enemyActions(paths)

        for (enemy, action) in zip(enemies, actions) {
            scene.addChild(enemy)
            enemy.runAction(action)
        }
    }
    
    func createPath(sceneSize: CGSize) -> CGPath {
        switch type {
        case .A:
            let start = CGPoint(x: sceneSize.width + 200, y: 200)
            let center = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
            let end = CGPoint(x: -200, y: sceneSize.height - 200)

            let bezierPath = UIBezierPath()
            bezierPath.moveToPoint(start)
            bezierPath.addCurveToPoint(center, controlPoint1: CGPointMake(start.x, start.y), controlPoint2: CGPointMake(center.x, start.y))
            bezierPath.addCurveToPoint(end, controlPoint1: CGPointMake(center.x, end.y), controlPoint2: CGPointMake(end.x, end.y))

            return bezierPath.CGPath
        case .B:
            let start = CGPoint(x: sceneSize.width + 200, y: 200)
            let center = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
            let end = CGPoint(x: -200, y: sceneSize.height - 200)
            
            let bezierPath = UIBezierPath()
            bezierPath.moveToPoint(start)
            bezierPath.addCurveToPoint(center, controlPoint1: start, controlPoint2: CGPointMake(center.x, start.y))
            bezierPath.addCurveToPoint(end, controlPoint1: CGPointMake(center.x, end.y), controlPoint2: start)

            return bezierPath.CGPath
        }
    }
    
    func createInversePath(sceneSize: CGSize) -> CGPath {
        switch type {
        case .A:
            let start = CGPoint(x: sceneSize.width + 200, y: sceneSize.height - 200)
            let center = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
            let end = CGPoint(x: -200, y: 200)

            let bezierPath = UIBezierPath()
            bezierPath.moveToPoint(start)
            bezierPath.addCurveToPoint(center, controlPoint1: CGPointMake(start.x, start.y), controlPoint2: CGPointMake(center.x, start.y))
            bezierPath.addCurveToPoint(end, controlPoint1: CGPointMake(center.x, end.y), controlPoint2: CGPointMake(end.x, end.y))
            
            return bezierPath.CGPath
        case .B:
            let start = CGPoint(x: sceneSize.width + 200, y: sceneSize.height - 200)
            let center = CGPoint(x: sceneSize.width / 2, y: sceneSize.height / 2)
            let end = CGPoint(x: -200, y: 200)
            
            let bezierPath = UIBezierPath()
            bezierPath.moveToPoint(start)
{'fraction_non_alphanumeric': 0.09885248168118346, 'fraction_numerical': 0.021153048527581916, 'mean_word_length': 2.098072805139186, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '4853062', 'n_tokens_mistral': 2379, 'n_tokens_neox': 2194, 'n_words': 547}