# -*- coding: utf-8 -*-


class AirportConfig(object):
    def __init__(self, airport):
        self.airport = airport
        self.planes_config = planes_config_factory(
            self.airport.planes_capacity)
        self.staff_config = staff_config_factory(self.airport.planes_capacity)
        self.resources_config = ResourcesConfig(
            self.airport, self.planes_config)


class PlanesConfig(object):
    def __init__(self, commercials_nb=0, jets_nb=0, supersonics_nb=0):
        self.commercials_nb = commercials_nb
        self.jets_nb = jets_nb
        self.supersonics_nb = supersonics_nb


def planes_config_factory(airport_capacity):
    return {
        3: PlanesConfig(supersonics_nb=3),
        9: PlanesConfig(supersonics_nb=9),
        18: PlanesConfig(supersonics_nb=18),
        27: PlanesConfig(supersonics_nb=27),
        36: PlanesConfig(supersonics_nb=36),
        54: PlanesConfig(supersonics_nb=54),
        84: PlanesConfig(supersonics_nb=84),
        114: PlanesConfig(supersonics_nb=108, jets_nb=6),
        200: PlanesConfig(supersonics_nb=108, jets_nb=92),
    }[airport_capacity]


class StaffConfig(object):
    def __init__(self, pilots_nb, flight_attendants_nb, mechanics_nb):
        self.pilots_nb = pilots_nb
        self.flight_attendants_nb = flight_attendants_nb
        self.mechanics_nb = mechanics_nb
        # TODO calculate automatically radar watcher and security guys


def staff_config_factory(airport_capacity):
    """ should be improved, and be variable of supersonic nb and jets nb """
    return {
        3: StaffConfig(pilots_nb=6, flight_attendants_nb=8, mechanics_nb=8),
        9: StaffConfig(pilots_nb=20, flight_attendants_nb=16, mechanics_nb=16),
        18: StaffConfig(pilots_nb=42, flight_attendants_nb=25, mechanics_nb=16),
        27: StaffConfig(pilots_nb=20, flight_attendants_nb=16, mechanics_nb=16),
        36: StaffConfig(pilots_nb=100, flight_attendants_nb=56, mechanics_nb=32),
        54: StaffConfig(pilots_nb=85, flight_attendants_nb=56, mechanics_nb=32),
        84: StaffConfig(pilots_nb=250, flight_attendants_nb=120, mechanics_nb=40),
        114: StaffConfig(pilots_nb=285, flight_attendants_nb=175, mechanics_nb=60),
        200: StaffConfig(pilots_nb=520, flight_attendants_nb=315, mechanics_nb=200),
    }[airport_capacity]


class ResourcesConfig(object):
    def __init__(self, airport, planes_config):
        # self.kerosene = airport_config.jets_nb * 10000 + airport_config.supersonics_nb * 100000
        # multiple of the airport capacity
        self.kerosene = {
            'min': 0.7 * airport.kerosene_capacity,
            'max': 1 * airport.kerosene_capacity
        }
        self.engines_5_nb = {
            'min': 3 * planes_config.jets_nb / 4,
            'max': 3 * planes_config.jets_nb / 2
        }
        self.engines_6_nb = {
            'min': 4 * planes_config.supersonics_nb / 10,
            'max': 4 * planes_config.supersonics_nb / 7
        }

@@ -1541,16 +1541,81 @@
  nb %22%22%22%0A
+    # supersonics only: 3 pilots & 2 flight attendants per plane%0A
     retu
@@ -1652,17 +1652,17 @@
 lots_nb=
-6
+9
 , flight
@@ -1676,17 +1676,17 @@
 ants_nb=
-8
+6
 , mechan
@@ -1722,33 +1722,33 @@
 nfig(pilots_nb=2
-0
+7
 , flight_attenda
@@ -1747,33 +1747,33 @@
 _attendants_nb=1
-6
+8
 , mechanics_nb=1
@@ -1814,10 +1814,10 @@
 _nb=
+5
 4
-2
 , fl
@@ -1835,18 +1835,18 @@
 ants_nb=
-25
+38
 , mechan
@@ -1891,18 +1891,18 @@
 lots_nb=
-20
+71
 , flight
@@ -1916,18 +1916,18 @@
 ants_nb=
-1
 6
+0
 , mechan
@@ -1974,17 +1974,17 @@
 ts_nb=10
-0
+8
 , flight
@@ -1990,34 +1990,34 @@
 t_attendants_nb=
-56
+72
 , mechanics_nb=3
@@ -2054,18 +2054,19 @@
 lots_nb=
-85
+162
 , flight
@@ -2084,10 +2084,11 @@
 _nb=
-56
+108
 , me
@@ -2138,17 +2138,17 @@
 ots_nb=2
-5
+0
 0, fligh
@@ -2164,17 +2164,17 @@
 nts_nb=1
-2
+6
 0, mecha
@@ -2226,10 +2226,10 @@
 nb=2
-85
+70
 , fl
@@ -2251,10 +2251,10 @@
 _nb=
+2
 1
-7
 5, m
@@ -2265,17 +2265,17 @@
 nics_nb=
-6
+8
 0),%0A    

Tweak staff configuration