Compare commits

...

2 Commits

Author SHA1 Message Date
6bc9d4df9d
Des bouts de code faits ... ouais 2024-10-20 19:55:36 +02:00
26755f9ecd
A bit of fight simulation 2024-08-24 17:18:57 +02:00
12 changed files with 251 additions and 4 deletions

View File

@ -15,6 +15,21 @@ import com.bernard.greposimu.model.game.units.Unit;
public class Fight {
public FightResult simulateFight(GameConfig gc, OffContext off, DefContext def) {
FightStats offStats = computeOffStats(gc, off);
FightStats defStats = computeDefStats(gc, def);
// Combat Naval
if(offStats.getShip() > defStats.getShip()) {
// Off wins ship
} else {
}
//TODO simulateFight
throw new UnsupportedOperationException("Simulator not created");
}
public static FightStats computeDefStats(GameConfig gc, DefContext def) {
FightStats everyoneStatsBonus = FightStats.zero();
@ -218,6 +233,11 @@ public class Fight {
));
}
// Bonuses
everyoneStatsBonus = FightStats.add(everyoneStatsBonus, FightStats.cst(off.getLuck()/100.0));
everyoneStatsBonus = FightStats.add(everyoneStatsBonus, FightStats.cst(-(100.0-off.getMorale())/100.0));
return total;
}
@ -239,10 +259,8 @@ public class Fight {
return gc.getUnits().stream().toList();
}
public FightResult simulateFight(OffContext off, DefContext def) {
//TODO simulateFight
throw new UnsupportedOperationException("Simulator not created");
}
public static class FightResult {

View File

@ -70,6 +70,22 @@ public class FightStats implements Cloneable{
return new FightStats(k * b.hack, k * b.pierce, k * b.distance, k * b.ship);
}
public double getHack() {
return hack;
}
public double getPierce() {
return pierce;
}
public double getDistance() {
return distance;
}
public double getShip() {
return ship;
}
@Override
public FightStats clone() {
return new FightStats(hack, pierce, distance, ship);

View File

@ -0,0 +1,26 @@
package com.bernard.greposimu.model.game;
public enum Building {
AGORA,
SENAT,
SCIERIE,
FERME,
CARRIERE,
ENTREPOT,
MINE,
CASERNE,
TEMPLE,
MARCHE,
PORT,
ACADEMIE,
REMPARTS,
GROTTE,
THEATRE,
THERMES,
BIBLIOTHEQUE,
PHARE,
TOUR,
STATUE,
ORACLE,
COMPTOIR;
}

View File

@ -0,0 +1,5 @@
package com.bernard.greposimu.model.runtime;
public class Alliance {
}

View File

@ -0,0 +1,9 @@
package com.bernard.greposimu.model.runtime;
public class Joueureuse {
String nom;
Alliance alliance;
int points;
}

View File

@ -0,0 +1,8 @@
package com.bernard.greposimu.model.runtime;
public class PositionVille {
int ileId;
int x,y,nr,ex,ey,fx,fy;
}

View File

@ -0,0 +1,7 @@
package com.bernard.greposimu.model.runtime;
public class Timestamp {
long timestamp;
}

View File

@ -0,0 +1,18 @@
package com.bernard.greposimu.model.runtime;
import com.bernard.greposimu.model.game.Resources;
public class Ville {
int id;
// null -> Ville fantôme
Joueureuse proprietaire;
PositionVille ville;
Resources resources;
Map<String,Integer> batiments
}

View File

@ -0,0 +1,32 @@
package com.bernard.greposimu.model.simulator;
import java.util.List;
import java.util.Map;
import com.bernard.greposimu.model.game.God;
import com.bernard.greposimu.model.runtime.Timestamp;
public class Joueureuse {
// God
Map<God,Integer> favor;
int rage;
int gold;
// Heroes
// herosId -> townId
Map<String,Integer> heroes;
// herosId -> timeOfArrival
Map<String,Timestamp> heroesArrival;
// herosid -> level
Map<String,Integer> heroesLevel;
List<String> inventory;
//TODO quêtes
//TODO messages/rapports
//TODO profile
//TODO alliance + allianceMessages
}

View File

@ -0,0 +1,9 @@
package com.bernard.greposimu.model.simulator;
import java.util.Map;
public class Troupes {
Map<String,Integer> unites;
}

View File

@ -0,0 +1,88 @@
package com.bernard.greposimu.model.simulator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import com.bernard.greposimu.model.game.God;
import com.bernard.greposimu.model.game.Resources;
import com.bernard.greposimu.model.runtime.Timestamp;
public class Ville {
int id;
String nom;
Map<String,Integer> batiments;
Troupes troupes;
// origin town id -> troupes
Map<Integer,Troupes> soutiens;
// Destination town -> troupes
Map<Integer,Troupes> soutenus;
// sortilegeId -> effectEnd
Map<String,Timestamp> sortileges;
// Agora
Timestamp festivalEnd,olympiquesEnd,marchEnd,theaterEnd;
// Academie
Set<String> researches;
List<QueueItem> researchQueue;
// Senat
List<QueueItem> buildingQueue;
// Farm
Timestamp miliceAppel;
// Entrepôt
Resources storage;
// Caserne
List<QueueItem> terrestrialQueue;
// Temple
God god;
// Port
List<QueueItem> navalQueue;
// Remparts
Troupes slainAsOff,slainAsDef,lostAsOff,lostAsDef;
// Grotte
int piecesStoquees;
/* Ordres */
Set<UnitOrder> ordresMilitaires;
Set<TradeOrder> incomingTrade;
Set<TradeOrder> outgoingTrade;
public static class TradeOrder {
Resources resources;
Integer other;
}
public static class UnitOrder {
Troupes attq;
Timestamp arrivee;
OrderType type;
Set<String> sortileges;
}
public static enum OrderType {
ATTACK,
SUPPORT,
ATTACK_CANCELED,
ATTACK_RETURN;
}
public static class QueueItem {
String buildingId;
Timestamp startTime;
Timestamp endTime;
long duration;
}
}

View File

@ -0,0 +1,11 @@
out = {}
for(var townid in ITowns.towns) {
out[townid] = {}
out[townid].units = ITowns.towns[townid].units()
out[townid].support = ITowns.towns[townid].unitsSupport()
out[townid].outer = ITowns.towns[townid].unitsOuter()
out[townid].resources = ITowns.towns[townid].resources()
out[townid].buildings = ITowns.towns[townid].buildings().getBuildings()
out[townid].researches = ITowns.towns[townid].researches().attributes
}
var json = JSON.stringify(out)