SteamWar/MissileWars
Archiviert
13
0

Fix SpecialItem
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-07-22 11:06:18 +02:00
Ursprung ea37dc8287
Commit 2b3b885a7b

Datei anzeigen

@ -40,8 +40,7 @@ import java.util.Random;
public abstract class SpecialItem {
private static final Random random = new Random();
private static long missileCount = 0;
private static long supportCount = 0;
private static long count = 0;
private static List<SpecialItem> supportItems = new ArrayList<>();
private static List<SpecialItem> missileItems = new ArrayList<>();
@ -111,20 +110,12 @@ public abstract class SpecialItem {
}
public static ItemStack getRandomItem() {
double missile = missileCount * Config.MissileChance;
double support = supportCount;
double missileChance;
if (missile == 0 && support == 0) {
missileChance = 0.5;
} else {
missileChance = support / (support + missile);
}
double missileChance = Config.MissileChance + (-count) * 0.1;
if (random.nextDouble() > missileChance) {
supportCount++;
count++;
return supportItems.get(random.nextInt(supportItems.size())).getItem();
} else {
missileCount++;
count--;
return missileItems.get(random.nextInt(missileItems.size())).getItem();
}
}