// Path: core/src/com/galvarez/ttw/model/Faction.java
// public enum Faction {
// 
//   MILITARY, ECONOMIC, CULTURAL;
// 
// }
// 
// Path: core/src/com/galvarez/ttw/model/map/Terrain.java
// public enum Terrain {
// 
//   DEEP_WATER("deep water", Color.NAVY, 50, false),
// 
//   SHALLOW_WATER("shallow water", Color.BLUE, 30, false),
// 
//   DESERT("desert", Color.YELLOW, 50, false),
// 
//   PLAIN("plain", Color.GREEN, 10, true),
// 
//   GRASSLAND("grassland", new Color(0, 0.5f, 0, 1), 15, true),
// 
//   FOREST("forest", Color.OLIVE, 30, true),
// 
//   HILLS("hills", Color.ORANGE, 30, true),
// 
//   MOUNTAIN("mountain", Color.MAROON, 50, false),
// 
//   ARCTIC("arctic", Color.WHITE, 100, false);
// 
//   private final Color color;
// 
//   private final int moveCost;
// 
//   private final String desc;
// 
//   private final boolean canStart;
// 
//   private Terrain(String desc, Color color, int moveCost, boolean canStart) {
//     this.desc = desc;
//     this.moveCost = moveCost;
//     this.color = color;
//     this.canStart = canStart;
//   }
// 
//   public Color getColor() {
//     return color;
//   }
// 
//   public boolean moveBlock() {
//     return false;
//   }
// 
//   public boolean canStart() {
//     return canStart;
//   }
// 
//   public int moveCost() {
//     return moveCost;
//   }
// 
//   public int getTexture() {
//     return ordinal();
//   }
// 
//   public String getDesc() {
//     return desc;
//   }
// 
// }


import static java.util.stream.Collectors.toSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.badlogic.gdx.utils.Json;
import com.badlogic.gdx.utils.Json.ReadOnlySerializer;
import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.ObjectFloatMap;
import com.galvarez.ttw.model.Faction;
import com.galvarez.ttw.model.map.Terrain;
package com.galvarez.ttw.model.data;




public final class Discovery {

  public final String name;

  public final Set<Terrain> terrains = EnumSet.noneOf(Terrain.class);

  public final Set<String> groups;

  public final Set<Set<String>> previous;

  public ObjectFloatMap<Faction> factions;

  /**
   * Indexed by effect name, contains the delta for the corresponding variable.
   * Positive numbers are positive modifiers for the discoverer.
   */
  public final Map<String, Object> effects;

  private Discovery(String name, List<List<String>> previous, List<String> groups, List<Terrain> terrains,
      Map<String, Object> effects) {
    this.name = name;
    this.effects = effects != null ? effects : Collections.emptyMap();
    this.previous = previous.stream().filter(l -> !l.isEmpty()).map(l -> set(l)).collect(toSet());
    this.groups = set(groups);
    if (terrains != null)
      this.terrains.addAll(terrains);
  }

  @SuppressWarnings("unchecked")
  private static <T> Set<T> set(List<T> list) {
    if (list == null || list.isEmpty())
      return Collections.emptySet();
    if (list.size() == 1)
      return Collections.singleton(list.get(0));
    else if (list instanceof Set)
// Path: core/src/com/galvarez/ttw/model/Faction.java
// public enum Faction {
// 
//   MILITARY, ECONOMIC, CULTURAL;
// 
// }
// 
// Path: core/src/com/galvarez/ttw/model/map/Terrain.java
// public enum Terrain {
// 
//   DEEP_WATER("deep water", Color.NAVY, 50, false),
// 
//   SHALLOW_WATER("shallow water", Color.BLUE, 30, false),
// 
//   DESERT("desert", Color.YELLOW, 50, false),
// 
//   PLAIN("plain", Color.GREEN, 10, true),
// 
//   GRASSLAND("grassland", new Color(0, 0.5f, 0, 1), 15, true),
// 
//   FOREST("forest", Color.OLIVE, 30, true),
// 
//   HILLS("hills", Color.ORANGE, 30, true),
// 
//   MOUNTAIN("mountain", Color.MAROON, 50, false),
// 
//   ARCTIC("arctic", Color.WHITE, 100, false);
// 
//   private final Color color;
// 
//   private final int moveCost;
// 
//   private final String desc;
// 
//   private final boolean canStart;
// 
//   private Terrain(String desc, Color color, int moveCost, boolean canStart) {
//     this.desc = desc;
//     this.moveCost = moveCost;
//     this.color = color;
//     this.canStart = canStart;
//   }
// 
//   public Color getColor() {
//     return color;
//   }
// 
//   public boolean moveBlock() {
//     return false;
//   }
// 
//   public boolean canStart() {
//     return canStart;
//   }
// 
//   public int moveCost() {
//     return moveCost;
//   }
// 
//   public int getTexture() {
//     return ordinal();
//   }
// 
//   public String getDesc() {
//     return desc;
//   }
// 
// }


// Path: core/src/com/galvarez/ttw/model/data/Discovery.java
import static java.util.stream.Collectors.toSet;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.badlogic.gdx.utils.Json;
import com.badlogic.gdx.utils.Json.ReadOnlySerializer;
import com.badlogic.gdx.utils.JsonValue;
import com.badlogic.gdx.utils.ObjectFloatMap;
import com.galvarez.ttw.model.Faction;
import com.galvarez.ttw.model.map.Terrain;

package com.galvarez.ttw.model.data;




public final class Discovery {

  public final String name;

  public final Set<Terrain> terrains = EnumSet.noneOf(Terrain.class);

  public final Set<String> groups;

  public final Set<Set<String>> previous;

  public ObjectFloatMap<Faction> factions;

  /**
   * Indexed by effect name, contains the delta for the corresponding variable.
   * Positive numbers are positive modifiers for the discoverer.
   */
  public final Map<String, Object> effects;

  private Discovery(String name, List<List<String>> previous, List<String> groups, List<Terrain> terrains,
      Map<String, Object> effects) {
    this.name = name;
    this.effects = effects != null ? effects : Collections.emptyMap();
    this.previous = previous.stream().filter(l -> !l.isEmpty()).map(l -> set(l)).collect(toSet());
    this.groups = set(groups);
    if (terrains != null)
      this.terrains.addAll(terrains);
  }

  @SuppressWarnings("unchecked")
  private static <T> Set<T> set(List<T> list) {
    if (list == null || list.isEmpty())
      return Collections.emptySet();
    if (list.size() == 1)
      return Collections.singleton(list.get(0));
    else if (list instanceof Set)
      return (Set<T>) list;