diff --git a/src/main/java/com/alterdekim/javabot/bot/LiveFormula.java b/src/main/java/com/alterdekim/javabot/bot/LiveFormula.java index d06ea01..3e670e1 100644 --- a/src/main/java/com/alterdekim/javabot/bot/LiveFormula.java +++ b/src/main/java/com/alterdekim/javabot/bot/LiveFormula.java @@ -2,11 +2,21 @@ package com.alterdekim.javabot.bot; import com.alterdekim.javabot.entities.Synergy; import com.alterdekim.javabot.util.Clamp; +import lombok.NoArgsConstructor; +import lombok.Setter; import java.util.List; +@NoArgsConstructor +@Setter public class LiveFormula { - public static double calc(List playerList, List synergies) { + + private List playerList; + private List synergies; + + private double p = 0.0d; + + public double calc() { double i = 0; for( Player p : playerList ) { double age = 1.0D - (((double) p.getAge()) / 75.0D); @@ -33,7 +43,11 @@ public class LiveFormula { Boolean eb = LiveFormula.entity(playerList, s.getSecondType(), s.getSecondEntityId()); if( fb && eb ) i += s.getProbabilityValue().doubleValue() * _i; } - return Clamp.clamp(i * 1.2d, 0, 1); + return Clamp.clamp((i * 1.2d) + p, 0, 1); + } + + public void sub(double p) { + this.p -= p; } private static Boolean entity(List players, SectionType ct, Long eid) { diff --git a/src/main/java/com/alterdekim/javabot/bot/cards/Sabotage.java b/src/main/java/com/alterdekim/javabot/bot/cards/Sabotage.java index 7921896..dc5cd6b 100644 --- a/src/main/java/com/alterdekim/javabot/bot/cards/Sabotage.java +++ b/src/main/java/com/alterdekim/javabot/bot/cards/Sabotage.java @@ -16,7 +16,7 @@ public class Sabotage extends ActionCard { @Override public void execute() { - + this.bot.liveFormula.sub(5.0d / 100.0d); } @Override diff --git a/src/main/java/com/alterdekim/javabot/components/BunkerBot.java b/src/main/java/com/alterdekim/javabot/components/BunkerBot.java index 24d1189..cfa9233 100644 --- a/src/main/java/com/alterdekim/javabot/components/BunkerBot.java +++ b/src/main/java/com/alterdekim/javabot/components/BunkerBot.java @@ -4,10 +4,7 @@ import com.alterdekim.javabot.bot.*; import com.alterdekim.javabot.Commands; import com.alterdekim.javabot.Constants; import com.alterdekim.javabot.TelegramConfig; -import com.alterdekim.javabot.bot.cards.ActionCard; -import com.alterdekim.javabot.bot.cards.ChangeWorksCard; -import com.alterdekim.javabot.bot.cards.RandomHIVCard; -import com.alterdekim.javabot.bot.cards.ScannerCard; +import com.alterdekim.javabot.bot.cards.*; import com.alterdekim.javabot.entities.*; import com.alterdekim.javabot.service.*; import com.alterdekim.javabot.util.*; @@ -63,6 +60,8 @@ public class BunkerBot extends TelegramLongPollingBot { private ConcurrentLinkedQueue> linkedQueue; + public LiveFormula liveFormula; + @SuppressWarnings("deprecation") public BunkerBot(TelegramConfig telegramConfig, BioService bioService, @@ -85,7 +84,7 @@ public class BunkerBot extends TelegramLongPollingBot { this.textDataValService = textDataValService; this.disasterService = disasterService; this.synergyService = synergyService; - this.actionCards = new ArrayList<>(List.of(ScannerCard.class, RandomHIVCard.class, ChangeWorksCard.class)); + this.actionCards = new ArrayList<>(List.of(Sabotage.class)); // ScannerCard.class, RandomHIVCard.class, ChangeWorksCard.class, this.random = randomComponent; this.dayNightFields = new DayNightFields(); this.linkedQueue = new ConcurrentLinkedQueue<>(); @@ -186,6 +185,9 @@ public class BunkerBot extends TelegramLongPollingBot { } Collections.shuffle(players); this.gameState = GameState.STARTED; + this.liveFormula = new LiveFormula(); + this.liveFormula.setPlayerList(players); + this.liveFormula.setSynergies(synergyService.getAllSynergies()); Disaster d = (Disaster) BotUtils.getRandomFromList(disasterService.getAllDisasters(), random); sendApi(new SendMessage(groupId, getStringById(d.getDescTextId()))); //sendApi(new SendMessage(groupId, String.format(Constants.BUNKER_STATS, ))); @@ -345,7 +347,7 @@ public class BunkerBot extends TelegramLongPollingBot { private void doDay() { dayNightFields.setIsNight(false); - double p = Math.floor(LiveFormula.calc(players, synergyService.getAllSynergies())*100d); + double p = Math.floor(this.liveFormula.calc()*100d); if( this.last_p < 0 ) { this.last_p = p; } if( p > this.last_p ) { sendApi(new SendMessage(groupId, String.format(Constants.DAY_MESSAGE_UPPER, (int) p, (p - this.last_p)))); @@ -449,7 +451,7 @@ public class BunkerBot extends TelegramLongPollingBot { } private void endGame() { - double d = Math.floor(LiveFormula.calc(players, synergyService.getAllSynergies())*100d); + double d = Math.floor(this.liveFormula.calc()*100d); sendApi(new SendMessage(groupId, String.format(Constants.END_GAME, d))); if(!players.isEmpty() && Math.floor(random.nextDouble()*100d) <= d) { sendApi(new SendMessage(groupId, String.format(Constants.WIN_MESSAGE,