forked from External/mage
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:
parent
0f987704bb
commit
d705fa0e41
6 changed files with 307 additions and 0 deletions
40
Mage/src/main/java/mage/choices/VillainousChoice.java
Normal file
40
Mage/src/main/java/mage/choices/VillainousChoice.java
Normal 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);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue