Changed action cards logic. x12
This commit is contained in:
parent
9ad829e997
commit
cd0cb39c6b
@ -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<Player> playerList, List<Synergy> synergies) {
|
||||
|
||||
private List<Player> playerList;
|
||||
private List<Synergy> 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<Player> players, SectionType ct, Long eid) {
|
||||
|
@ -16,7 +16,7 @@ public class Sabotage extends ActionCard {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
this.bot.liveFormula.sub(5.0d / 100.0d);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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<BotApiMethod<? extends Serializable>> 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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user