A bit of fight simulation

This commit is contained in:
Samy Avrillon 2024-08-24 17:18:57 +02:00
parent 6e2f916927
commit 26755f9ecd
Signed by: Mysaa
GPG Key ID: 0220AC4A3D6A328B
2 changed files with 38 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);