Refactored Powers, moved packages, addded CastedPower
This commit is contained in:
parent
acab58d0a3
commit
6410de196f
@ -7,8 +7,10 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Identified;
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
|
|
||||||
public class Utils {
|
public class Utils {
|
||||||
|
|
||||||
@ -25,6 +27,12 @@ public class Utils {
|
|||||||
public static final <T extends Identified> T getIdentified(Set<T> set, String id) {
|
public static final <T extends Identified> T getIdentified(Set<T> set, String id) {
|
||||||
return set.stream().filter(x -> x.getId().equals(id)).findAny().orElse(null);
|
return set.stream().filter(x -> x.getId().equals(id)).findAny().orElse(null);
|
||||||
}
|
}
|
||||||
|
public static final <T extends Identified> T throwingGetIdentified(String type, Set<T> set,String id){
|
||||||
|
if(id == null)return null;
|
||||||
|
T out = Utils.getIdentified(set, id);
|
||||||
|
if(out==null) throw new IllegalArgumentException("Could not find "+type+" of id "+id);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
public static final <E extends Enum<E>> EnumSet<E> toEnumSet(Class<E> c,Set<E> set){
|
public static final <E extends Enum<E>> EnumSet<E> toEnumSet(Class<E> c,Set<E> set){
|
||||||
if(set.isEmpty())
|
if(set.isEmpty())
|
||||||
@ -32,6 +40,12 @@ public class Utils {
|
|||||||
else
|
else
|
||||||
return EnumSet.copyOf(set);
|
return EnumSet.copyOf(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final <K,E,F> Map<K,F> mapValue(Map<K,E> map,Function<E,F> f){
|
||||||
|
return map.keySet().stream().collect(Collectors.toMap(
|
||||||
|
Function.identity(),
|
||||||
|
k -> f.apply(map.get(k))));
|
||||||
|
}
|
||||||
|
|
||||||
public static final <T> Map<T,Boolean> setToMap(Set<T> set){
|
public static final <T> Map<T,Boolean> setToMap(Set<T> set){
|
||||||
return new AbstractMap<T,Boolean>() {
|
return new AbstractMap<T,Boolean>() {
|
||||||
|
|||||||
@ -9,19 +9,22 @@ import java.util.function.Function;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
import com.bernard.greposimu.Utils;
|
import com.bernard.greposimu.Utils;
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
|
||||||
import com.bernard.greposimu.model.game.powers.FuryPower;
|
import com.bernard.greposimu.model.game.powers.FuryPower;
|
||||||
import com.bernard.greposimu.model.game.powers.GodPower;
|
import com.bernard.greposimu.model.game.powers.GodPower;
|
||||||
import com.bernard.greposimu.model.game.powers.MultitypePower;
|
|
||||||
import com.bernard.greposimu.model.game.powers.Power;
|
import com.bernard.greposimu.model.game.powers.Power;
|
||||||
|
import com.bernard.greposimu.model.game.powers.Power.AreaOfEffect;
|
||||||
|
import com.bernard.greposimu.model.game.powers.Power.Effect;
|
||||||
|
import com.bernard.greposimu.model.game.powers.Power.Target;
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
import com.bernard.greposimu.model.game.units.FightType;
|
import com.bernard.greposimu.model.game.units.FightType;
|
||||||
import com.bernard.greposimu.model.game.units.Hero;
|
import com.bernard.greposimu.model.game.units.Hero;
|
||||||
import com.bernard.greposimu.model.game.units.Hero.HeroCategory;
|
import com.bernard.greposimu.model.game.units.Hero.HeroCategory;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
import com.bernard.greposimu.model.game.units.NavalUnit;
|
import com.bernard.greposimu.model.game.units.NavalUnit;
|
||||||
import com.bernard.greposimu.model.game.units.TerrestrialUnit;
|
import com.bernard.greposimu.model.game.units.TerrestrialUnit;
|
||||||
import com.bernard.greposimu.model.game.units.TransportUnit;
|
import com.bernard.greposimu.model.game.units.TransportUnit;
|
||||||
@ -42,111 +45,61 @@ public class JSONReader {
|
|||||||
for(String p : powersJ.keySet()) {
|
for(String p : powersJ.keySet()) {
|
||||||
JSONObject power = powersJ.getJSONObject(p);
|
JSONObject power = powersJ.getJSONObject(p);
|
||||||
JSONObject metadefaults = power.isNull("meta_defaults")?null:power.getJSONObject("meta_defaults");
|
JSONObject metadefaults = power.isNull("meta_defaults")?null:power.getJSONObject("meta_defaults");
|
||||||
if(power.isNull("god_id") || power.getString("god_id").isEmpty()) {
|
String id = power.getString("id");
|
||||||
// DETECTING TYPE DEPEDENCY
|
EnumSet<Target> targets = Utils.toEnumSet(Power.Target.class,power.getJSONArray("targets").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet()));
|
||||||
boolean dependent =
|
EnumSet<Target> seedsTo = Utils.toEnumSet(Power.Target.class,power.getJSONArray("seeds_to").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet()));
|
||||||
power.optJSONObject("name")!=null ||
|
|
||||||
|
String shortEffect = power.isNull("short_effect")?null:power.getString("short_effect");
|
||||||
|
Power.Group powerGroup = getPowerGroup(power.getString("power_group"));
|
||||||
|
int powerGroupLevel = power.getInt("power_group_level");
|
||||||
|
|
||||||
|
//name
|
||||||
|
Set<String> metaFields = power.getJSONArray("meta_fields").toList().stream().map(v -> (String)v).collect(Collectors.toSet());
|
||||||
|
Map<String,Object> metaDefaults = metadefaults==null?Map.of():metadefaults.toMap();
|
||||||
|
|
||||||
|
|
||||||
|
int lifetime = power.getInt("lifetime");
|
||||||
|
|
||||||
|
EnumSet<Power.Tag> tags = getPowerTags(power);
|
||||||
|
EnumSet<Effect> effects = Utils.toEnumSet(Power.Effect.class,power.getJSONArray("effects").toList().stream().map(k -> getPowerEffect((String)k)).collect(Collectors.toSet()));
|
||||||
|
Set<String> compatiblePowers = power.isNull("compatible_powers")?Set.of():power.getJSONArray("compatible_powers").toList().stream().map(v -> (String)v).collect(Collectors.toSet());
|
||||||
|
EnumSet<AreaOfEffect> areaOfEffect = Utils.toEnumSet(Power.AreaOfEffect.class,power.getJSONArray("area_of_effect").toList().stream().map(k -> getPowerAOE((String)k)).collect(Collectors.toSet()));
|
||||||
|
|
||||||
|
boolean dependent =
|
||||||
|
power.optJSONObject("name")!=null ||
|
||||||
power.optJSONObject("effect")!=null ||
|
power.optJSONObject("effect")!=null ||
|
||||||
power.optJSONObject("description")!=null;
|
power.optJSONObject("description")!=null;
|
||||||
String dependentKind = dependent?
|
String configType = dependent?
|
||||||
(metadefaults != null && metadefaults.has("type"))?"type":
|
(metadefaults != null && metadefaults.has("type"))?"type":
|
||||||
(metadefaults != null && metadefaults.has("god"))?"god":"unknown"
|
(metadefaults != null && metadefaults.has("god"))?"god":"unknown"
|
||||||
:null;
|
:null;
|
||||||
|
|
||||||
if(dependent) {
|
// for each X, either X or XM should be null. if one XM is not null, configType should be set
|
||||||
Set<String> kinds =
|
String name = (power.optJSONObject("name")==null)?power.optString("name"):null;
|
||||||
Optional.ofNullable(power.optJSONObject("name"))
|
String effect = (power.optJSONObject("effect")==null)?power.optString("effect"):null;
|
||||||
.orElseGet(() -> Optional.ofNullable(power.optJSONObject("effect"))
|
String description = (power.optJSONObject("description")==null)?power.optString("description"):null;
|
||||||
.orElseGet(() -> power.optJSONObject("description"))
|
|
||||||
).getJSONObject(dependentKind).keySet();
|
Map<String,String> nameM = (name==null)?Utils.mapValue(power.getJSONObject("name").getJSONObject(configType).toMap(),v -> (String)v):null;
|
||||||
for(String kind : kinds){
|
Map<String,String> effectM = (effect==null)?Utils.mapValue(power.getJSONObject("effect").getJSONObject(configType).toMap(),v -> (String)v):null;
|
||||||
powers.add(new MultitypePower(
|
Map<String,String> descriptionM = (description==null)?Utils.mapValue(power.getJSONObject("description").getJSONObject(configType).toMap(),v -> (String)v):null;
|
||||||
power.getString("id")+":"+kind,
|
|
||||||
Optional.ofNullable(power.optString("name")).orElseGet(() -> power.getJSONObject("name").getJSONObject(dependentKind).getString(kind)),
|
if(!power.isNull("god_id") && !power.getString("god_id").isEmpty()) {
|
||||||
Optional.ofNullable(power.optString("description")).orElseGet(() -> power.getJSONObject("description").getJSONObject(dependentKind).getString(kind)),
|
God god = gods.stream().filter(g -> g.getId().equals(power.getString("god_id"))).findAny().get();
|
||||||
power.isNull("short_effect")?null:power.getString("short_effect"),
|
int favorCost = power.getInt("favor");
|
||||||
Optional.ofNullable(power.optString("effect")).orElseGet(() -> power.getJSONObject("effect").getJSONObject(dependentKind).getString(kind)),
|
int templeLevelSumDepedency = power.isNull("temple_level_sum_dependency")?0:power.getInt("temple_level_sum_dependency");
|
||||||
Utils.toEnumSet(Power.Target.class,power.getJSONArray("targets").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet())),
|
|
||||||
Utils.toEnumSet(Power.Target.class,power.getJSONArray("seeds_to").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet())),
|
if(power.getInt("fury_percentage_cost") != 0) {
|
||||||
getPowerGroup(power.getString("power_group")),
|
// FuryPower
|
||||||
power.getBoolean("negative"),
|
int furyPercentageCost = power.getInt("fury_percentage_cost");
|
||||||
power.getInt("power_group_level"),
|
powers.add(new FuryPower(id, targets, seedsTo, shortEffect, powerGroup, powerGroupLevel, metaFields, metaDefaults, lifetime, effects, tags, compatiblePowers, areaOfEffect, name, effect, description, configType, nameM, effectM, descriptionM,
|
||||||
Utils.toEnumSet(Power.Effect.class,power.getJSONArray("effects").toList().stream().map(k -> getPowerEffect((String)k)).collect(Collectors.toSet())),
|
god, favorCost, templeLevelSumDepedency, furyPercentageCost));
|
||||||
power.getBoolean("ignores_democritus"),
|
} else {
|
||||||
Utils.toEnumSet(Power.AreaOfEffect.class,power.getJSONArray("area_of_effect").toList().stream().map(k -> getPowerAOE((String)k)).collect(Collectors.toSet())),
|
// GodPower
|
||||||
getPowerTags(power),
|
powers.add(new GodPower(id, targets, seedsTo, shortEffect, powerGroup, powerGroupLevel, metaFields, metaDefaults, lifetime, effects, tags, compatiblePowers, areaOfEffect, name, effect, description, configType, nameM, effectM, descriptionM, god, favorCost, templeLevelSumDepedency));
|
||||||
power.getInt("lifetime"),
|
}
|
||||||
metadefaults==null?Map.of():metadefaults.toMap(),
|
} else {
|
||||||
power.getString("id")
|
powers.add(new Power(id, targets, seedsTo, shortEffect, powerGroup, powerGroupLevel, metaFields, metaDefaults, lifetime, effects, tags, compatiblePowers, areaOfEffect, name, effect, description, configType, nameM, effectM, descriptionM));
|
||||||
));
|
}
|
||||||
}
|
|
||||||
}else {
|
|
||||||
powers.add(new Power(
|
|
||||||
power.getString("id"),
|
|
||||||
power.getString("name"),
|
|
||||||
power.getString("description"),
|
|
||||||
power.isNull("short_effect")?null:power.getString("short_effect"),
|
|
||||||
power.getString("effect"),
|
|
||||||
Utils.toEnumSet(Power.Target.class,power.getJSONArray("targets").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet())),
|
|
||||||
Utils.toEnumSet(Power.Target.class,power.getJSONArray("seeds_to").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet())),
|
|
||||||
getPowerGroup(power.getString("power_group")),
|
|
||||||
power.getBoolean("negative"),
|
|
||||||
power.getInt("power_group_level"),
|
|
||||||
Utils.toEnumSet(Power.Effect.class,power.getJSONArray("effects").toList().stream().map(k -> getPowerEffect((String)k)).collect(Collectors.toSet())),
|
|
||||||
power.getBoolean("ignores_democritus"),
|
|
||||||
Utils.toEnumSet(Power.AreaOfEffect.class,power.getJSONArray("area_of_effect").toList().stream().map(k -> getPowerAOE((String)k)).collect(Collectors.toSet())),
|
|
||||||
getPowerTags(power),
|
|
||||||
power.getInt("lifetime"),
|
|
||||||
metadefaults==null?Map.of():metadefaults.toMap()
|
|
||||||
));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if(power.getInt("fury_percentage_cost") != 0) {
|
|
||||||
powers.add(new FuryPower(
|
|
||||||
power.getString("id"),
|
|
||||||
power.getString("name"),
|
|
||||||
power.getString("description"),
|
|
||||||
power.isNull("short_effect")?null:power.getString("short_effect"),
|
|
||||||
Optional.ofNullable(power.optString("effect")).orElseGet(() -> power.optJSONObject("effect").getString("not_cast")),
|
|
||||||
Utils.toEnumSet(Power.Target.class,power.getJSONArray("targets").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet())),
|
|
||||||
Utils.toEnumSet(Power.Target.class,power.getJSONArray("seeds_to").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet())),
|
|
||||||
getPowerGroup(power.getString("power_group")),
|
|
||||||
power.getBoolean("negative"),
|
|
||||||
power.getInt("power_group_level"),
|
|
||||||
Utils.toEnumSet(Power.Effect.class,power.getJSONArray("effects").toList().stream().map(k -> getPowerEffect((String)k)).collect(Collectors.toSet())),
|
|
||||||
power.getBoolean("ignores_democritus"),
|
|
||||||
Utils.toEnumSet(Power.AreaOfEffect.class,power.getJSONArray("area_of_effect").toList().stream().map(k -> getPowerAOE((String)k)).collect(Collectors.toSet())),
|
|
||||||
getPowerTags(power),
|
|
||||||
power.getInt("lifetime"),
|
|
||||||
metadefaults==null?Map.of():metadefaults.toMap(),
|
|
||||||
power.isNull("god_id")?null:gods.stream().filter(g -> g.getId().equals(power.getString("god_id"))).findAny().get(),
|
|
||||||
power.getInt("favor"),
|
|
||||||
power.isNull("temple_level_sum_dependency")?0:power.getInt("temple_level_sum_dependency"),
|
|
||||||
power.getInt("fury_percentage_cost")/100.0
|
|
||||||
));
|
|
||||||
} else {
|
|
||||||
powers.add(new GodPower(
|
|
||||||
power.getString("id"),
|
|
||||||
power.getString("name"),
|
|
||||||
power.getString("description"),
|
|
||||||
power.isNull("short_effect")?null:power.getString("short_effect"),
|
|
||||||
Optional.ofNullable(power.optString("effect")).orElseGet(() -> power.optJSONObject("effect").getString("not_cast")),
|
|
||||||
Utils.toEnumSet(Power.Target.class,power.getJSONArray("targets").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet())),
|
|
||||||
Utils.toEnumSet(Power.Target.class,power.getJSONArray("seeds_to").toList().stream().map(k -> getPowerTarget((String)k)).collect(Collectors.toSet())),
|
|
||||||
getPowerGroup(power.getString("power_group")),
|
|
||||||
power.getBoolean("negative"),
|
|
||||||
power.getInt("power_group_level"),
|
|
||||||
Utils.toEnumSet(Power.Effect.class,power.getJSONArray("effects").toList().stream().map(k -> getPowerEffect((String)k)).collect(Collectors.toSet())),
|
|
||||||
power.getBoolean("ignores_democritus"),
|
|
||||||
Utils.toEnumSet(Power.AreaOfEffect.class,power.getJSONArray("area_of_effect").toList().stream().map(k -> getPowerAOE((String)k)).collect(Collectors.toSet())),
|
|
||||||
getPowerTags(power),
|
|
||||||
power.getInt("lifetime"),
|
|
||||||
metadefaults==null?Map.of():metadefaults.toMap(),
|
|
||||||
power.isNull("god_id")?null:gods.stream().filter(g -> g.getId().equals(power.getString("god_id"))).findAny().get(),
|
|
||||||
power.getInt("favor"),
|
|
||||||
power.isNull("temple_level_sum_dependency")?0:power.getInt("temple_level_sum_dependency")
|
|
||||||
));}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JSONObject researchesJ = json.getJSONObject("researches");
|
JSONObject researchesJ = json.getJSONObject("researches");
|
||||||
@ -305,8 +258,13 @@ public class JSONReader {
|
|||||||
if(o.getBoolean("removed_on_target_loss"))out.add(Power.Tag.REMOVED_ON_TARGET_LOSS);
|
if(o.getBoolean("removed_on_target_loss"))out.add(Power.Tag.REMOVED_ON_TARGET_LOSS);
|
||||||
if(o.getBoolean("requires_god"))out.add(Power.Tag.REQUIRES_GOD);
|
if(o.getBoolean("requires_god"))out.add(Power.Tag.REQUIRES_GOD);
|
||||||
if(o.getBoolean("no_lifetime"))out.add(Power.Tag.NO_LIFETIME);
|
if(o.getBoolean("no_lifetime"))out.add(Power.Tag.NO_LIFETIME);
|
||||||
|
if(o.getBoolean("only_own_towns"))out.add(Power.Tag.ONLY_OWN_TOWNS);
|
||||||
|
if(o.getBoolean("negative"))out.add(Power.Tag.NEGATIVE);
|
||||||
|
if(o.getBoolean("ignores_democritus"))out.add(Power.Tag.IGNORES_DEMOCRITUS);
|
||||||
|
if(o.getBoolean("boost"))out.add(Power.Tag.BOOST);
|
||||||
return Utils.toEnumSet(Power.Tag.class,out);
|
return Utils.toEnumSet(Power.Tag.class,out);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Power.AreaOfEffect getPowerAOE(String s){
|
private static Power.AreaOfEffect getPowerAOE(String s){
|
||||||
switch(s) {
|
switch(s) {
|
||||||
case "area_of_effect_build_time": return Power.AreaOfEffect.BUILDTIME;
|
case "area_of_effect_build_time": return Power.AreaOfEffect.BUILDTIME;
|
||||||
|
|||||||
@ -17,10 +17,10 @@ import org.springframework.web.bind.annotation.ResponseBody;
|
|||||||
|
|
||||||
import com.bernard.greposimu.GrepoSimuApplication;
|
import com.bernard.greposimu.GrepoSimuApplication;
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.simulator.Ville;
|
|
||||||
import com.bernard.greposimu.model.simulator.command.Command;
|
import com.bernard.greposimu.model.simulator.command.Command;
|
||||||
import com.bernard.greposimu.model.simulator.command.TownCommand;
|
import com.bernard.greposimu.model.simulator.command.TownCommand;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Ville;
|
||||||
import com.bernard.greposimu.model.simulator.objective.TownObjective;
|
import com.bernard.greposimu.model.simulator.objective.TownObjective;
|
||||||
import com.bernard.greposimu.source.JSONSourcer;
|
import com.bernard.greposimu.source.JSONSourcer;
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import com.bernard.greposimu.model.DefContext;
|
|||||||
import com.bernard.greposimu.model.FightStats;
|
import com.bernard.greposimu.model.FightStats;
|
||||||
import com.bernard.greposimu.model.OffContext;
|
import com.bernard.greposimu.model.OffContext;
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.units.Unit;
|
import com.bernard.greposimu.model.game.units.Unit;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
|
|||||||
@ -1,14 +1,22 @@
|
|||||||
package com.bernard.greposimu.model.game;
|
package com.bernard.greposimu.model.game;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.bernard.greposimu.Utils;
|
import com.bernard.greposimu.Utils;
|
||||||
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.powers.Power;
|
import com.bernard.greposimu.model.game.powers.Power;
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
import com.bernard.greposimu.model.game.units.Hero;
|
import com.bernard.greposimu.model.game.units.Hero;
|
||||||
import com.bernard.greposimu.model.game.units.Unit;
|
import com.bernard.greposimu.model.game.units.Unit;
|
||||||
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
import com.bernard.greposimu.model.game.util.UnitResources;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.CastedPower;
|
||||||
|
|
||||||
public class GameConfig {
|
public class GameConfig {
|
||||||
|
|
||||||
@ -23,8 +31,6 @@ public class GameConfig {
|
|||||||
|
|
||||||
Set<Power> powers;
|
Set<Power> powers;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public GameConfig(Set<God> gods, Set<Unit> units, Set<Hero> heroes, Set<Research> researches, Set<Power> powers) {
|
public GameConfig(Set<God> gods, Set<Unit> units, Set<Hero> heroes, Set<Research> researches, Set<Power> powers) {
|
||||||
this.gods = gods;
|
this.gods = gods;
|
||||||
this.units = units;
|
this.units = units;
|
||||||
@ -32,7 +38,7 @@ public class GameConfig {
|
|||||||
this.researches = researches;
|
this.researches = researches;
|
||||||
this.powers = powers;
|
this.powers = powers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<God> getGods() {
|
public Set<God> getGods() {
|
||||||
return gods;
|
return gods;
|
||||||
}
|
}
|
||||||
@ -42,35 +48,44 @@ public class GameConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Unit getUnit(String id) {
|
public Unit getUnit(String id) {
|
||||||
return Utils.getIdentified(this.units, id);
|
return Utils.throwingGetIdentified("unit",this.units, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Hero> getHeroes() {
|
public Set<Hero> getHeroes() {
|
||||||
return Collections.unmodifiableSet(this.heroes);
|
return Collections.unmodifiableSet(this.heroes);
|
||||||
}
|
}
|
||||||
public Hero getHero(String id) {
|
public Hero getHero(String id) {
|
||||||
return Utils.getIdentified(this.heroes, id);
|
return Utils.throwingGetIdentified("hero",this.heroes, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Research> getResearches() {
|
public Set<Research> getResearches() {
|
||||||
return Collections.unmodifiableSet(this.researches);
|
return Collections.unmodifiableSet(this.researches);
|
||||||
}
|
}
|
||||||
public Research getResearch(String id) {
|
public Research getResearch(String id) {
|
||||||
return Utils.getIdentified(this.researches, id);
|
return Utils.throwingGetIdentified("research",this.researches, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Building getBuilding(String bid) {
|
public Building getBuilding(String bid) {
|
||||||
return Arrays.stream(Building.values()).filter(b -> b.id.equals(bid)).findAny().orElse(null);
|
return Utils.throwingGetIdentified("building", Set.of(Building.values()), bid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public God getGod(String god) {
|
public God getGod(String god) {
|
||||||
return Utils.getIdentified(this.gods, god);
|
return Utils.throwingGetIdentified("god", this.gods, god);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Building> getBuildings() {
|
public Set<Building> getBuildings() {
|
||||||
return Set.of(Building.values());
|
return Set.of(Building.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<Power> getPowers() {
|
||||||
|
return powers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Power getPower(String pid){
|
||||||
|
System.out.println(powers.stream().map(Power::getId).sorted().collect(Collectors.joining("\n")));
|
||||||
|
return Utils.throwingGetIdentified("power", powers, pid);
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public <T extends Identified> T getIdentified(Class<T> clazz, String id) {
|
public <T extends Identified> T getIdentified(Class<T> clazz, String id) {
|
||||||
if(Unit.class.isAssignableFrom(clazz))
|
if(Unit.class.isAssignableFrom(clazz))
|
||||||
@ -80,9 +95,11 @@ public class GameConfig {
|
|||||||
if(Research.class.isAssignableFrom(clazz))
|
if(Research.class.isAssignableFrom(clazz))
|
||||||
return (T)this.getResearch(id);
|
return (T)this.getResearch(id);
|
||||||
if(God.class.isAssignableFrom(clazz))
|
if(God.class.isAssignableFrom(clazz))
|
||||||
return (T)this.getGod(id);
|
return (T)this.getGod(id);
|
||||||
if(Building.class.isAssignableFrom(clazz))
|
if(Building.class.isAssignableFrom(clazz))
|
||||||
return (T)this.getBuilding(id);
|
return (T)this.getBuilding(id);
|
||||||
|
if(Power.class.isAssignableFrom(clazz))
|
||||||
|
return (T)this.getPower(id);
|
||||||
throw new UnsupportedOperationException("Cannot get identified object of class "+clazz.getName());
|
throw new UnsupportedOperationException("Cannot get identified object of class "+clazz.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,4 +112,196 @@ public class GameConfig {
|
|||||||
return tot;
|
return tot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*********************/
|
||||||
|
/* COMPUTING METHODS */
|
||||||
|
/*********************/
|
||||||
|
|
||||||
|
private double callOfTheOceanBonus = 0.5;
|
||||||
|
private double fertilityImprovementBonus = 0.5;
|
||||||
|
private double shipwrightBonus = 0.1;
|
||||||
|
private double instructorBonus = 0.1;
|
||||||
|
private double conscriptionBonus = 0.1;
|
||||||
|
private double mathematicsBonus = 0.1;
|
||||||
|
private double architectureBonus = 0.1;
|
||||||
|
private double craneBonus = 0.15;
|
||||||
|
|
||||||
|
private double heroBonus(Hero h, int level) { return h.getPowerBaseValue() + level*h.getPowerValuePerLevel();}
|
||||||
|
|
||||||
|
private List<Double> senateReduction = List.of(1.000 , 0.986 , 0.970 , 0.953 , 0.935 , 0.915 , 0.895 , 0.874 , 0.852 , 0.830 , 0.808 , 0.785 , 0.761 , 0.737 , 0.712 , 0.685 , 0.661 , 0.636 , 0.620 , 0.584 , 0.561 , 0.537 , 0.502 , 0.476 , 0.450);
|
||||||
|
|
||||||
|
public long getUnitBuildTime(Unit u, int barracksLevel, int navalLevel, Set<CastedPower> powers, Set<Research> researches, Hero hero, int heroLevel){
|
||||||
|
// From helpers/general_modifications.js:169
|
||||||
|
double build_time = (u.getBuildTime() * (1 - Math.pow((u.isNaval()?navalLevel:barracksLevel) - 1, 1.1) / 100));
|
||||||
|
|
||||||
|
double modification_factor_by_powers = 1;
|
||||||
|
double modification_factor_by_researches = 1;
|
||||||
|
|
||||||
|
for(CastedPower p : powers){
|
||||||
|
if (u.isNaval() && p.getPower().getId().equals("call_of_the_ocean")) {
|
||||||
|
modification_factor_by_powers -= this.callOfTheOceanBonus;
|
||||||
|
} else if (!u.isNaval() && p.getPower().getId().equals("fertility_improvement")) {
|
||||||
|
modification_factor_by_powers -= this.fertilityImprovementBonus;
|
||||||
|
} else if ( Set.of("unit_order_boost", "longterm_unit_order_boost", "assassins_unit_order_boost", "mourning", "missions_power_2")
|
||||||
|
.contains(p.getPower().getId())) {
|
||||||
|
modification_factor_by_powers -= Integer.parseInt((String)p.getConfiguration().get("percent"), 10) / 100.0;
|
||||||
|
} else if (p.getPower().getId().equals("mourning")) {
|
||||||
|
modification_factor_by_powers += Integer.parseInt((String)p.getConfiguration().get("percent"), 10) / 100.0;
|
||||||
|
} else if(p.getPower().getId().equals("great_arming")) {
|
||||||
|
modification_factor_by_powers *= (1 - Integer.parseInt((String)p.getConfiguration().get("percent"), 10) / 100.0);
|
||||||
|
}
|
||||||
|
// Alliance boost powers
|
||||||
|
if (p.getPower().getId().equals("unit_order_boost_alliance") ||
|
||||||
|
p.getPower().getId().equals("unit_order_boost_alliance_hera")) {
|
||||||
|
String type = (String)p.getConfiguration().getOrDefault("type", "");
|
||||||
|
// The configured type must either be "all" or match the type of the current unit
|
||||||
|
if (type.equals("all") || (u.isNaval() ? type.equals("naval") : type.equals("ground"))) {
|
||||||
|
modification_factor_by_powers *= 0.01 * (100 - ((Integer)p.getConfiguration().getOrDefault("percent", 0)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (u.isNaval() && researches.contains(this.getResearch("shipwright"))) {
|
||||||
|
modification_factor_by_researches -= shipwrightBonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!u.isNaval() && researches.contains(this.getResearch("instructor"))) {
|
||||||
|
modification_factor_by_researches -= instructorBonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
build_time *= modification_factor_by_powers * modification_factor_by_researches;
|
||||||
|
|
||||||
|
//TODO implement augmentation bonus from benefits
|
||||||
|
//build_time *= this.getCollection("benefits").getAugmentationBonusForUnitBuildTime();
|
||||||
|
// Code in features/benefits/collections/benefits.js:12
|
||||||
|
|
||||||
|
//TODO implement augmentation bonus from world boosts
|
||||||
|
//build_time *= this.getCollection('world_boosts').getWorldBoostFactorForUnitRecruitTime(u);
|
||||||
|
// Code in collections/world_boosts.js:16
|
||||||
|
|
||||||
|
return Math.max(1, Math.round(build_time));
|
||||||
|
}
|
||||||
|
|
||||||
|
public UnitResources getUnitBuildResources(Unit u, int barracksLevel, int navalLevel, Set<CastedPower> powers, Set<Research> researches,Hero hero,int heroLevel){
|
||||||
|
//TODO use the real application computation (helpers/general_modifications.js:221)
|
||||||
|
Resources base = u.getBuildCost();
|
||||||
|
|
||||||
|
double modification_factor = 1;
|
||||||
|
Optional<CastedPower> power;
|
||||||
|
//finished_wonders = us.last(MM.getCollections().Wonder);
|
||||||
|
|
||||||
|
if (!u.isNaval() && researches.contains(this.getResearch("conscription")))
|
||||||
|
modification_factor *= (1 - conscriptionBonus);
|
||||||
|
|
||||||
|
if (!u.isNaval()) {
|
||||||
|
power = powers.stream().filter(p -> p.getPower().getId().equals("passionate_training")).findAny();
|
||||||
|
if (power.isPresent())
|
||||||
|
modification_factor *= (1 - Integer.parseInt((String)power.get().getConfiguration().get("percent"), 10) / 100.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (u.isNaval()) {
|
||||||
|
power = powers.stream().filter(p -> p.getPower().getId().equals("help_of_the_nereids")).findAny();
|
||||||
|
if (power.isPresent())
|
||||||
|
modification_factor *= (1 - Integer.parseInt((String)power.get().getConfiguration().get("percent"), 10) / 100.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
power = powers.stream().filter(p -> p.getPower().getId().equals("great_arming")).findAny();
|
||||||
|
if (power.isPresent())
|
||||||
|
modification_factor *= (1 - Integer.parseInt((String)power.get().getConfiguration().get("percent"), 10) / 100.0);
|
||||||
|
|
||||||
|
if (u.isNaval() && researches.contains(this.getResearch("mathematics")))
|
||||||
|
modification_factor *= (1 - mathematicsBonus);
|
||||||
|
|
||||||
|
|
||||||
|
// TODO take wonders into account
|
||||||
|
// finished_wonders.hasWonder('mausoleum_of_halicarnassus')
|
||||||
|
|
||||||
|
if (u.getId().equals("hoplite") && heroLevel != 0 && hero.getId().equals("cheiron"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
if (u.getId().equals("archer") && heroLevel != 0 && hero.getId().equals("philoctetes"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
if (u.getId().equals("sword") && heroLevel != 0 && hero.getId().equals("odysseus"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
if (u.getId().equals("attack_ship") && heroLevel != 0 && hero.getId().equals("aristotle"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
if (u.getId().equals("bireme") && heroLevel != 0 && hero.getId().equals("daidalos"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
if (u.getId().equals("trireme") && heroLevel != 0 && hero.getId().equals("eurybia"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
|
||||||
|
if(u.isMythological()){
|
||||||
|
int favor_cost_modifier = 0;
|
||||||
|
|
||||||
|
power = powers.stream().filter(p -> p.getPower().getId().equals("favor_boost_alliance")).findAny();
|
||||||
|
if (power.isPresent())
|
||||||
|
favor_cost_modifier += (int)power.get().getConfiguration().get("percent");
|
||||||
|
|
||||||
|
if (heroLevel != 0 && hero.getId().equals("anysia"))
|
||||||
|
favor_cost_modifier += 10 + heroLevel * 1;
|
||||||
|
|
||||||
|
return new UnitResources(base.prod(modification_factor),
|
||||||
|
u.getGod(),(int)Math.ceil(u.getFavorCost() * (1 - (favor_cost_modifier/100))));//TODO modifier on favor cost
|
||||||
|
} else
|
||||||
|
return new UnitResources(base.prod(modification_factor));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBuildingBuildingTime(Building b, int toLevel, int senateLevel, Set<CastedPower> powers, Set<Research> researches, Hero hero, int heroLevel){
|
||||||
|
//TODO check this function is correct
|
||||||
|
double modification_factor = 1.0;
|
||||||
|
//TODO take availability into consideration
|
||||||
|
// models/heroes/player_hero.js:165
|
||||||
|
if (heroLevel != 0 && hero.getId().equals("christopholus"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
|
||||||
|
if (researches.contains(this.getResearch("building_crane"))) {
|
||||||
|
modification_factor -= craneBonus;
|
||||||
|
}
|
||||||
|
Optional<CastedPower> power = powers.stream().filter(p -> p.getPower().getId().endsWith("building_order_boost")).findAny();
|
||||||
|
if (power.isPresent())
|
||||||
|
modification_factor *= (1 - Integer.parseInt((String)power.get().getConfiguration().get("percent"), 10) / 100.0);
|
||||||
|
|
||||||
|
long time = (long) (b.getBuildTime(toLevel) * senateReduction.get(senateLevel-1));
|
||||||
|
time = (long) Math.floor(time * modification_factor);
|
||||||
|
if (time < 1) time = 1;
|
||||||
|
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resources getBuildingBuildingResources(Building b, int toLevel, int senateLevel, Set<CastedPower> powers, Set<Research> researches, Hero hero, int heroLevel){
|
||||||
|
//TODO check this function is correct
|
||||||
|
double modification_factor = 1;
|
||||||
|
if (researches.contains(this.getResearch("architecture"))) {
|
||||||
|
modification_factor -= architectureBonus;
|
||||||
|
}
|
||||||
|
|
||||||
|
return b.getRequiredResources(toLevel).prod(modification_factor);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBuildingTearDownTime(Building b, int toLevel, int senateLevel, Set<CastedPower> powers, Set<Research> researches, Hero hero, int heroLevel){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getResearchTime(Research r, int academyLevel, Set<CastedPower> powers, Hero hero, int heroLevel){
|
||||||
|
double modification_factor = 1.0;
|
||||||
|
//TODO take availability into consideration
|
||||||
|
// models/heroes/player_hero.js:165
|
||||||
|
if (heroLevel != 0 && hero.getId().equals("apheledes"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
|
||||||
|
long time = (long) (r.getRequiredTime() * ((100 - Math.pow(academyLevel, 1.1)) / 100));
|
||||||
|
time = (long) Math.floor(time * modification_factor);
|
||||||
|
if (time < 1) time = 1;
|
||||||
|
|
||||||
|
return time;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Resources getResearchResources(Research r, int academyLevel, Set<CastedPower> powers, Hero hero, int heroLevel){
|
||||||
|
double modification_factor = 1.0;
|
||||||
|
//TODO take availability into consideration
|
||||||
|
// models/heroes/player_hero.js:165
|
||||||
|
if (heroLevel != 0 && hero.getId().equals("apheledes"))
|
||||||
|
modification_factor *= (1 - heroBonus(hero, heroLevel));
|
||||||
|
|
||||||
|
return r.getResources().prod(modification_factor);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,9 +2,12 @@ package com.bernard.greposimu.model.game;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
import com.bernard.greposimu.model.game.units.Hero;
|
import com.bernard.greposimu.model.game.units.Hero;
|
||||||
import com.bernard.greposimu.model.game.units.Unit;
|
import com.bernard.greposimu.model.game.units.Unit;
|
||||||
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
import com.fasterxml.jackson.core.JacksonException;
|
import com.fasterxml.jackson.core.JacksonException;
|
||||||
import com.fasterxml.jackson.core.JsonGenerator;
|
import com.fasterxml.jackson.core.JsonGenerator;
|
||||||
import com.fasterxml.jackson.core.JsonParser;
|
import com.fasterxml.jackson.core.JsonParser;
|
||||||
|
|||||||
@ -1,7 +1,10 @@
|
|||||||
package com.bernard.greposimu.model.game;
|
package com.bernard.greposimu.model.game.buildings;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
|
||||||
public enum Building implements Identified{
|
public enum Building implements Identified{
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -69,6 +72,18 @@ public enum Building implements Identified{
|
|||||||
public int getRequiredPop(int level) {
|
public int getRequiredPop(int level) {
|
||||||
return (int) Math.floor(pop0*Math.pow(level, popF));
|
return (int) Math.floor(pop0*Math.pow(level, popF));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Resources getRequiredResources(int level) {
|
||||||
|
return new Resources(
|
||||||
|
(int) Math.floor(wood0*Math.pow(level, woodF)),
|
||||||
|
(int) Math.floor(stone0*Math.pow(level, stoneF)),
|
||||||
|
(int) Math.floor(iron0*Math.pow(level, ironF)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getBuildTime(int level) {
|
||||||
|
//TODO check this, is build_time_reduction used ?
|
||||||
|
return (long) Math.floor(build0*Math.pow(level, buildF));
|
||||||
|
}
|
||||||
|
|
||||||
public int popInBuildings(Map<Building,Integer> buildings) {
|
public int popInBuildings(Map<Building,Integer> buildings) {
|
||||||
return buildings.entrySet().stream().mapToInt(e -> e.getKey().getRequiredPop(e.getValue())).sum();
|
return buildings.entrySet().stream().mapToInt(e -> e.getKey().getRequiredPop(e.getValue())).sum();
|
||||||
@ -1,7 +1,9 @@
|
|||||||
package com.bernard.greposimu.model.game;
|
package com.bernard.greposimu.model.game.gods;
|
||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
|
|
||||||
public class God implements Identified,Comparable<God>{
|
public class God implements Identified,Comparable<God>{
|
||||||
|
|
||||||
String id;
|
String id;
|
||||||
@ -2,23 +2,27 @@ package com.bernard.greposimu.model.game.powers;
|
|||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
|
|
||||||
public class FuryPower extends GodPower {
|
public class FuryPower extends GodPower {
|
||||||
double furyProportionCost;
|
double furyProportionCost;
|
||||||
|
|
||||||
public FuryPower(String id, String name, String description, String shortEffect, String effect,
|
public FuryPower(String id, EnumSet<Target> targets, EnumSet<Target> seedsTo, String shortEffect, Power.Group powerGroup,
|
||||||
EnumSet<Target> targets, EnumSet<Target> seedsTo, Group powerGroup, boolean negative, int powerGroupLevel,
|
int powerGroupLevel, Set<String> metaFields, Map<String, Object> metaDefaults, int lifetime, EnumSet<Effect> effects,
|
||||||
EnumSet<Effect> effects, boolean ignores_democritus, EnumSet<AreaOfEffect> areaOfEffect, EnumSet<Tag> tags,
|
EnumSet<Tag> tags,
|
||||||
int lifetime, Map<String, Object> metaDefaults, God god, int furyCost, int templeLevelSumDependency,
|
Set<String> compatiblePowers, EnumSet<AreaOfEffect> areaOfEffect, String name, String effect,
|
||||||
|
String description, String configType, Map<String, String> nameM, Map<String, String> effectM,
|
||||||
|
Map<String, String> descriptionM, God god2, int favorCost, int templeLevelSumDependency,
|
||||||
double furyProportionCost) {
|
double furyProportionCost) {
|
||||||
super(id, name, description, shortEffect, effect, targets, seedsTo, powerGroup, negative, powerGroupLevel,
|
super(id, targets, seedsTo, shortEffect, powerGroup, powerGroupLevel, metaFields, metaDefaults, lifetime,
|
||||||
effects, ignores_democritus, areaOfEffect, tags, lifetime, metaDefaults, god, furyCost,
|
effects, tags, compatiblePowers, areaOfEffect, name,
|
||||||
|
effect, description, configType, nameM, effectM, descriptionM, god2, favorCost,
|
||||||
templeLevelSumDependency);
|
templeLevelSumDependency);
|
||||||
this.furyProportionCost = furyProportionCost;
|
this.furyProportionCost = furyProportionCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getFuryProportionCost() {
|
public double getFuryProportionCost() {
|
||||||
return furyProportionCost;
|
return furyProportionCost;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,26 +2,28 @@ package com.bernard.greposimu.model.game.powers;
|
|||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
|
|
||||||
public class GodPower extends Power {
|
public class GodPower extends Power {
|
||||||
|
|
||||||
God god;
|
God god;
|
||||||
int furyCost;
|
int favorCost;
|
||||||
|
|
||||||
int templeLevelSumDependency;
|
int templeLevelSumDependency;
|
||||||
|
|
||||||
|
public GodPower(String id, EnumSet<Target> targets, EnumSet<Target> seedsTo, String shortEffect, Power.Group powerGroup,
|
||||||
|
int powerGroupLevel, Set<String> metaFields, Map<String, Object> metaDefaults, int lifetime, EnumSet<Effect> effects,
|
||||||
public GodPower(String id, String name, String description, String shortEffect, String effect,
|
EnumSet<Tag> tags,
|
||||||
EnumSet<Target> targets, EnumSet<Target> seedsTo, Group powerGroup, boolean negative, int powerGroupLevel,
|
Set<String> compatiblePowers, EnumSet<AreaOfEffect> areaOfEffect, String name, String effect,
|
||||||
EnumSet<Effect> effects, boolean ignores_democritus, EnumSet<AreaOfEffect> areaOfEffect, EnumSet<Tag> tags,
|
String description, String configType, Map<String, String> nameM, Map<String, String> effectM,
|
||||||
int lifetime, Map<String, Object> metaDefaults, God god, int furyCost, int templeLevelSumDependency) {
|
Map<String, String> descriptionM, God god2, int favorCost, int templeLevelSumDependency) {
|
||||||
super(id, name, description, shortEffect, effect, targets, seedsTo, powerGroup, negative, powerGroupLevel,
|
super(id, targets, seedsTo, shortEffect, powerGroup, powerGroupLevel, metaFields, metaDefaults, lifetime,
|
||||||
effects, ignores_democritus, areaOfEffect, tags, lifetime, metaDefaults);
|
effects, tags, compatiblePowers, areaOfEffect, name,
|
||||||
this.god = god;
|
effect, description, configType, nameM, effectM, descriptionM);
|
||||||
this.furyCost = furyCost;
|
god = god2;
|
||||||
|
this.favorCost = favorCost;
|
||||||
this.templeLevelSumDependency = templeLevelSumDependency;
|
this.templeLevelSumDependency = templeLevelSumDependency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -29,10 +31,10 @@ public class GodPower extends Power {
|
|||||||
return god;
|
return god;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getFuryCost() {
|
public int getFavorCost() {
|
||||||
return furyCost;
|
return favorCost;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getTempleLevelSumDependency() {
|
public int getTempleLevelSumDependency() {
|
||||||
return templeLevelSumDependency;
|
return templeLevelSumDependency;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,21 +0,0 @@
|
|||||||
package com.bernard.greposimu.model.game.powers;
|
|
||||||
|
|
||||||
import java.util.EnumSet;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class MultitypePower extends Power{
|
|
||||||
String commonId;
|
|
||||||
|
|
||||||
public MultitypePower(String id, String name, String description, String shortEffect, String effect,
|
|
||||||
EnumSet<Target> targets, EnumSet<Target> seedsTo, Group powerGroup, boolean negative, int powerGroupLevel,
|
|
||||||
EnumSet<Effect> effects, boolean ignores_democritus, EnumSet<AreaOfEffect> areaOfEffect, EnumSet<Tag> tags,
|
|
||||||
int lifetime, Map<String, Object> metaDefaults, String commonId) {
|
|
||||||
super(id, name, description, shortEffect, effect, targets, seedsTo, powerGroup, negative, powerGroupLevel,
|
|
||||||
effects, ignores_democritus, areaOfEffect, tags, lifetime, metaDefaults);
|
|
||||||
this.commonId = commonId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCommonId() {
|
|
||||||
return commonId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -2,50 +2,51 @@ package com.bernard.greposimu.model.game.powers;
|
|||||||
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Identified;
|
import org.springframework.lang.Nullable;
|
||||||
|
|
||||||
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
|
|
||||||
public class Power implements Identified {
|
public class Power implements Identified {
|
||||||
|
|
||||||
|
|
||||||
String id;
|
String id;
|
||||||
String name;
|
|
||||||
String description;
|
|
||||||
String shortEffect;
|
|
||||||
String effect;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The target it applies to
|
* The target it applies to
|
||||||
*/
|
*/
|
||||||
EnumSet<Target> targets;
|
EnumSet<Target> targets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The targets it is seeded to. For example, attack boost is targeted to towns, and is seeded to commands.
|
* The targets it is seeded to. For example, attack boost is targeted to towns, and is seeded to commands.
|
||||||
*/
|
*/
|
||||||
EnumSet<Target> seedsTo;
|
EnumSet<Target> seedsTo;
|
||||||
|
|
||||||
|
@Nullable
|
||||||
// EFFECTS
|
String shortEffect;
|
||||||
Group powerGroup;
|
Power.Group powerGroup;
|
||||||
boolean negative;
|
|
||||||
int powerGroupLevel;
|
int powerGroupLevel;
|
||||||
|
|
||||||
|
//name
|
||||||
|
Set<String> metaFields;
|
||||||
|
Map<String,Object> metaDefaults;
|
||||||
|
|
||||||
|
int lifetime;
|
||||||
|
|
||||||
|
EnumSet<Tag> tags;
|
||||||
EnumSet<Effect> effects;
|
EnumSet<Effect> effects;
|
||||||
boolean ignores_democritus;
|
Set<String> compatiblePowers;
|
||||||
EnumSet<AreaOfEffect> areaOfEffect;
|
EnumSet<AreaOfEffect> areaOfEffect;
|
||||||
|
|
||||||
|
// for each X, either X or XM should be null. if one XM is not null, configType should be set
|
||||||
|
String name,effect,description;
|
||||||
|
String configType;
|
||||||
|
Map<String,String> nameM,effectM,descriptionM;
|
||||||
|
|
||||||
|
//display_amount -> ignore
|
||||||
|
|
||||||
// images -> IGNORE
|
|
||||||
EnumSet<Tag> tags;
|
|
||||||
int lifetime;
|
|
||||||
|
|
||||||
|
|
||||||
Map<String,Object> metaDefaults;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static enum Tag {
|
public static enum Tag {
|
||||||
EXTENDIBLE,
|
EXTENDIBLE,
|
||||||
DISPLAY_AMOUNT,
|
DISPLAY_AMOUNT,
|
||||||
@ -63,96 +64,101 @@ public class Power implements Identified {
|
|||||||
RECREATE_ON_RESTART,
|
RECREATE_ON_RESTART,
|
||||||
REMOVED_ON_TARGET_LOSS,
|
REMOVED_ON_TARGET_LOSS,
|
||||||
REQUIRES_GOD,
|
REQUIRES_GOD,
|
||||||
NO_LIFETIME;
|
NO_LIFETIME,
|
||||||
|
ONLY_OWN_TOWNS,
|
||||||
|
NEGATIVE,
|
||||||
|
IGNORES_DEMOCRITUS,
|
||||||
|
BOOST;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Power(String id, EnumSet<Target> targets, EnumSet<Target> seedsTo, String shortEffect, Power.Group powerGroup,
|
||||||
|
int powerGroupLevel, Set<String> metaFields, Map<String, Object> metaDefaults, int lifetime,
|
||||||
|
EnumSet<Effect> effects, EnumSet<Tag> tags,
|
||||||
|
Set<String> compatiblePowers, EnumSet<AreaOfEffect> areaOfEffect, String name, String effect,
|
||||||
|
String description, String configType, Map<String, String> nameM, Map<String, String> effectM,
|
||||||
|
Map<String, String> descriptionM) {
|
||||||
|
this.id = id;
|
||||||
|
this.targets = targets;
|
||||||
|
this.seedsTo = seedsTo;
|
||||||
|
this.shortEffect = shortEffect;
|
||||||
|
this.powerGroup = powerGroup;
|
||||||
|
this.powerGroupLevel = powerGroupLevel;
|
||||||
|
this.metaFields = metaFields;
|
||||||
|
this.metaDefaults = metaDefaults;
|
||||||
|
this.lifetime = lifetime;
|
||||||
|
this.effects = effects;
|
||||||
|
this.tags = tags;
|
||||||
|
this.compatiblePowers = compatiblePowers;
|
||||||
|
this.areaOfEffect = areaOfEffect;
|
||||||
|
this.name = name;
|
||||||
|
this.effect = effect;
|
||||||
|
this.description = description;
|
||||||
|
this.configType = configType;
|
||||||
|
this.nameM = nameM;
|
||||||
|
this.effectM = effectM;
|
||||||
|
this.descriptionM = descriptionM;
|
||||||
|
}
|
||||||
public static enum AreaOfEffect {
|
public static enum AreaOfEffect {
|
||||||
BUILDTIME,COMMANDS,FAVOR,MILITIA,RESOURCES;
|
BUILDTIME,COMMANDS,FAVOR,MILITIA,RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Effect {
|
public static enum Effect {
|
||||||
GROUND,NAVAL,WALL;
|
GROUND,NAVAL,WALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum Group {
|
public static enum Group {
|
||||||
ATTACK_BOOST,ATTACK_SHIP_ATTACK_BOOST,BATTLE_POINT_BOOST,BUILDING_BOOST,DEFENSE_BOOST,FAVOR_BOOST,RESOURCE_BOOST,UNIT_BOOST;
|
ATTACK_BOOST,ATTACK_SHIP_ATTACK_BOOST,BATTLE_POINT_BOOST,BUILDING_BOOST,DEFENSE_BOOST,FAVOR_BOOST,RESOURCE_BOOST,UNIT_BOOST;
|
||||||
}
|
}
|
||||||
public static enum Target {
|
public static enum Target {
|
||||||
ALLIANCE,COMMAND,PLAYER,SUPPORT_COMMAND,TOWN;
|
ALLIANCE,COMMAND,PLAYER,SUPPORT_COMMAND,TOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public Power(String id, String name, String description, String shortEffect, String effect, EnumSet<Target> targets,
|
|
||||||
EnumSet<Target> seedsTo, Group powerGroup, boolean negative, int powerGroupLevel, EnumSet<Effect> effects,
|
|
||||||
boolean ignores_democritus, EnumSet<AreaOfEffect> areaOfEffect, EnumSet<Tag> tags, int lifetime,
|
|
||||||
Map<String, Object> metaDefaults) {
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.description = description;
|
|
||||||
this.shortEffect = shortEffect;
|
|
||||||
this.effect = effect;
|
|
||||||
this.targets = targets;
|
|
||||||
this.seedsTo = seedsTo;
|
|
||||||
this.powerGroup = powerGroup;
|
|
||||||
this.negative = negative;
|
|
||||||
this.powerGroupLevel = powerGroupLevel;
|
|
||||||
this.effects = effects;
|
|
||||||
this.ignores_democritus = ignores_democritus;
|
|
||||||
this.areaOfEffect = areaOfEffect;
|
|
||||||
this.tags = tags;
|
|
||||||
this.lifetime = lifetime;
|
|
||||||
this.metaDefaults = metaDefaults;
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
public String getDescription() {
|
|
||||||
return description;
|
|
||||||
}
|
|
||||||
public String getShortEffect() {
|
|
||||||
return shortEffect;
|
|
||||||
}
|
|
||||||
public String getEffect() {
|
|
||||||
return effect;
|
|
||||||
}
|
|
||||||
public EnumSet<Target> getTargets() {
|
public EnumSet<Target> getTargets() {
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
public EnumSet<Target> getSeedsTo() {
|
public EnumSet<Target> getSeedsTo() {
|
||||||
return seedsTo;
|
return seedsTo;
|
||||||
}
|
}
|
||||||
public Group getPowerGroup() {
|
public String getShortEffect() {
|
||||||
return powerGroup;
|
return shortEffect;
|
||||||
}
|
}
|
||||||
public boolean isNegative() {
|
public Power.Group getPowerGroup() {
|
||||||
return negative;
|
return powerGroup;
|
||||||
}
|
}
|
||||||
public int getPowerGroupLevel() {
|
public int getPowerGroupLevel() {
|
||||||
return powerGroupLevel;
|
return powerGroupLevel;
|
||||||
}
|
}
|
||||||
public EnumSet<Effect> getEffects() {
|
public Set<String> getMetaFields() {
|
||||||
return effects;
|
return metaFields;
|
||||||
}
|
|
||||||
public boolean isIgnores_democritus() {
|
|
||||||
return ignores_democritus;
|
|
||||||
}
|
|
||||||
public EnumSet<AreaOfEffect> getAreaOfEffect() {
|
|
||||||
return areaOfEffect;
|
|
||||||
}
|
|
||||||
public EnumSet<Tag> getTags() {
|
|
||||||
return tags;
|
|
||||||
}
|
|
||||||
public int getLifetime() {
|
|
||||||
return lifetime;
|
|
||||||
}
|
}
|
||||||
public Map<String, Object> getMetaDefaults() {
|
public Map<String, Object> getMetaDefaults() {
|
||||||
return metaDefaults;
|
return metaDefaults;
|
||||||
}
|
}
|
||||||
|
public int getLifetime() {
|
||||||
|
return lifetime;
|
||||||
|
}
|
||||||
|
public EnumSet<Effect> getEffects() {
|
||||||
|
return effects;
|
||||||
|
}
|
||||||
|
public EnumSet<Tag> getTags() {
|
||||||
|
return tags;
|
||||||
|
}
|
||||||
|
public Set<String> getCompatiblePowers() {
|
||||||
|
return compatiblePowers;
|
||||||
|
}
|
||||||
|
public EnumSet<AreaOfEffect> getAreaOfEffect() {
|
||||||
|
return areaOfEffect;
|
||||||
|
}
|
||||||
|
public String getName(Map<String,Object> configuration) {
|
||||||
|
return name!=null?name:(nameM.get(configuration.get(configType)));
|
||||||
|
}
|
||||||
|
public String getEffect(Map<String,Object> configuration) {
|
||||||
|
return effect!=null?effect:(effectM.get(configuration.get(configType)));
|
||||||
|
}
|
||||||
|
public String getDescription(Map<String,Object> configuration) {
|
||||||
|
return description!=null?description:(descriptionM.get(configuration.get(configType)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.bernard.greposimu.model.game.queues;
|
package com.bernard.greposimu.model.game.queues;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Building;
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
import com.bernard.greposimu.model.game.Timestamp;
|
import com.bernard.greposimu.model.game.util.Timestamp;
|
||||||
|
|
||||||
public class BuildingQueueItem extends QueueItem {
|
public class BuildingQueueItem extends QueueItem {
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.bernard.greposimu.model.game.queues;
|
package com.bernard.greposimu.model.game.queues;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Timestamp;
|
|
||||||
import com.bernard.greposimu.model.game.UnitResources;
|
|
||||||
import com.bernard.greposimu.model.game.units.Unit;
|
import com.bernard.greposimu.model.game.units.Unit;
|
||||||
|
import com.bernard.greposimu.model.game.util.Timestamp;
|
||||||
|
import com.bernard.greposimu.model.game.util.UnitResources;
|
||||||
|
|
||||||
public class RecruitmentQueueItem extends QueueItem {
|
public class RecruitmentQueueItem extends QueueItem {
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.bernard.greposimu.model.game.queues;
|
package com.bernard.greposimu.model.game.queues;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
|
||||||
import com.bernard.greposimu.model.game.Timestamp;
|
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
import com.bernard.greposimu.model.game.util.Timestamp;
|
||||||
|
|
||||||
public class ResearchQueueItem extends QueueItem {
|
public class ResearchQueueItem extends QueueItem {
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,8 @@ package com.bernard.greposimu.model.game.researches;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Identified;
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
|
||||||
public class Research implements Identified{
|
public class Research implements Identified{
|
||||||
|
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import java.util.Map;
|
|||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Identified;
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
|
|
||||||
public class Hero extends TerrestrialUnit implements Comparable<Hero>{
|
public class Hero extends TerrestrialUnit implements Comparable<Hero>{
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package com.bernard.greposimu.model.game.units;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
|
||||||
public class NavalUnit extends Unit {
|
public class NavalUnit extends Unit {
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package com.bernard.greposimu.model.game.units;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
|
||||||
public class TerrestrialUnit extends Unit{
|
public class TerrestrialUnit extends Unit{
|
||||||
|
|
||||||
|
|||||||
@ -3,9 +3,9 @@ package com.bernard.greposimu.model.game.units;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
|
||||||
public class TransportUnit extends NavalUnit {
|
public class TransportUnit extends NavalUnit {
|
||||||
int capacity;
|
int capacity;
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package com.bernard.greposimu.model.game.units;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.Identified;
|
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
|
||||||
public abstract class Unit implements Identified{
|
public abstract class Unit implements Identified{
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package com.bernard.greposimu.model.game;
|
package com.bernard.greposimu.model.game.util;
|
||||||
|
|
||||||
public interface Identified {
|
public interface Identified {
|
||||||
|
|
||||||
@ -1,7 +1,9 @@
|
|||||||
package com.bernard.greposimu.model.game;
|
package com.bernard.greposimu.model.game.util;
|
||||||
|
|
||||||
public class Resources {
|
public class Resources {
|
||||||
|
|
||||||
|
public static final Resources empty = new Resources(0,0,0);
|
||||||
|
|
||||||
int wood;
|
int wood;
|
||||||
int stone;
|
int stone;
|
||||||
int iron;
|
int iron;
|
||||||
@ -25,7 +27,7 @@ public class Resources {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Resources prod(double p){
|
public Resources prod(double p){
|
||||||
return new Resources((int)p*wood, (int)p*stone, (int)p*iron);
|
return new Resources((int)Math.ceil(p*wood), (int)Math.ceil(p*stone), (int)Math.ceil(p*iron));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.bernard.greposimu.model.game;
|
package com.bernard.greposimu.model.game.util;
|
||||||
|
|
||||||
public class Timestamp {
|
public class Timestamp {
|
||||||
|
|
||||||
@ -1,21 +1,26 @@
|
|||||||
package com.bernard.greposimu.model.game;
|
package com.bernard.greposimu.model.game.util;
|
||||||
|
|
||||||
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
|
|
||||||
public class UnitResources extends Resources {
|
public class UnitResources extends Resources {
|
||||||
|
|
||||||
God god;
|
God god;
|
||||||
int favor;
|
int favor;
|
||||||
|
|
||||||
public UnitResources(int wood, int stone, int iron) {
|
|
||||||
super(wood, stone, iron);
|
|
||||||
this.god = null;
|
|
||||||
this.favor = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnitResources(int wood, int stone, int iron, God god, int favor) {
|
public UnitResources(int wood, int stone, int iron, God god, int favor) {
|
||||||
super(wood, stone, iron);
|
super(wood, stone, iron);
|
||||||
this.god = god;
|
this.god = god;
|
||||||
this.favor = favor;
|
this.favor = favor;
|
||||||
}
|
}
|
||||||
|
public UnitResources(int wood, int stone, int iron) {
|
||||||
|
this(wood, stone, iron, null, 0);
|
||||||
|
}
|
||||||
|
public UnitResources(Resources r, God god, int favor) {
|
||||||
|
this(r.getWood(), r.getStone(), r.getIron(),god,favor);
|
||||||
|
}
|
||||||
|
public UnitResources(Resources r) {
|
||||||
|
this(r.getWood(), r.getStone(), r.getIron(),null,0);
|
||||||
|
}
|
||||||
|
|
||||||
public God getGod() {
|
public God getGod() {
|
||||||
return god;
|
return god;
|
||||||
@ -1,9 +1,10 @@
|
|||||||
package com.bernard.greposimu.model.simulator.command;
|
package com.bernard.greposimu.model.simulator.command;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Building;
|
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Ville;
|
||||||
|
|
||||||
public class BuildCommand extends TownCommand {
|
public class BuildCommand extends TownCommand {
|
||||||
|
|
||||||
@ -31,14 +32,39 @@ public class BuildCommand extends TownCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resources neededResources(SimulatorData sd) {
|
public Resources neededResources(SimulatorData sd) {
|
||||||
// TODO Auto-generated method stub
|
if(this.tearingDown)return Resources.empty;
|
||||||
return new Resources(1000, 1000, 1000);
|
Ville v = sd.getVille(town);
|
||||||
|
return gc.getBuildingBuildingResources(
|
||||||
|
this.building,
|
||||||
|
this.level,
|
||||||
|
v.getBatiments().get(Building.MAIN),
|
||||||
|
v.getPowers(),
|
||||||
|
v.getResearches(),
|
||||||
|
v.getHero(),
|
||||||
|
v.getHeroLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int timeNeeded(SimulatorData sd) {
|
public long timeNeeded(SimulatorData sd) {
|
||||||
// TODO Auto-generated method stub
|
Ville v = sd.getVille(town);
|
||||||
return 3600;
|
if(this.tearingDown)
|
||||||
|
return gc.getBuildingTearDownTime(
|
||||||
|
this.building,
|
||||||
|
this.level,
|
||||||
|
v.getBatiments().get(Building.MAIN),
|
||||||
|
v.getPowers(),
|
||||||
|
v.getResearches(),
|
||||||
|
v.getHero(),
|
||||||
|
v.getHeroLevel());
|
||||||
|
else
|
||||||
|
return gc.getBuildingBuildingTime(
|
||||||
|
this.building,
|
||||||
|
this.level,
|
||||||
|
v.getBatiments().get(Building.MAIN),
|
||||||
|
v.getPowers(),
|
||||||
|
v.getResearches(),
|
||||||
|
v.getHero(),
|
||||||
|
v.getHeroLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package com.bernard.greposimu.model.simulator.command;
|
package com.bernard.greposimu.model.simulator.command;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
|
|
||||||
public abstract class Command {
|
public abstract class Command {
|
||||||
|
|
||||||
@ -11,6 +11,6 @@ public abstract class Command {
|
|||||||
this.gc = gc;
|
this.gc = gc;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract int timeNeeded(SimulatorData sd);
|
public abstract long timeNeeded(SimulatorData sd);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.bernard.greposimu.model.simulator.command;
|
package com.bernard.greposimu.model.simulator.command;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
|
|
||||||
public class HideStoreCommand extends TownCommand {
|
public class HideStoreCommand extends TownCommand {
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public class HideStoreCommand extends TownCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int timeNeeded(SimulatorData sd) {
|
public long timeNeeded(SimulatorData sd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package com.bernard.greposimu.model.simulator.command;
|
package com.bernard.greposimu.model.simulator.command;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Building;
|
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
import com.bernard.greposimu.model.game.units.Unit;
|
import com.bernard.greposimu.model.game.units.Unit;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
import com.bernard.greposimu.model.simulator.Ville;
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Ville;
|
||||||
|
|
||||||
public class RecruitCommand extends TownCommand{
|
public class RecruitCommand extends TownCommand{
|
||||||
|
|
||||||
@ -22,30 +22,31 @@ public class RecruitCommand extends TownCommand{
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return "[%d] Recruit %d %s".formatted(this.town,this.count, this.unit.getName());
|
return "[%d] Recruit %d %s".formatted(this.town,this.count, this.unit.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resources neededResources(SimulatorData sd) {
|
public Resources neededResources(SimulatorData sd) {
|
||||||
Resources base = this.unit.getBuildCost();
|
|
||||||
Ville v = sd.getVille(town);
|
Ville v = sd.getVille(town);
|
||||||
double percentage = 1.0;
|
return gc.getUnitBuildResources(
|
||||||
//TODO take heroes into account, generalize resarches
|
this.unit,
|
||||||
if(v.hasResearch(gc.getResearch("conscription")))
|
v.getBatiments().get(Building.BARRACKS),
|
||||||
percentage -= .1;
|
v.getBatiments().get(Building.DOCKS),
|
||||||
return base.prod(percentage*count);
|
v.getPowers(),
|
||||||
|
v.getResearches(),
|
||||||
|
v.getHero(),
|
||||||
|
v.getHeroLevel()).prod(this.count);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int timeNeeded(SimulatorData sd) {
|
public long timeNeeded(SimulatorData sd) {
|
||||||
int base = this.unit.getBuildTime();
|
|
||||||
Ville v = sd.getVille(town);
|
Ville v = sd.getVille(town);
|
||||||
double percentage = 1.0;
|
return gc.getUnitBuildTime(
|
||||||
//TODO take heroes into account, generalize resarches
|
this.unit,
|
||||||
if(v.hasResearch(gc.getResearch("instructor")))
|
v.getBatiments().get(Building.BARRACKS),
|
||||||
percentage -= .1;
|
v.getBatiments().get(Building.DOCKS),
|
||||||
//TODO move this code in gameconfig
|
v.getPowers(),
|
||||||
//TODO use the real application computation (helpers/general_modifications.js:221)
|
v.getResearches(),
|
||||||
percentage -= Math.pow(v.getBatiments().get(Building.BARRACKS) - 1, 1.1) / 100;
|
v.getHero(),
|
||||||
return (int) (base * percentage * count);
|
v.getHeroLevel()) * this.count;
|
||||||
}
|
}
|
||||||
|
// Store favor cost somewhere
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,9 +1,11 @@
|
|||||||
package com.bernard.greposimu.model.simulator.command;
|
package com.bernard.greposimu.model.simulator.command;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Ville;
|
||||||
|
|
||||||
public class ResearchCommand extends TownCommand {
|
public class ResearchCommand extends TownCommand {
|
||||||
|
|
||||||
@ -22,19 +24,31 @@ public class ResearchCommand extends TownCommand {
|
|||||||
else
|
else
|
||||||
return "[%d] Research %s".formatted(this.town,this.research.getName());
|
return "[%d] Research %s".formatted(this.town,this.research.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resources neededResources(SimulatorData sd) {
|
public Resources neededResources(SimulatorData sd) {
|
||||||
//TODO take into account other modifiers (heroes zB)
|
if(this.forget)return Resources.empty;
|
||||||
//TODO take forgetting into account
|
Ville v = sd.getVille(town);
|
||||||
return research.getResources();
|
return gc.getResearchResources(
|
||||||
|
this.research,
|
||||||
|
v.getBatiments().get(Building.ACADEMY),
|
||||||
|
v.getPowers(),
|
||||||
|
v.getHero(),
|
||||||
|
v.getHeroLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int timeNeeded(SimulatorData sd) {
|
public long timeNeeded(SimulatorData sd) {
|
||||||
//TODO take into account other modifiers (heroes zB)
|
Ville v = sd.getVille(town);
|
||||||
//TODO take forgetting into account
|
if(this.forget)
|
||||||
return research.getRequiredTime();
|
//TODO check this implementation correct
|
||||||
|
return 0;
|
||||||
|
else
|
||||||
|
return gc.getResearchTime(
|
||||||
|
this.research,
|
||||||
|
v.getBatiments().get(Building.ACADEMY),
|
||||||
|
v.getPowers(),
|
||||||
|
v.getHero(),
|
||||||
|
v.getHeroLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
package com.bernard.greposimu.model.simulator.command;
|
package com.bernard.greposimu.model.simulator.command;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
|
|
||||||
public abstract class TownCommand extends Command {
|
public abstract class TownCommand extends Command {
|
||||||
|
|
||||||
@ -12,6 +12,6 @@ public abstract class TownCommand extends Command {
|
|||||||
super(gc);
|
super(gc);
|
||||||
this.town = town;
|
this.town = town;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Resources neededResources(SimulatorData sd);
|
public abstract Resources neededResources(SimulatorData sd);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
package com.bernard.greposimu.model.simulator.data;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.bernard.greposimu.model.game.powers.Power;
|
||||||
|
import com.bernard.greposimu.model.game.util.Identified;
|
||||||
|
import com.bernard.greposimu.model.game.util.Timestamp;
|
||||||
|
|
||||||
|
public class CastedPower implements Identified{
|
||||||
|
|
||||||
|
long originPlayer;
|
||||||
|
Power power;
|
||||||
|
Timestamp end;
|
||||||
|
String id;
|
||||||
|
Integer level;
|
||||||
|
int extended;
|
||||||
|
|
||||||
|
// Replace with real OOP, depending on the power
|
||||||
|
Map<String,Object> configuration;
|
||||||
|
|
||||||
|
public CastedPower(long originPlayer, Power power, Timestamp end, String id, Integer level, int extended,
|
||||||
|
Map<String, Object> configuration) {
|
||||||
|
this.originPlayer = originPlayer;
|
||||||
|
this.power = power;
|
||||||
|
this.end = end;
|
||||||
|
this.id = id;
|
||||||
|
this.level = level;
|
||||||
|
this.extended = extended;
|
||||||
|
this.configuration = configuration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getOriginPlayer() {
|
||||||
|
return originPlayer;
|
||||||
|
}
|
||||||
|
public Power getPower() {
|
||||||
|
return power;
|
||||||
|
}
|
||||||
|
public Timestamp getEnd() {
|
||||||
|
return end;
|
||||||
|
}
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
public Map<String, Object> getConfiguration() {
|
||||||
|
return configuration;
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,11 +1,11 @@
|
|||||||
package com.bernard.greposimu.model.simulator;
|
package com.bernard.greposimu.model.simulator.data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.Timestamp;
|
import com.bernard.greposimu.model.game.util.Timestamp;
|
||||||
|
|
||||||
public class Joueureuse {
|
public class Joueureuse {
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
package com.bernard.greposimu.model.simulator;
|
package com.bernard.greposimu.model.simulator.data;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Timestamp;
|
import com.bernard.greposimu.model.game.util.Timestamp;
|
||||||
|
|
||||||
public class Movements {
|
public class Movements {
|
||||||
|
|
||||||
@ -1,11 +1,10 @@
|
|||||||
package com.bernard.greposimu.model.simulator;
|
package com.bernard.greposimu.model.simulator.data;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class SimulatorData {
|
public class SimulatorData {
|
||||||
|
|
||||||
Map<Integer,Ville> villes;
|
Map<Integer,Ville> villes;
|
||||||
|
|
||||||
Joueureuse joueureuse;
|
Joueureuse joueureuse;
|
||||||
|
|
||||||
public SimulatorData(Map<Integer, Ville> villes, Joueureuse joueureuse) {
|
public SimulatorData(Map<Integer, Ville> villes, Joueureuse joueureuse) {
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package com.bernard.greposimu.model.simulator;
|
package com.bernard.greposimu.model.simulator.data;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@ -1,18 +1,18 @@
|
|||||||
package com.bernard.greposimu.model.simulator;
|
package com.bernard.greposimu.model.simulator.data;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Building;
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
|
||||||
import com.bernard.greposimu.model.game.Timestamp;
|
|
||||||
import com.bernard.greposimu.model.game.powers.Power;
|
|
||||||
import com.bernard.greposimu.model.game.queues.BuildingQueueItem;
|
import com.bernard.greposimu.model.game.queues.BuildingQueueItem;
|
||||||
import com.bernard.greposimu.model.game.queues.RecruitmentQueueItem;
|
import com.bernard.greposimu.model.game.queues.RecruitmentQueueItem;
|
||||||
import com.bernard.greposimu.model.game.queues.ResearchQueueItem;
|
import com.bernard.greposimu.model.game.queues.ResearchQueueItem;
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
|
import com.bernard.greposimu.model.game.units.Hero;
|
||||||
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
|
import com.bernard.greposimu.model.game.util.Timestamp;
|
||||||
|
|
||||||
public class Ville {
|
public class Ville {
|
||||||
|
|
||||||
@ -29,8 +29,7 @@ public class Ville {
|
|||||||
// Destination town -> troupes
|
// Destination town -> troupes
|
||||||
Map<Integer,Troupes> soutenus;
|
Map<Integer,Troupes> soutenus;
|
||||||
|
|
||||||
// sortilegeId -> effectEnd
|
Set<CastedPower> powers;
|
||||||
Map<Power,Timestamp> sortileges;
|
|
||||||
|
|
||||||
// Agora
|
// Agora
|
||||||
Timestamp festivalEnd,olympiquesEnd,marchEnd,theaterEnd;
|
Timestamp festivalEnd,olympiquesEnd,marchEnd,theaterEnd;
|
||||||
@ -68,7 +67,7 @@ public class Ville {
|
|||||||
|
|
||||||
|
|
||||||
public Ville(int id, String nom, Map<Building, Integer> batiments, Troupes troupes, Map<Integer, Troupes> soutiens,
|
public Ville(int id, String nom, Map<Building, Integer> batiments, Troupes troupes, Map<Integer, Troupes> soutiens,
|
||||||
Map<Integer, Troupes> soutenus, Map<Power, Timestamp> sortileges, Timestamp festivalEnd,
|
Map<Integer, Troupes> soutenus, Set<CastedPower> powers, Timestamp festivalEnd,
|
||||||
Timestamp olympiquesEnd, Timestamp marchEnd, Timestamp theaterEnd, Set<Research> researches,
|
Timestamp olympiquesEnd, Timestamp marchEnd, Timestamp theaterEnd, Set<Research> researches,
|
||||||
List<ResearchQueueItem> researchQueue, List<BuildingQueueItem> buildingQueue, Timestamp miliceUntil,
|
List<ResearchQueueItem> researchQueue, List<BuildingQueueItem> buildingQueue, Timestamp miliceUntil,
|
||||||
Resources storage, List<RecruitmentQueueItem> terrestrialQueue, God god,
|
Resources storage, List<RecruitmentQueueItem> terrestrialQueue, God god,
|
||||||
@ -81,7 +80,7 @@ public class Ville {
|
|||||||
this.troupes = troupes;
|
this.troupes = troupes;
|
||||||
this.soutiens = soutiens;
|
this.soutiens = soutiens;
|
||||||
this.soutenus = soutenus;
|
this.soutenus = soutenus;
|
||||||
this.sortileges = sortileges;
|
this.powers = powers;
|
||||||
this.festivalEnd = festivalEnd;
|
this.festivalEnd = festivalEnd;
|
||||||
this.olympiquesEnd = olympiquesEnd;
|
this.olympiquesEnd = olympiquesEnd;
|
||||||
this.marchEnd = marchEnd;
|
this.marchEnd = marchEnd;
|
||||||
@ -152,8 +151,8 @@ public class Ville {
|
|||||||
return soutenus;
|
return soutenus;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Power, Timestamp> getSortileges() {
|
public Set<CastedPower> getPowers() {
|
||||||
return sortileges;
|
return powers;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Timestamp getFestivalEnd() {
|
public Timestamp getFestivalEnd() {
|
||||||
@ -223,5 +222,15 @@ public class Ville {
|
|||||||
public Set<TradeOrder> getOutgoingTrade() {
|
public Set<TradeOrder> getOutgoingTrade() {
|
||||||
return outgoingTrade;
|
return outgoingTrade;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Hero getHero(){
|
||||||
|
//TODO implement this
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHeroLevel() {
|
||||||
|
//TODO implement this
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -5,18 +5,18 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Building;
|
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
import com.bernard.greposimu.model.game.units.Unit;
|
import com.bernard.greposimu.model.game.units.Unit;
|
||||||
import com.bernard.greposimu.model.simulator.Troupes;
|
|
||||||
import com.bernard.greposimu.model.simulator.Ville;
|
|
||||||
import com.bernard.greposimu.model.simulator.command.BuildCommand;
|
import com.bernard.greposimu.model.simulator.command.BuildCommand;
|
||||||
import com.bernard.greposimu.model.simulator.command.Command;
|
import com.bernard.greposimu.model.simulator.command.Command;
|
||||||
import com.bernard.greposimu.model.simulator.command.HideStoreCommand;
|
import com.bernard.greposimu.model.simulator.command.HideStoreCommand;
|
||||||
import com.bernard.greposimu.model.simulator.command.RecruitCommand;
|
import com.bernard.greposimu.model.simulator.command.RecruitCommand;
|
||||||
import com.bernard.greposimu.model.simulator.command.ResearchCommand;
|
import com.bernard.greposimu.model.simulator.command.ResearchCommand;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Troupes;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Ville;
|
||||||
|
|
||||||
public class TownObjective {
|
public class TownObjective {
|
||||||
GameConfig gc;
|
GameConfig gc;
|
||||||
|
|||||||
@ -10,12 +10,9 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.bernard.greposimu.model.game.Building;
|
|
||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.God;
|
import com.bernard.greposimu.model.game.buildings.Building;
|
||||||
import com.bernard.greposimu.model.game.Resources;
|
import com.bernard.greposimu.model.game.gods.God;
|
||||||
import com.bernard.greposimu.model.game.Timestamp;
|
|
||||||
import com.bernard.greposimu.model.game.UnitResources;
|
|
||||||
import com.bernard.greposimu.model.game.powers.Power;
|
import com.bernard.greposimu.model.game.powers.Power;
|
||||||
import com.bernard.greposimu.model.game.queues.BuildingQueueItem;
|
import com.bernard.greposimu.model.game.queues.BuildingQueueItem;
|
||||||
import com.bernard.greposimu.model.game.queues.RecruitmentQueueItem;
|
import com.bernard.greposimu.model.game.queues.RecruitmentQueueItem;
|
||||||
@ -23,11 +20,15 @@ import com.bernard.greposimu.model.game.queues.RecruitmentQueueItem.RecruitmentK
|
|||||||
import com.bernard.greposimu.model.game.queues.ResearchQueueItem;
|
import com.bernard.greposimu.model.game.queues.ResearchQueueItem;
|
||||||
import com.bernard.greposimu.model.game.researches.Research;
|
import com.bernard.greposimu.model.game.researches.Research;
|
||||||
import com.bernard.greposimu.model.game.units.Unit;
|
import com.bernard.greposimu.model.game.units.Unit;
|
||||||
import com.bernard.greposimu.model.simulator.Joueureuse;
|
import com.bernard.greposimu.model.game.util.Resources;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.game.util.Timestamp;
|
||||||
import com.bernard.greposimu.model.simulator.Troupes;
|
import com.bernard.greposimu.model.game.util.UnitResources;
|
||||||
import com.bernard.greposimu.model.simulator.Ville;
|
import com.bernard.greposimu.model.simulator.data.CastedPower;
|
||||||
import com.bernard.greposimu.model.simulator.Ville.TradeOrder;
|
import com.bernard.greposimu.model.simulator.data.Joueureuse;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Troupes;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Ville;
|
||||||
|
import com.bernard.greposimu.model.simulator.data.Ville.TradeOrder;
|
||||||
import com.fasterxml.jackson.core.exc.StreamReadException;
|
import com.fasterxml.jackson.core.exc.StreamReadException;
|
||||||
import com.fasterxml.jackson.databind.DatabindException;
|
import com.fasterxml.jackson.databind.DatabindException;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
@ -73,7 +74,7 @@ public class JSONSourcer {
|
|||||||
Map<Building,Integer> buildings = new HashMap<>();
|
Map<Building,Integer> buildings = new HashMap<>();
|
||||||
for(String bid : st.buildings.keySet())buildings.put(gc.getBuilding(bid), st.buildings.get(bid));
|
for(String bid : st.buildings.keySet())buildings.put(gc.getBuilding(bid), st.buildings.get(bid));
|
||||||
Set<Research> researches = new HashSet<>();
|
Set<Research> researches = new HashSet<>();
|
||||||
for(String rid : st.researches.keySet())if(st.researches.get(rid))researches.add(gc.getResearch(rid));
|
for(String rid : st.researches.keySet())if(!rid.equals("id") && st.researches.get(rid))researches.add(gc.getResearch(rid));
|
||||||
Map<Integer,Troupes> soutiens = new HashMap<Integer, Troupes>();
|
Map<Integer,Troupes> soutiens = new HashMap<Integer, Troupes>();
|
||||||
Map<Integer,Troupes> soutenus = new HashMap<Integer, Troupes>();
|
Map<Integer,Troupes> soutenus = new HashMap<Integer, Troupes>();
|
||||||
for(SourcedUnits uts : sd.units) {
|
for(SourcedUnits uts : sd.units) {
|
||||||
@ -121,10 +122,18 @@ public class JSONSourcer {
|
|||||||
new Timestamp(sro.getEndTime()),
|
new Timestamp(sro.getEndTime()),
|
||||||
getResources(sro.getRefund())
|
getResources(sro.getRefund())
|
||||||
));
|
));
|
||||||
Map<Power,Timestamp> sortileges = new HashMap<>();
|
|
||||||
for(SourcedCastedPower sp : st.castedPowers) {
|
Set<CastedPower> powers = new HashSet<>();
|
||||||
//TODO
|
for(SourcedCastedPower sp : st.castedPowers)
|
||||||
}
|
powers.add(new CastedPower(
|
||||||
|
sp.getOriginPlayer(),
|
||||||
|
gc.getPower(sp.getPower()),
|
||||||
|
sp.getEndTime()==null?null:new Timestamp(sp.getEndTime()),
|
||||||
|
sp.getId(),
|
||||||
|
sp.getLevel(),
|
||||||
|
sp.getExtended(),
|
||||||
|
sp.getConfiguration()));
|
||||||
|
|
||||||
Set<TradeOrder> incomingTrade = new HashSet<>();
|
Set<TradeOrder> incomingTrade = new HashSet<>();
|
||||||
Set<TradeOrder> outgoingTrade = new HashSet<>();
|
Set<TradeOrder> outgoingTrade = new HashSet<>();
|
||||||
for(SourcedTrades str : sd.trades) {
|
for(SourcedTrades str : sd.trades) {
|
||||||
@ -145,7 +154,7 @@ public class JSONSourcer {
|
|||||||
getTroupes(gc, st.getUnitsTotal()),
|
getTroupes(gc, st.getUnitsTotal()),
|
||||||
soutiens,
|
soutiens,
|
||||||
soutenus,
|
soutenus,
|
||||||
sortileges,
|
powers,
|
||||||
|
|
||||||
townCele.stream().filter(c -> c.type.equals("party")).map(SourcedCelebration::getEnd).map(Timestamp::new).findAny().orElse(null),
|
townCele.stream().filter(c -> c.type.equals("party")).map(SourcedCelebration::getEnd).map(Timestamp::new).findAny().orElse(null),
|
||||||
townCele.stream().filter(c -> c.type.equals("games")).map(SourcedCelebration::getEnd).map(Timestamp::new).findAny().orElse(null),
|
townCele.stream().filter(c -> c.type.equals("games")).map(SourcedCelebration::getEnd).map(Timestamp::new).findAny().orElse(null),
|
||||||
|
|||||||
@ -1,20 +1,18 @@
|
|||||||
package com.bernard.greposimu.source;
|
package com.bernard.greposimu.source;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class SourcedCastedPower {
|
public class SourcedCastedPower {
|
||||||
|
|
||||||
Object configuration;
|
Map<String,Object> configuration;
|
||||||
Long endTime;
|
Long endTime;
|
||||||
int extended;
|
int extended;
|
||||||
Integer level;
|
Integer level;
|
||||||
Long originPlayer;
|
Long originPlayer;
|
||||||
String power;
|
String power;
|
||||||
|
String id;
|
||||||
|
|
||||||
@Override
|
public Map<String,Object> getConfiguration() {
|
||||||
public String toString() {
|
|
||||||
return "SourcedCastedPower [configuration=" + configuration + ", endTime=" + endTime + ", extended=" + extended
|
|
||||||
+ ", level=" + level + ", originPlayer=" + originPlayer + ", power=" + power + "]";
|
|
||||||
}
|
|
||||||
public Object getConfiguration() {
|
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
public Long getEndTime() {
|
public Long getEndTime() {
|
||||||
@ -32,6 +30,8 @@ public class SourcedCastedPower {
|
|||||||
public String getPower() {
|
public String getPower() {
|
||||||
return power;
|
return power;
|
||||||
}
|
}
|
||||||
|
public String getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -95,7 +95,8 @@ function makeObject() {
|
|||||||
extended: order.extended,
|
extended: order.extended,
|
||||||
level: order.level,
|
level: order.level,
|
||||||
originPlayer: order.origin_player_id,
|
originPlayer: order.origin_player_id,
|
||||||
power: order.power_id
|
power: order.power_id,
|
||||||
|
id: order.id
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,7 +13,7 @@ import org.springframework.boot.test.context.SpringBootTest;
|
|||||||
import com.bernard.greposimu.model.game.GameConfig;
|
import com.bernard.greposimu.model.game.GameConfig;
|
||||||
import com.bernard.greposimu.model.game.GrepoYaml;
|
import com.bernard.greposimu.model.game.GrepoYaml;
|
||||||
import com.bernard.greposimu.model.game.units.Unit;
|
import com.bernard.greposimu.model.game.units.Unit;
|
||||||
import com.bernard.greposimu.model.simulator.SimulatorData;
|
import com.bernard.greposimu.model.simulator.data.SimulatorData;
|
||||||
import com.bernard.greposimu.model.simulator.objective.TownObjective;
|
import com.bernard.greposimu.model.simulator.objective.TownObjective;
|
||||||
import com.bernard.greposimu.source.JSONSourcer;
|
import com.bernard.greposimu.source.JSONSourcer;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|||||||
@ -26,7 +26,7 @@ defTerTown:
|
|||||||
- "hoplite"
|
- "hoplite"
|
||||||
- "pottery"
|
- "pottery"
|
||||||
- "instructor"
|
- "instructor"
|
||||||
- "crane"
|
- "building_crane"
|
||||||
- "conscription"
|
- "conscription"
|
||||||
- "cryptography"
|
- "cryptography"
|
||||||
- "plow"
|
- "plow"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user