Search in sources :

Example 1 with AGENT_DIVISION

use of fr.guiguilechat.jcelechat.model.sde.npcs.Agent.AGENT_DIVISION in project JCELechat by guiguilechat.

the class MultipleAgentStations method main.

public static void main(String[] args) {
    HashMap<String, StationAgentsSummary> summsHS = new HashMap<>();
    HashMap<String, StationAgentsSummary> summsLS = new HashMap<>();
    HashMap<String, StationAgentsSummary> summsNS = new HashMap<>();
    for (Agent a : Agent.load().values()) {
        if (a.level >= 3 && a.level < 5 && a.type == AGENT_TYPE.Basic && validDivisions.contains(a.division)) {
            SolarSystem solsyst = SolarSystem.load().get(a.system);
            Map<String, StationAgentsSummary> dataholder = null;
            if (solsyst.isHS()) {
                dataholder = summsHS;
            }
            if (solsyst.isLS()) {
                dataholder = summsLS;
            }
            if (solsyst.isNS()) {
                dataholder = summsNS;
            }
            StationAgentsSummary sum = dataholder.get(a.station);
            if (sum == null) {
                sum = new StationAgentsSummary();
                sum.solsyst = SolarSystem.load().get(a.system);
                dataholder.put(a.station, sum);
            }
            switch(a.division) {
                case Distribution:
                    if (a.level == 3) {
                        sum.L3D++;
                    } else {
                        sum.L4D++;
                    }
                    break;
                case Mining:
                    if (a.level == 3) {
                        sum.L3M++;
                    } else {
                        sum.L4M++;
                    }
                    break;
                case Security:
                    if (a.level == 3) {
                        sum.L3S++;
                    } else {
                        sum.L4S++;
                    }
                    break;
                default:
                    throw new UnsupportedOperationException("case not handled " + a.division);
            }
        }
    }
    if (csv) {
        System.out.println("region" + csvSeparator + "constellation" + csvSeparator + "solar system" + csvSeparator + "security status" + csvSeparator + "true sec" + csvSeparator + "station" + csvSeparator + "division" + csvSeparator + "level" + csvSeparator + "number");
    }
    for (HashMap<String, StationAgentsSummary> mmap : Arrays.asList(summsHS, summsLS, summsNS)) {
        String secstatus = mmap == summsHS ? "HS" : mmap == summsLS ? "LS" : "NS";
        if (!csv) {
            System.out.println(secstatus + ":");
        }
        for (AGENT_DIVISION division : validDivisions) {
            for (int level : new int[] { 3, 4 }) {
                if (!csv) {
                    System.out.println("  " + division + " level " + level);
                }
                mmap.entrySet().stream().sorted((e1, e2) -> e1.getKey().compareTo(e2.getKey())).forEach(e -> {
                    StationAgentsSummary val = e.getValue();
                    int nb = val.missions(division, level);
                    if (nb > 1) {
                        if (!csv) {
                            System.out.println("      " + e.getKey() + " : " + nb);
                        } else {
                            System.out.println(val.solsyst.region + csvSeparator + val.solsyst.constellation + csvSeparator + val.solsyst.name + csvSeparator + secstatus + csvSeparator + val.solsyst.truesec + csvSeparator + e.getKey() + csvSeparator + division + csvSeparator + level + csvSeparator + nb);
                        }
                    }
                });
            }
        }
    }
}
Also used : HashSet(java.util.HashSet) Arrays(java.util.Arrays) Map(java.util.Map) Set(java.util.Set) AGENT_DIVISION(fr.guiguilechat.jcelechat.model.sde.npcs.Agent.AGENT_DIVISION) HashMap(java.util.HashMap) Agent(fr.guiguilechat.jcelechat.model.sde.npcs.Agent) SolarSystem(fr.guiguilechat.jcelechat.model.sde.locations.SolarSystem) AGENT_TYPE(fr.guiguilechat.jcelechat.model.sde.npcs.Agent.AGENT_TYPE) Agent(fr.guiguilechat.jcelechat.model.sde.npcs.Agent) HashMap(java.util.HashMap) SolarSystem(fr.guiguilechat.jcelechat.model.sde.locations.SolarSystem) AGENT_DIVISION(fr.guiguilechat.jcelechat.model.sde.npcs.Agent.AGENT_DIVISION)

Aggregations

SolarSystem (fr.guiguilechat.jcelechat.model.sde.locations.SolarSystem)1 Agent (fr.guiguilechat.jcelechat.model.sde.npcs.Agent)1 AGENT_DIVISION (fr.guiguilechat.jcelechat.model.sde.npcs.Agent.AGENT_DIVISION)1 AGENT_TYPE (fr.guiguilechat.jcelechat.model.sde.npcs.Agent.AGENT_TYPE)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Set (java.util.Set)1