First commit - Working greposimu

This commit is contained in:
MysaaJava 2024-06-12 10:18:41 +02:00
commit 26d8058cf4
Signed by: Mysaa
GPG Key ID: DBA23608F23F5A10
158 changed files with 180284 additions and 0 deletions

47
.gitignore vendored Normal file
View File

@ -0,0 +1,47 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
### Gradle ###
gradle/
gradlew
gradlew.bat
### Eclipse ###
.settings/
.project
.classpath
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM gradle:8.8-jdk17 AS builder
COPY src/ ./src/
COPY build.gradle settings.gradle ./
RUN gradle bootJar
ENTRYPOINT java -jar build/libs/greposimu-0.0.1-SNAPSHOT.jar

34
build.gradle Normal file
View File

@ -0,0 +1,34 @@
plugins {
id 'eclipse'
id 'java'
id 'war'
id 'org.springframework.boot' version '3.3.0'
id 'io.spring.dependency-management' version '1.1.5'
}
group = 'com.bernard'
version = '0.0.1-SNAPSHOT'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
repositories {
mavenCentral()
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.springframework.boot:spring-boot-starter-web'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.yaml:snakeyaml:2.2'
implementation 'org.ojalgo:ojalgo:54.0.0'
}
tasks.named('test') {
useJUnitPlatform()
}

1
settings.gradle Normal file
View File

@ -0,0 +1 @@
rootProject.name = 'greposimu'

View File

@ -0,0 +1,61 @@
package com.bernard.greposimu;
import java.util.Arrays;
import java.util.Iterator;
import com.bernard.greposimu.engine.Registerar;
import com.bernard.greposimu.model.Dieu;
import com.bernard.greposimu.model.Heros;
import com.bernard.greposimu.model.OffDefStats;
public class GrepoSimu {
public static void main(String[] args) {
Registerar.regiter();
System.out.println(Registerar.unites.size());
OffDefStats scoring = new OffDefStats(0, 0, 0, 1.0, 0,0,0,0);
for(Heros h : withNull(Registerar.heros)) {
if(h!= null && h.getNom()!="Agamemnon")continue;
for(int l = 1;l<=20&&h!=null;l+=10-(l%10)) {
for(Dieu d : withNull(Arrays.asList(Dieu.values()))) {
//System.out.println("Héros: "+((c.h==null)?"aucun":("%s (lvl %d)".formatted(h.getNom(),l)))+" - Dieu: "+((d==null)?"aucun":d.getNom()));
//up.print(h, l, 1000);
}
}
}
}
public static final <T> Iterable<T> withNull(Iterable<T> itrble) {
return (Iterable<T>) new Iterable<T>() {
@Override
public Iterator<T> iterator() {
Iterator<T> it = itrble.iterator();
return new Iterator<T>() {
boolean pastNull = false;
@Override
public boolean hasNext() {
return !pastNull || it.hasNext();
}
@Override
public T next() {
if(pastNull)
return it.next();
else {
pastNull = true;
return null;
}
}
};
};
};
}
}

View File

@ -0,0 +1,16 @@
package com.bernard.greposimu;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import com.bernard.greposimu.engine.Registerar;
@SpringBootApplication
public class GrepoSimuApplication {
public static void main(String[] args) {
Registerar.regiter();
SpringApplication.run(GrepoSimuApplication.class, args);
}
}

View File

@ -0,0 +1,28 @@
package com.bernard.greposimu;
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.context.support.GenericWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.ServletRegistration;
public class MainWebAppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(final ServletContext sc) throws ServletException {
AnnotationConfigWebApplicationContext root =
new AnnotationConfigWebApplicationContext();
root.scan("com.bernard.greposimu");
sc.addListener(new ContextLoaderListener(root));
ServletRegistration.Dynamic appServlet =
sc.addServlet("mvc", new DispatcherServlet(new GenericWebApplicationContext()));
appServlet.setLoadOnStartup(1);
appServlet.addMapping("/");
}
}

View File

@ -0,0 +1,237 @@
package com.bernard.greposimu.controller;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import com.bernard.greposimu.engine.Optimizer;
import com.bernard.greposimu.engine.Optimizer.UnitesProportions;
import com.bernard.greposimu.engine.Registerar;
import com.bernard.greposimu.model.Dieu;
import com.bernard.greposimu.model.Heros;
import com.bernard.greposimu.model.OffDefStats;
import com.bernard.greposimu.model.Unite;
@Controller
public class GrepoSimuController {
@GetMapping("/optimizer")
public String greeting(Model model) {
model.addAttribute("heros", Registerar.heros);
// Liste des unités
Map<String,List<Unite>> godUnites = Registerar.unites.stream()
.filter(u -> u.getDieu() != null)
.collect(Collectors.groupingBy(u -> u.getDieu().getPname()));
List<Unite> otherUnites = Registerar.unites.stream()
.filter(u -> u.getDieu() == null)
.collect(Collectors.toList());
System.out.println(godUnites);
model.addAttribute("otherunites", otherUnites);
model.addAttribute("godunites", godUnites);
model.addAttribute("dieux", Arrays.stream(Dieu.values()).map(Dieu::getPname).collect(Collectors.toList()));
model.addAttribute("optinput", new OptimizerInput());
return "optimizer";
}
@PostMapping("/optimizer")
public String greetingSubmit(@ModelAttribute OptimizerInput optinput, Model model) {
Optimizer.Contexte ctx = new Optimizer.Contexte();
ctx.h = Registerar.getHeros(optinput.heros);
ctx.level = optinput.herosLvl;
ctx.scoring = optinput.getOffDefStats();
ctx.d = null;
Set<Unite> unites = Registerar.unites.stream().filter(u -> optinput.unites.get(u.getPname())).collect(Collectors.toSet());
Map<String,OptimizerOutput> outputs = new HashMap<>();
outputs.put("none", new OptimizerOutput(Optimizer.optimize(ctx,unites), ctx.h, ctx.level, optinput.population));
for(Dieu d : Dieu.values()) {
ctx.d = d;
outputs.put(d.getPname(), new OptimizerOutput(Optimizer.optimize(ctx,unites), ctx.h, ctx.level, optinput.population));
}
model.addAttribute("dieux", Arrays.stream(Dieu.values()).map(Dieu::getPname).collect(Collectors.toList()));
model.addAttribute("outputs", outputs);
model.addAttribute("requestedPop",optinput.population);
return "optimizerResult";
}
public static class OptimizerInput {
public String heros = Registerar.heros.stream().map(Heros::getPname).min(Comparator.comparing(Function.identity())).get();
public int herosLvl = 1;
public double att_hack_proportion = 0.0;
public double att_pierce_proportion = 0.0;
public double att_distance_proportion = 0.0;
public double ship_attack_proportion = 0.0;
public double def_hack_proportion = 1.0;
public double def_pierce_proportion = 1.0;
public double def_distance_proportion = 1.0;
public double ship_defense_proportion = 1.0;
public int population = 1000;
public Map<String,Boolean> unites = Registerar.unites.stream().collect(Collectors.toMap(Unite::getPname, u -> true));
public String getHeros() {
return heros;
}
public void setHeros(String heros) {
this.heros = heros;
}
public int getHerosLvl() {
return herosLvl;
}
public void setHerosLvl(int herosLvl) {
this.herosLvl = herosLvl;
}
public double getAtt_hack_proportion() {
return att_hack_proportion;
}
public void setAtt_hack_proportion(double att_hack_proportion) {
this.att_hack_proportion = att_hack_proportion;
}
public double getAtt_pierce_proportion() {
return att_pierce_proportion;
}
public void setAtt_pierce_proportion(double att_pierce_proportion) {
this.att_pierce_proportion = att_pierce_proportion;
}
public double getAtt_distance_proportion() {
return att_distance_proportion;
}
public void setAtt_distance_proportion(double att_distance_proportion) {
this.att_distance_proportion = att_distance_proportion;
}
public double getShip_attack_proportion() {
return ship_attack_proportion;
}
public void setShip_attack_proportion(double ship_attack_proportion) {
this.ship_attack_proportion = ship_attack_proportion;
}
public double getDef_hack_proportion() {
return def_hack_proportion;
}
public void setDef_hack_proportion(double def_hack_proportion) {
this.def_hack_proportion = def_hack_proportion;
}
public double getDef_pierce_proportion() {
return def_pierce_proportion;
}
public void setDef_pierce_proportion(double def_pierce_proportion) {
this.def_pierce_proportion = def_pierce_proportion;
}
public double getDef_distance_proportion() {
return def_distance_proportion;
}
public void setDef_distance_proportion(double def_distance_proportion) {
this.def_distance_proportion = def_distance_proportion;
}
public double getShip_defense_proportion() {
return ship_defense_proportion;
}
public void setShip_defense_proportion(double ship_defense_proportion) {
this.ship_defense_proportion = ship_defense_proportion;
}
public int getPopulation() {
return population;
}
public void setPopulation(int population) {
this.population = population;
}
public Map<String, Boolean> getUnites() {
return unites;
}
public void setUnites(Map<String, Boolean> unites) {
this.unites = unites;
}
public OffDefStats getOffDefStats() {
return new OffDefStats(att_hack_proportion, att_pierce_proportion, att_distance_proportion, ship_attack_proportion, def_hack_proportion, def_pierce_proportion, def_distance_proportion, ship_defense_proportion);
}
@Override
public String toString() {
return "OptimizerInput [heros=" + heros + ", herosLvl=" + herosLvl + ", att_hack_proportion="
+ att_hack_proportion + ", att_pierce_proportion=" + att_pierce_proportion
+ ", att_distance_proportion=" + att_distance_proportion + ", ship_attack_proportion="
+ ship_attack_proportion + ", def_hack_proportion=" + def_hack_proportion
+ ", def_pierce_proportion=" + def_pierce_proportion + ", def_distance_proportion="
+ def_distance_proportion + ", ship_defense_proportion=" + ship_defense_proportion + ", population="
+ population + ", unites=" + unites + "]";
}
}
public static class OptimizerOutput {
OffDefStats total;
int totalpop;
List<Unite> unites;
Map<Unite,Integer> ucounts;
public OptimizerOutput(UnitesProportions data, Heros h, int level, int pop) {
this.ucounts = new HashMap<>(data.getData().size());
for(Unite u : data.getData().keySet())
this.ucounts.put(u, (int) Math.floor((data.getData().get(u) * pop) / u.getPopulation()));
this.unites = Registerar.unites.stream().filter(u -> ucounts.containsKey(u)).toList();
this.totalpop = this.ucounts.entrySet().stream().mapToInt(e -> e.getKey().getPopulation() * e.getValue()).sum();
this.total = this.ucounts.entrySet().stream()
.map(e -> ((h==null)?e.getKey().getStats():h.applyToUnit(e.getKey(), level)).times(e.getValue()))
.reduce(OffDefStats.zero,(a,b) -> a.plus(b));
}
public OffDefStats getTotal() {
return total;
}
public int getTotalpop() {
return totalpop;
}
public Map<Unite, Integer> getUcounts() {
return ucounts;
}
public List<Unite> getUnites() {
return unites;
}
}
}

View File

@ -0,0 +1,116 @@
package com.bernard.greposimu.engine;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Function;
import java.util.stream.Collectors;
import org.ojalgo.optimisation.Expression;
import org.ojalgo.optimisation.ExpressionsBasedModel;
import org.ojalgo.optimisation.Optimisation;
import org.ojalgo.optimisation.Optimisation.Result;
import org.ojalgo.optimisation.Variable;
import com.bernard.greposimu.model.Dieu;
import com.bernard.greposimu.model.Heros;
import com.bernard.greposimu.model.OffDefStats;
import com.bernard.greposimu.model.Unite;
public class Optimizer {
public static UnitesProportions optimize(Contexte c,Set<Unite> uniteList) {
// Computing the stats of the unités in this context
Map<Unite,OffDefStats> stats = uniteList.stream()
.filter(u -> u.getDieu() == null || u.getDieu().equals(c.d))
.collect(Collectors.toMap(
Function.identity(),
u -> (OffDefStats)((c.h==null)?u.getStats():c.h.applyToUnit(u, c.level)).div(u.getPopulation())
));
// Clean list of unités
List<Unite> unites = stats.keySet().stream().sorted((u,v) -> u.getNom().compareTo(v.getNom())).toList();
// Création du modèle
ExpressionsBasedModel model = new ExpressionsBasedModel();
// Variable à optimiser
Variable y = model.addVariable("y").weight(1.0);
// Création des variables correspondant aux proportions, elles ne sont pas «optimisées» (weight 0.0) et sont positives
List<Variable> varz = new ArrayList<>(unites.size());
for(Unite u : unites) {
Variable xi = model.addVariable(u.getNom()).weight(0.0);
model.addExpression().lower(0.0).set(xi, 1.0); // 0 <= x_i
varz.add(xi);
}
// Les proportions doivent être maximalement 1 (en pratique, 1, parce que croissante)
Expression esum = model.addExpression().upper(1.0);
// y doit se comparer à chaque somme suivant ce que le scoring précise
Expression eAttqCont = model.addExpression().lower(0.0).set(y, -c.scoring.getAttqCont()); // y <= sum(a_1_i * x_i)
Expression eAttqBlan = model.addExpression().lower(0.0).set(y, -c.scoring.getAttqBlan()); // y <= sum(a_1_i * x_i)
Expression eAttqJet = model.addExpression().lower(0.0).set(y, -c.scoring.getAttqJet() ); // y <= sum(a_1_i * x_i)
Expression eAttqNav = model.addExpression().lower(0.0).set(y, -c.scoring.getAttqNav() ); // y <= sum(a_1_i * x_i)
Expression eDefCont = model.addExpression().lower(0.0).set(y, -c.scoring.getDefCont() ); // y <= sum(a_1_i * x_i)
Expression eDefBlan = model.addExpression().lower(0.0).set(y, -c.scoring.getDefBlan() ); // y <= sum(a_1_i * x_i)
Expression eDefJet = model.addExpression().lower(0.0).set(y, -c.scoring.getDefJet() ); // y <= sum(a_1_i * x_i)
Expression eDefNav = model.addExpression().lower(0.0).set(y, -c.scoring.getDefNav() ); // y <= sum(a_1_i * x_i)
for(int i=0;i<varz.size();i++) {
esum.set(varz.get(i), 1.0);
eAttqCont.set(varz.get(i), stats.get(unites.get(i)).getAttqCont());
eAttqBlan.set(varz.get(i), stats.get(unites.get(i)).getAttqBlan());
eAttqJet .set(varz.get(i), stats.get(unites.get(i)).getAttqJet());
eAttqNav .set(varz.get(i), stats.get(unites.get(i)).getAttqNav());
eDefCont .set(varz.get(i), stats.get(unites.get(i)).getDefCont());
eDefBlan .set(varz.get(i), stats.get(unites.get(i)).getDefBlan());
eDefJet .set(varz.get(i), stats.get(unites.get(i)).getDefJet());
eDefNav .set(varz.get(i), stats.get(unites.get(i)).getDefNav());
}
Result r = model.maximise(); // maximize y
return new UnitesProportions(unites, r);
}
public static class UnitesProportions {
Map<Unite,Double> data;
public UnitesProportions(List<Unite> unites, Optimisation.Result result) {
this.data = new HashMap<>();
for(int i=0;i<unites.size();i++) {
double val = result.doubleValue(1+i);
if(val>=0.0001) {
this.data.put(unites.get(i), val);
}
}
}
public void print(Heros h, int level, int pop) {
Map<Unite,Integer> ucounts = new HashMap<>(data.size());
for(Unite u : data.keySet())
ucounts.put(u, (int) Math.floor((data.get(u) * pop) / u.getPopulation()));
int totalpop = ucounts.entrySet().stream().mapToInt(e -> e.getKey().getPopulation() * e.getValue()).sum();
OffDefStats t = ucounts.entrySet().stream()
.map(e -> h.applyToUnit(e.getKey(), level).times(e.getValue()))
.reduce(OffDefStats.zero,(a,b) -> a.plus(b));
System.out.println("Population totale de %d".formatted(totalpop));
for(Unite u : data.keySet())
System.out.println("|-- %d %s (%.1f%% de la population)".formatted(ucounts.get(u),u.getNom(),data.get(u)*100));
System.out.println("--- Attaque (%d,%d,%d,%d) Défense (%d,%d,%d,%d)".formatted(
(int)t.getAttqCont(),(int)t.getAttqBlan(),(int)t.getAttqJet(),(int)t.getAttqNav(),(int)t.getDefCont(),(int)t.getDefBlan(),(int)t.getDefJet(),(int)t.getDefNav()
));
}
public Map<Unite, Double> getData() {
return data;
}
}
public static class Contexte {
public Dieu d;
public Heros h;
public int level;
public OffDefStats scoring;
}
}

View File

@ -0,0 +1,114 @@
package com.bernard.greposimu.engine;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import com.bernard.greposimu.model.Dieu;
import com.bernard.greposimu.model.Heros;
import com.bernard.greposimu.model.OffDefStats;
import com.bernard.greposimu.model.Unite;
public class Registerar {
public static List<Unite> unites;
public static List<Heros> heros;
public static Heros getHeros(String pname) {
return heros.stream().filter(h -> h.getPname().equals(pname)).findAny().orElse(null);
}
public static List<Unite> getUnites(Dieu dieu) {
return unites.stream().filter(u -> u.getDieu() == null || u.getDieu().equals(dieu)).collect(Collectors.toList());
}
public static void addHeros(
String nom,
String pname,
Set<String> appliedToNames,
boolean appTerrestre,
boolean appNavale,
boolean appMythique,
double attqContZero,
double attqContPlus,
double attqBlanZero,
double attqBlanPlus,
double attqJetZero,
double attqJetPlus,
double attqNavZero,
double attqNavPlus,
double defContZero,
double defContPlus,
double defBlanZero,
double defBlanPlus,
double defJetZero,
double defJetPlus,
double defNavZero,
double defNavPlus) {
heros.add(new Heros(
nom, pname, appliedToNames, appTerrestre, appNavale, appMythique,
new OffDefStats(attqContZero, attqBlanZero, attqJetZero, attqNavZero, defContZero, defBlanZero, defJetZero, defNavZero),
new OffDefStats(attqContPlus, attqBlanPlus, attqJetPlus, attqNavPlus, defContPlus, defBlanPlus, defJetPlus, defNavPlus)
));
}
public static void addUnite(String nom, String pname, int population, int speed, int butin, double attqCont, double attqBlan, double attqJet, double attqNav, double defCont, double defBlan,
double defJet, double defNav, boolean terrestre, boolean navale,
boolean mythique, Dieu dieu) {
unites.add(new Unite(
nom, pname, population, speed, butin,
new OffDefStats(attqCont, attqBlan, attqJet, attqNav, defCont, defBlan, defJet, defNav),
terrestre, navale, mythique, dieu
));
}
public static void regiter() {
unites = new ArrayList<Unite>();
addUnite("Combattant à l'épée","sword",1,8,16,5.0,0.0,0.0,0.0,14.0,8.0,30.0,0.0,true,false,false,null);
addUnite("Frondeur","slinger",1,14,8,0.0,0.0,23.0,0.0,7.0,8.0,2.0,0.0,true,false,false,null);
addUnite("Archer","archer",1,12,24,0.0,0.0,8.0,0.0,7.0,25.0,13.0,0.0,true,false,false,null);
addUnite("Hoplite","hoplite",1,6,8,0.0,16.0,0.0,0.0,18.0,12.0,7.0,0.0,true,false,false,null);
addUnite("Cavalier","rider",3,22,72,60.0,0.0,0.0,0.0,18.0,1.0,24.0,0.0,true,false,false,null);
addUnite("Char","chariot",4,18,64,0.0,56.0,0.0,0.0,76.0,16.0,56.0,0.0,true,false,false,null);
addUnite("Catapulte","catapult",15,2,400,0.0,0.0,100.0,0.0,30.0,30.0,30.0,0.0,true,false,false,null);
addUnite("Envoyé divin","godsent",3,16,5,45.0,0.0,0.0,0.0,40.0,40.0,40.0,0.0,true,false,true,null);
addUnite("Centaure","centaur",12,18,200,0.0,0.0,134.0,0.0,195.0,585.0,80.0,0.0,true,false,true,Dieu.ATHENA);
addUnite("Cerbère","cerberus",30,4,240,210.0,0.0,0.0,0.0,825.0,300.0,1575.0,0.0,true,false,true,Dieu.HADES);
addUnite("Cyclope","zyklop",40,8,320,0.0,0.0,1035.0,0.0,1050.0,10.0,1450.0,0.0,true,false,true,Dieu.POSEIDON);
addUnite("Érinye","fury",55,10,440,0.0,0.0,1700.0,0.0,460.0,460.0,595.0,0.0,true,false,true,Dieu.HADES);
addUnite("Méduse","medusa",18,6,400,0.0,425.0,0.0,0.0,480.0,345.0,290.0,0.0,true,false,true,Dieu.HERA);
addUnite("Minotaure","minotaur",30,10,480,650.0,0.0,0.0,0.0,750.0,330.0,640.0,0.0,true,false,true,Dieu.ZEUS);
addUnite("Sanglier","calydonian_boar",20,16,240,0.0,180.0,0.0,0.0,700.0,700.0,100.0,0.0,true,false,true,Dieu.ARTEMIS);
addUnite("Satyre","satyr",16,136,335,0.0,385.0,0.0,0.0,55.0,105.0,170.0,0.0,true,false,true,Dieu.APHRODITE);
addUnite("Sparte","spartoi",10,16,275,205.0,0.0,0.0,0.0,100.0,100.0,150.0,0.0,true,false,true,Dieu.ARES);
addUnite("Harpie","harpy",14,28,340,295.0,0.0,0.0,0.0,105.0,70.0,1.0,0.0,true,false,true,Dieu.HERA);
addUnite("Manticore","manticore",45,22,360,0.0,1010.0,0.0,0.0,170.0,225.0,505.0,0.0,true,false,true,Dieu.ZEUS);
addUnite("Pégase","pegasus",20,35,160,0.0,100.0,0.0,0.0,750.0,275.0,275.0,0.0,true,false,true,Dieu.ATHENA);
addUnite("Griffon","griffin",35,18,350,900.0,0.0,0.0,0.0,320.0,330.0,100.0,0.0,true,false,true,Dieu.ARTEMIS);
addUnite("Ladon","ladon",85,40,1000,0.0,0.0,1195.0,0.0,478.0,390.0,420.0,0.0,true,false,true,Dieu.ARES);
addUnite("Birème","bireme",8,15,0,0.0,0.0,0.0,24.0,0.0,0.0,0.0,160.0,false,true,false,null);
addUnite("Bateau-feu","attack_ship",10,13,0,0.0,0.0,0.0,200.0,0.0,0.0,0.0,60.0,false,true,false,null);
addUnite("Trière","trireme",16,15,0,0.0,0.0,0.0,250.0,0.0,0.0,0.0,250.0,false,true,false,null);
addUnite("Hydre","sea_monster",50,8,0,0.0,0.0,0.0,1310.0,0.0,0.0,0.0,1400.0,false,false,true,Dieu.POSEIDON);
addUnite("Sirène","siren",16,22,0,0.0,0.0,0.0,180.0,0.0,0.0,0.0,170.0,false,false,true,Dieu.APHRODITE);
//addUnite("Ladon (max)","ladon",85000,40,1000,0.0,0.0,2988.0,0.0,478.0,390.0,420.0,0.0,true,false,true,Dieu.ARES);
heros = new ArrayList<Heros>();
addHeros("Agamemnon","agamemnon",Set.of("hoplite","archer"),false,false,false,0.100,0.010,0.100,0.010,0.100,0.010,0.000,0.000,0.100,0.010,0.100,0.010,0.100,0.010,0.000,0.000);
addHeros("Ajax","ajax",Set.of("hoplites"),false,false,false,0.150,0.015,0.150,0.015,0.150,0.015,0.000,0.000,0.150,0.015,0.150,0.015,0.150,0.015,0.000,0.000);
addHeros("Alexandrios","alexandrios",Set.of("archers"),false,false,false,0.150,0.010,0.150,0.010,0.150,0.010,0.000,0.000,0.150,0.010,0.150,0.010,0.150,0.010,0.000,0.000);
addHeros("Déimos","deimos",Set.of(),true,true,true,0.050,0.005,0.050,0.005,0.050,0.005,0.050,0.005,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000);
addHeros("Hector","hector",Set.of("sword","slinger"),false,false,false,0.100,0.010,0.100,0.010,0.100,0.010,0.000,0.000,0.100,0.010,0.100,0.010,0.100,0.010,0.000,0.000);
addHeros("Lysippe","lysippe",Set.of("rider"),false,false,false,0.150,0.010,0.150,0.010,0.150,0.010,0.000,0.000,0.150,0.010,0.150,0.010,0.150,0.010,0.000,0.000);
addHeros("Léonidas","leonidas",Set.of(),true,true,true,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.050,0.005,0.050,0.005,0.050,0.005,0.050,0.005);
addHeros("Mihalis","mihalis",Set.of(),true,false,false,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.000,0.100,0.010,0.100,0.010,0.000,0.000,0.000,0.000);
addHeros("Médée","medea",Set.of("slinger"),false,false,false,0.150,0.015,0.150,0.015,0.150,0.015,0.000,0.000,0.150,0.015,0.150,0.015,0.150,0.015,0.000,0.000);
addHeros("Mélousa","melousa",Set.of("chariot"),false,false,false,0.150,0.010,0.150,0.010,0.150,0.010,0.000,0.000,0.150,0.010,0.150,0.010,0.150,0.010,0.000,0.000);
addHeros("Pélops","pelops",Set.of("hoplite","chariot"),false,false,false,0.100,0.010,0.100,0.010,0.100,0.010,0.000,0.000,0.100,0.010,0.100,0.010,0.100,0.010,0.000,0.000);
addHeros("Thémistocle","themistokles",Set.of("godsent","rider"),false,false,false,0.100,0.010,0.100,0.010,0.100,0.010,0.000,0.000,0.100,0.010,0.100,0.010,0.100,0.010,0.000,0.000);
addHeros("Télémaque","telemachos",Set.of("sword"),false,false,false,0.150,0.015,0.150,0.015,0.150,0.015,0.000,0.000,0.150,0.015,0.150,0.015,0.150,0.015,0.000,0.000);
addHeros("Urephon","urephon",Set.of(),false,false,true,0.050,0.005,0.050,0.005,0.050,0.005,0.050,0.005,0.050,0.005,0.050,0.005,0.050,0.005,0.050,0.005);
addHeros("Zuretha","zuretha",Set.of(),false,true,false,0.000,0.000,0.000,0.000,0.000,0.000,0.050,0.005,0.000,0.000,0.000,0.000,0.000,0.000,0.050,0.005);
}
}

View File

@ -0,0 +1,28 @@
package com.bernard.greposimu.model;
public enum Dieu {
ZEUS("Zeus","zeus"),
POSEIDON("Poséidon","poseidon"),
HERA("Héra","hera"),
ATHENA("Athéna","athena"),
HADES("Hadès","hades"),
ARTEMIS("Artémis","artemis"),
APHRODITE("Aphrodite","aphrodite"),
ARES("Arès","ares");
String nom;
String pname;
Dieu(String nom,String pname){
this.nom = nom;
this.pname = pname;
}
public String getNom() {
return nom;
}
public String getPname() {
return pname;
}
}

View File

@ -0,0 +1,87 @@
package com.bernard.greposimu.model;
import java.util.Set;
public class Heros {
String nom;
String pname;
Set<String> appliedToNames;
boolean appTerrestre,appNavale,appMythique;
OffDefStats statsZero;
OffDefStats statsPlus;
public Heros(String nom, String pname, Set<String> appliedToNames, boolean appTerrestre, boolean appNavale, boolean appMythique,
OffDefStats statsZero, OffDefStats statsPlus) {
this.nom = nom;
this.pname = pname;
this.appliedToNames = appliedToNames;
this.appTerrestre = appTerrestre;
this.appNavale = appNavale;
this.appMythique = appMythique;
this.statsZero = statsZero;
this.statsPlus = statsPlus;
}
public OffDefStats applyToUnit(Unite unite,int level) {
if((appTerrestre && unite.terrestre) ||
(appNavale && unite.navale) ||
(appMythique && unite.mythique) ||
appliedToNames.contains(unite.pname)) {
return unite.stats.plus(unite.stats.prod(statsZero.plus(statsPlus.times(level))));
}
return unite.stats;
}
public String getNom() {
return nom;
}
public String getPname() {
return pname;
}
public Set<String> getAppliedToNames() {
return appliedToNames;
}
public boolean isAppTerrestre() {
return appTerrestre;
}
public boolean isAppNavale() {
return appNavale;
}
public boolean isAppMythique() {
return appMythique;
}
public OffDefStats getStatsZero() {
return statsZero;
}
public OffDefStats getStatsPlus() {
return statsPlus;
}
}

View File

@ -0,0 +1,182 @@
package com.bernard.greposimu.model;
public class OffDefStats {
double att_hack;
double att_pierce;
double att_distance;
double ship_attack;
double def_hack;
double def_pierce;
double def_distance;
double ship_defense;
public OffDefStats(double attqCont, double attqBlan, double attqJet, double attqNav, double defCont, double defBlan,
double defJet, double defNav) {
this.att_hack = attqCont;
this.att_pierce = attqBlan;
this.att_distance = attqJet;
this.ship_attack = attqNav;
this.def_hack = defCont;
this.def_pierce = defBlan;
this.def_distance = defJet;
this.ship_defense = defNav;
}
public static final OffDefStats zero = new OffDefStats(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
public OffDefStats plus(OffDefStats other) {
return new OffDefStats(
this.att_hack + other.att_hack,
this.att_pierce + other.att_pierce,
this.att_distance + other.att_distance ,
this.ship_attack + other.ship_attack ,
this.def_hack + other.def_hack ,
this.def_pierce + other.def_pierce ,
this.def_distance + other.def_distance ,
this.ship_defense + other.ship_defense
);
}
public OffDefStats prod(OffDefStats other) {
return new OffDefStats(
this.att_hack * other.att_hack,
this.att_pierce * other.att_pierce,
this.att_distance * other.att_distance ,
this.ship_attack * other.ship_attack ,
this.def_hack * other.def_hack ,
this.def_pierce * other.def_pierce ,
this.def_distance * other.def_distance ,
this.ship_defense * other.ship_defense
);
}
public OffDefStats times(int factor) {
return new OffDefStats(
this.att_hack * factor,
this.att_pierce * factor,
this.att_distance * factor,
this.ship_attack * factor,
this.def_hack * factor,
this.def_pierce * factor,
this.def_distance * factor,
this.ship_defense * factor
);
}
public OffDefStats div(int factor) {
return new OffDefStats(
this.att_hack / factor,
this.att_pierce / factor,
this.att_distance / factor,
this.ship_attack / factor,
this.def_hack / factor,
this.def_pierce / factor,
this.def_distance / factor,
this.ship_defense / factor
);
}
public double getAttqCont() {
return att_hack;
}
public void setAttqCont(double attqCont) {
this.att_hack = attqCont;
}
public double getAttqBlan() {
return att_pierce;
}
public void setAttqBlan(double attqBlan) {
this.att_pierce = attqBlan;
}
public double getAttqJet() {
return att_distance;
}
public void setAttqJet(double attqJet) {
this.att_distance = attqJet;
}
public double getAttqNav() {
return ship_attack;
}
public void setAttqNav(double attqNav) {
this.ship_attack = attqNav;
}
public double getDefCont() {
return def_hack;
}
public void setDefCont(double defCont) {
this.def_hack = defCont;
}
public double getDefBlan() {
return def_pierce;
}
public void setDefBlan(double defBlan) {
this.def_pierce = defBlan;
}
public double getDefJet() {
return def_distance;
}
public void setDefJet(double defJet) {
this.def_distance = defJet;
}
public double getDefNav() {
return ship_defense;
}
public void setDefNav(double defNav) {
this.ship_defense = defNav;
}
public double getAtt_hack() {
return att_hack;
}
public double getAtt_pierce() {
return att_pierce;
}
public double getAtt_distance() {
return att_distance;
}
public double getShip_attack() {
return ship_attack;
}
public double getDef_hack() {
return def_hack;
}
public double getDef_pierce() {
return def_pierce;
}
public double getDef_distance() {
return def_distance;
}
public double getShip_defense() {
return ship_defense;
}
public static OffDefStats getZero() {
return zero;
}
}

View File

@ -0,0 +1,74 @@
package com.bernard.greposimu.model;
public class Unite {
String nom;
String pname;
int population;
int speed;
int butin;
OffDefStats stats;
boolean terrestre,navale,mythique;
Dieu dieu;
public Unite(String nom, String pname, int population, int speed, int butin, OffDefStats stats, boolean terrestre, boolean navale,
boolean mythique, Dieu dieu) {
this.nom = nom;
this.pname = pname;
this.population = population;
this.speed = speed;
this.butin = butin;
this.stats = stats;
this.terrestre = terrestre;
this.navale = navale;
this.mythique = mythique;
this.dieu = dieu;
}
public String getNom() {
return nom;
}
public String getPname() {
return pname;
}
public int getPopulation() {
return population;
}
public int getSpeed() {
return speed;
}
public int getButin() {
return butin;
}
public OffDefStats getStats() {
return stats;
}
public boolean isTerrestre() {
return terrestre;
}
public boolean isNavale() {
return navale;
}
public boolean isMythique() {
return mythique;
}
public Dieu getDieu() {
return dieu;
}
}

View File

@ -0,0 +1,3 @@
spring.application.name=GrepoSimu
spring.devtools.restart.pollInterval=10s
spring.mvc.favicon.enabled=false

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

View File

@ -0,0 +1,2 @@
https://gpfr.innogamescdn.com/images/game/autogenerated/gods/gods_temple_13fb61e.png
IFS=$'\n'; for k in $(cat /tmp/gods.json | jq "keys[]"); do width=$(cat /tmp/gods.json | jq ".[$k].width"); height=$(cat /tmp/gods.json | jq ".[$k].height"); top=$(cat /tmp/gods.json | jq ".[$k].background" | cut -d' ' -f3); left=$(cat /tmp/gods.json | jq ".[$k].background" | cut -d' ' -f4); convert -crop "${width:1:-3}x${height:1:-3}+${top:1:-2}+${left:1:-3}" /tmp/gods.png src/main/resources/static/gods_temple/${k:26:-1}.png; done

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 98 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 79 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 991 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Some files were not shown because too many files have changed in this diff Show More