//
//  MapFactory.swift
//  GoldWars
//
//  Created by Marcel Schwarz on 02.05.20.
//  Copyright © 2020 SP2. All rights reserved.
//

import Foundation
import SpriteKit

class MapFactory {
    
    var twoPlayerMaps: [MapProtocol]!
    var threePlayerMaps: [MapProtocol]!
    var fourPlayerMaps: [MapProtocol]!
    
    init(scene: SKScene, entityManager: EntityManager) {
        self.twoPlayerMaps = [
            TwoPlayerDefaultTestMap(scene: scene, entityManager: entityManager)
        ]
        
        self.threePlayerMaps = [MapProtocol]()
        self.fourPlayerMaps = [MapProtocol]()
    }
    
    func loadMap(playerCount: Int) {
        if playerCount == 2 {
            twoPlayerMaps.randomElement()?.load()
        } else if playerCount == 3 {
            threePlayerMaps.randomElement()?.load()
        } else {
            fourPlayerMaps.randomElement()?.load()
        }
    }
}
