Implement Villainous Choice mechanic (#11304)

* [WHO] Implement Great Intelligence's Plan

* [WHO] Implement The Valeyard

* add comment for villainous choice event
This commit is contained in:
Evan Kranzler 2023-10-14 15:27:45 -04:00 committed by GitHub
parent 0f987704bb
commit d705fa0e41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 307 additions and 0 deletions

View file

@ -0,0 +1,40 @@
package mage.choices;
import mage.abilities.Ability;
import mage.game.Game;
import mage.players.Player;
import java.util.Objects;
import java.util.Optional;
/**
* @author TheElk801
*/
public abstract class VillainousChoice {
private final String rule;
private final String message;
protected VillainousChoice(String rule, String message) {
this.rule = rule;
this.message = message;
}
public abstract boolean doChoice(Player player, Game game, Ability source);
public String getRule() {
return rule;
}
public String getMessage(Game game, Ability source) {
if (!message.contains("{controller}")) {
return message;
}
String controllerName = Optional
.ofNullable(game.getPlayer(source.getControllerId()))
.filter(Objects::nonNull)
.map(Player::getName)
.orElse("Opponent");
return message.replace("{controller}", controllerName);
}
}