package com.galvarez.ttw.model.components;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

import com.artemis.Component;
import com.artemis.Entity;
import com.galvarez.ttw.model.DiplomaticSystem.Action;
import com.galvarez.ttw.model.DiplomaticSystem.State;

public final class Diplomacy extends Component {

  public final Map<Entity, State> relations = new HashMap<>();

  public final Map<Entity, Integer> lastChange = new HashMap<>();

  public final Map<Entity, Action> proposals = new HashMap<>();

  public final EnumSet<State> knownStates = EnumSet.of(State.NONE);

  public Diplomacy() {
  }

  public State getRelationWith(Entity other) {
    State state = relations.get(other);
    return state != null ? state : State.NONE;
  }

  public Action getProposalTo(Entity other) {
    Action action = proposals.get(other);
    return action != null ? action : Action.NO_CHANGE;
  }

}

@@ -37,16 +37,44 @@
 nents;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -134,19 +134,70 @@
 va.util.
-Map
+List;%0Aimport java.util.Map;%0Aimport java.util.Map.Entry
 ;%0A%0Aimpor
@@ -988,10 +988,333 @@
 E;%0A  %7D%0A%0A
+  /** Get all empires whose state is the one passed as a parameter. */%0A  public List%3CEntity%3E getEmpires(State state) %7B%0A    List%3CEntity%3E others = new ArrayList%3CEntity%3E();%0A    for (Entry%3CEntity, State%3E e : relations.entrySet()) %7B%0A      if (e.getValue() == state)%0A        others.add(e.getKey());%0A    %7D%0A    return others;%0A  %7D%0A%0A
 %7D%0A

Add helper method to get all the empires we have some relation with.