package Server;

import java.util.*;

public class BuildingRules {
    private static final Map<Integer, Map<Era, Integer>> RULES = new HashMap<>();
    static {
        // 2 players
        Map<Era, Integer> p2 = new EnumMap<>(Era.class);
        p2.put(Era.I, 1);
        p2.put(Era.II, 2);
        p2.put(Era.III, 3);

        // 3 players
        Map<Era, Integer> p3 = new EnumMap<>(Era.class);
        p3.put(Era.I, 2);
        p3.put(Era.II, 2);
        p3.put(Era.III, 4);

        // 4 players
        Map<Era, Integer> p4 = new EnumMap<>(Era.class);
        p4.put(Era.I, 2);
        p4.put(Era.II, 3);
        p4.put(Era.III, 4);

        // 5 players
        Map<Era, Integer> p5 = new EnumMap<>(Era.class);
        p4.put(Era.I, 2);
        p4.put(Era.II, 3);
        p4.put(Era.III, 5);

        // insert into main map
        RULES.put(2, p2);
        RULES.put(3, p3);
        RULES.put(4, p4);
        RULES.put(5, p5);
    }

    public static int getBuildingCards(int players, Era era) {
        Map<Era, Integer> eraMap = RULES.get(players);
        if (eraMap!=null){
            Integer value = eraMap.get(era);
            if (value!=null) return value;
        }

        return 0;
    }
}