Changed action cards logic. x13
This commit is contained in:
parent
cd0cb39c6b
commit
d8e47ee70b
@ -64,4 +64,21 @@ public interface Constants {
|
||||
String SCANNER_TRIGGERED = "Сканнер нашел скрытую стату игрока %s, %s";
|
||||
|
||||
String SABOTAGE_CARD = "Саботаж";
|
||||
String GODS_WILL_CARD = "Божья воля";
|
||||
|
||||
String CHANGE_HOBBY_CARD = "Обменяться хобби";
|
||||
|
||||
String CHANGE_HOBBY_TRIGGERED = "Вы обменялись хобби с игроком %s";
|
||||
|
||||
String CHANGE_LUGGAGE_CARD = "Обменяться багажом";
|
||||
|
||||
String CHANGE_LUGGAGE_TRIGGERED = "Вы обменялись багажом с игроком %s";
|
||||
|
||||
String STEAL_LUGGAGE_CARD = "Украсть багаж";
|
||||
|
||||
String STEAL_LUGGAGE_TRIGGERED = "Вы украли багаж у игрока %s";
|
||||
|
||||
String RESURRECTION_CARD = "Воскресить игрока";
|
||||
|
||||
String RESURRECTION_CARD_TRIGGERED = "Вы воскресили игрока %s";
|
||||
}
|
@ -50,6 +50,10 @@ public class LiveFormula {
|
||||
this.p -= p;
|
||||
}
|
||||
|
||||
public void add(double p) {
|
||||
this.p += p;
|
||||
}
|
||||
|
||||
private static Boolean entity(List<Player> players, SectionType ct, Long eid) {
|
||||
return switch (ct) {
|
||||
case GENDER -> LiveFormula.searchForBio(players, eid);
|
||||
|
@ -0,0 +1,32 @@
|
||||
package com.alterdekim.javabot.bot.cards;
|
||||
|
||||
import com.alterdekim.javabot.Constants;
|
||||
import com.alterdekim.javabot.bot.Player;
|
||||
import com.alterdekim.javabot.components.BunkerBot;
|
||||
import com.alterdekim.javabot.entities.Hobby;
|
||||
import com.alterdekim.javabot.entities.Work;
|
||||
import com.alterdekim.javabot.util.BotUtils;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||
|
||||
public class ChangeHobbyCard extends ActionCard {
|
||||
public ChangeHobbyCard(BunkerBot bot, Player activator) {
|
||||
super(bot, activator);
|
||||
}
|
||||
|
||||
public ChangeHobbyCard() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Player p = (Player) BotUtils.getRandomFromList(this.bot.players, this.bot.random);
|
||||
Hobby w = this.activator.getHobby();
|
||||
this.activator.setHobby(p.getHobby());
|
||||
p.setHobby(w);
|
||||
this.bot.sendApi(new SendMessage(this.activator.getTelegramId()+"", String.format(Constants.CHANGE_HOBBY_TRIGGERED, p.getFirstName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Constants.CHANGE_HOBBY_CARD;
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package com.alterdekim.javabot.bot.cards;
|
||||
|
||||
import com.alterdekim.javabot.Constants;
|
||||
import com.alterdekim.javabot.bot.Player;
|
||||
import com.alterdekim.javabot.components.BunkerBot;
|
||||
import com.alterdekim.javabot.entities.Hobby;
|
||||
import com.alterdekim.javabot.entities.Luggage;
|
||||
import com.alterdekim.javabot.util.BotUtils;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||
|
||||
public class ChangeLuggageCard extends ActionCard {
|
||||
|
||||
public ChangeLuggageCard(BunkerBot bot, Player activator) {
|
||||
super(bot, activator);
|
||||
}
|
||||
|
||||
public ChangeLuggageCard() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Player p = (Player) BotUtils.getRandomFromList(this.bot.players, this.bot.random);
|
||||
Luggage w = this.activator.getLuggage();
|
||||
this.activator.setLuggage(p.getLuggage());
|
||||
p.setLuggage(w);
|
||||
this.bot.sendApi(new SendMessage(this.activator.getTelegramId()+"", String.format(Constants.CHANGE_LUGGAGE_TRIGGERED, p.getFirstName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Constants.CHANGE_LUGGAGE_CARD;
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package com.alterdekim.javabot.bot.cards;
|
||||
|
||||
import com.alterdekim.javabot.Constants;
|
||||
import com.alterdekim.javabot.bot.Player;
|
||||
import com.alterdekim.javabot.components.BunkerBot;
|
||||
|
||||
public class GodsWillCard extends ActionCard {
|
||||
public GodsWillCard(BunkerBot bot, Player activator) {
|
||||
super(bot, activator);
|
||||
}
|
||||
|
||||
public GodsWillCard() {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
this.bot.liveFormula.add(5.0d / 100.0d);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Constants.GODS_WILL_CARD;
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package com.alterdekim.javabot.bot.cards;
|
||||
|
||||
import com.alterdekim.javabot.Constants;
|
||||
import com.alterdekim.javabot.bot.Player;
|
||||
import com.alterdekim.javabot.components.BunkerBot;
|
||||
import com.alterdekim.javabot.util.BotUtils;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||
|
||||
public class ResurrectionCard extends ActionCard {
|
||||
|
||||
public ResurrectionCard(BunkerBot bot, Player activator) {
|
||||
super(bot, activator);
|
||||
}
|
||||
|
||||
public ResurrectionCard() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Player p = (Player) BotUtils.getRandomFromList(this.bot.dead_players, this.bot.random);
|
||||
p.setIsAnswered(true);
|
||||
this.bot.players.add(p);
|
||||
this.bot.sendApi(new SendMessage(this.activator.getTelegramId()+"", String.format(Constants.RESURRECTION_CARD_TRIGGERED, p.getFirstName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Constants.RESURRECTION_CARD;
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.alterdekim.javabot.bot.cards;
|
||||
|
||||
import com.alterdekim.javabot.Constants;
|
||||
import com.alterdekim.javabot.bot.Player;
|
||||
import com.alterdekim.javabot.components.BunkerBot;
|
||||
import com.alterdekim.javabot.entities.Luggage;
|
||||
import com.alterdekim.javabot.util.BotUtils;
|
||||
import org.telegram.telegrambots.meta.api.methods.send.SendMessage;
|
||||
|
||||
public class StealActionCard extends ActionCard {
|
||||
|
||||
private static final long NOTHING_ID = 7;
|
||||
|
||||
public StealActionCard(BunkerBot bot, Player activator) {
|
||||
super(bot, activator);
|
||||
}
|
||||
|
||||
public StealActionCard() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Player p = (Player) BotUtils.getRandomFromList(this.bot.players, this.bot.random);
|
||||
Luggage l = p.getLuggage();
|
||||
p.setLuggage(this.bot.luggageService.getLuggageById(NOTHING_ID));
|
||||
this.activator.setLuggage(l);
|
||||
this.bot.sendApi(new SendMessage(this.activator.getTelegramId()+"", String.format(Constants.STEAL_LUGGAGE_TRIGGERED, p.getFirstName())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return Constants.STEAL_LUGGAGE_CARD;
|
||||
}
|
||||
}
|
@ -43,11 +43,12 @@ public class BunkerBot extends TelegramLongPollingBot {
|
||||
private double last_p = -1;
|
||||
|
||||
public List<Player> players;
|
||||
public List<Player> dead_players;
|
||||
|
||||
private final BioService bioService;
|
||||
public final HealthService healthService;
|
||||
private final HobbyService hobbyService;
|
||||
private final LuggageService luggageService;
|
||||
public final LuggageService luggageService;
|
||||
private final WorkService workService;
|
||||
public final TextDataValService textDataValService;
|
||||
private final DisasterService disasterService;
|
||||
@ -75,6 +76,7 @@ public class BunkerBot extends TelegramLongPollingBot {
|
||||
RandomComponent randomComponent) {
|
||||
this.telegramConfig = telegramConfig;
|
||||
this.players = new ArrayList<>();
|
||||
this.dead_players = new ArrayList<>();
|
||||
this.gameState = GameState.NONE;
|
||||
this.bioService = bioService;
|
||||
this.healthService = healthService;
|
||||
@ -84,7 +86,16 @@ public class BunkerBot extends TelegramLongPollingBot {
|
||||
this.textDataValService = textDataValService;
|
||||
this.disasterService = disasterService;
|
||||
this.synergyService = synergyService;
|
||||
this.actionCards = new ArrayList<>(List.of(Sabotage.class)); // ScannerCard.class, RandomHIVCard.class, ChangeWorksCard.class,
|
||||
this.actionCards = new ArrayList<>(List.of(
|
||||
ScannerCard.class,
|
||||
RandomHIVCard.class,
|
||||
ChangeWorksCard.class,
|
||||
ChangeHobbyCard.class,
|
||||
ChangeLuggageCard.class,
|
||||
Sabotage.class,
|
||||
GodsWillCard.class,
|
||||
StealActionCard.class,
|
||||
ResurrectionCard.class));
|
||||
this.random = randomComponent;
|
||||
this.dayNightFields = new DayNightFields();
|
||||
this.linkedQueue = new ConcurrentLinkedQueue<>();
|
||||
@ -184,6 +195,7 @@ public class BunkerBot extends TelegramLongPollingBot {
|
||||
return;
|
||||
}
|
||||
Collections.shuffle(players);
|
||||
this.dead_players = new ArrayList<>();
|
||||
this.gameState = GameState.STARTED;
|
||||
this.liveFormula = new LiveFormula();
|
||||
this.liveFormula.setPlayerList(players);
|
||||
@ -470,6 +482,7 @@ public class BunkerBot extends TelegramLongPollingBot {
|
||||
.filter(e -> e.getValue().equals(max))
|
||||
.forEach(i -> {
|
||||
sendApi(new SendMessage(groupId, String.format(Constants.REMOVE_PLAYER, players.get(i.getKey()).getFirstName())));
|
||||
dead_players.add(players.get(i.getKey().intValue()));
|
||||
players.remove(i.getKey().intValue());
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user