diff --git a/GoldWars/GoldWars/Map/MapFactory.swift b/GoldWars/GoldWars/Map/MapFactory.swift index bcddf4d..5664233 100644 --- a/GoldWars/GoldWars/Map/MapFactory.swift +++ b/GoldWars/GoldWars/Map/MapFactory.swift @@ -18,28 +18,13 @@ class MapFactory { var size: CGSize! var entityManager: EntityManager! - static func getNewMapModel() -> MapGenerationModel { - - let noOfCElements = CenterElementProvider.centerElements.count - 1 - - return MapGenerationModel( - numBasesP1: Int.random(in: 1...3), - numBasesP2: Int.random(in: 1...3), - topLeftId: Int.random(in: 0...noOfCElements), - topRightId: Int.random(in: 0...noOfCElements), - bottomLeftId: Int.random(in: 0...noOfCElements), - bottomRightId: Int.random(in: 0...noOfCElements) - ) - - } - required init(scene: SKScene, entityManager: EntityManager) { self.size = scene.size self.entityManager = entityManager } func load() -> MapGenerationModel { - let mapModel = MapFactory.getNewMapModel() + let mapModel = MapGenerationModel.new() load(fromModel: mapModel) return mapModel } diff --git a/GoldWars/GoldWars/Map/MapUtils.swift b/GoldWars/GoldWars/Map/MapUtils.swift index 0c636fc..732c93a 100644 --- a/GoldWars/GoldWars/Map/MapUtils.swift +++ b/GoldWars/GoldWars/Map/MapUtils.swift @@ -34,6 +34,19 @@ struct MapGenerationModel: Codable { let bottomLeftId: Int let bottomRightId: Int + static func new() -> MapGenerationModel { + let noOfCElements = CenterElementProvider.centerElements.count - 1 + + return MapGenerationModel( + numBasesP1: Int.random(in: 1...3), + numBasesP2: Int.random(in: 1...3), + topLeftId: Int.random(in: 0...noOfCElements), + topRightId: Int.random(in: 0...noOfCElements), + bottomLeftId: Int.random(in: 0...noOfCElements), + bottomRightId: Int.random(in: 0...noOfCElements) + ) + } + } class CenterElementProvider {