A bit of fight simulation
This commit is contained in:
parent
6e2f916927
commit
26755f9ecd
@ -15,6 +15,21 @@ import com.bernard.greposimu.model.game.units.Unit;
|
|||||||
|
|
||||||
public class Fight {
|
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) {
|
public static FightStats computeDefStats(GameConfig gc, DefContext def) {
|
||||||
|
|
||||||
FightStats everyoneStatsBonus = FightStats.zero();
|
FightStats everyoneStatsBonus = FightStats.zero();
|
||||||
@ -217,6 +232,11 @@ public class Fight {
|
|||||||
0.0
|
0.0
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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;
|
return total;
|
||||||
}
|
}
|
||||||
@ -239,10 +259,8 @@ public class Fight {
|
|||||||
return gc.getUnits().stream().toList();
|
return gc.getUnits().stream().toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public FightResult simulateFight(OffContext off, DefContext def) {
|
|
||||||
//TODO simulateFight
|
|
||||||
throw new UnsupportedOperationException("Simulator not created");
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class FightResult {
|
public static class FightResult {
|
||||||
|
|
||||||
|
|||||||
@ -70,6 +70,22 @@ public class FightStats implements Cloneable{
|
|||||||
return new FightStats(k * b.hack, k * b.pierce, k * b.distance, k * b.ship);
|
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
|
@Override
|
||||||
public FightStats clone() {
|
public FightStats clone() {
|
||||||
return new FightStats(hack, pierce, distance, ship);
|
return new FightStats(hack, pierce, distance, ship);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user