mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 13:02:06 -08:00
[C21] Implemented Guardian Archon
This commit is contained in:
parent
ad5d1e498f
commit
42132bb852
6 changed files with 261 additions and 109 deletions
|
|
@ -12,57 +12,51 @@ import mage.players.Player;
|
|||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
* @author credman0
|
||||
*/
|
||||
public class RevealSecretOpponentCost extends CostImpl {
|
||||
|
||||
public RevealSecretOpponentCost() {
|
||||
this.text = "Reveal the player you chose";
|
||||
}
|
||||
public RevealSecretOpponentCost() {
|
||||
this.text = "Reveal the player you chose";
|
||||
}
|
||||
|
||||
public RevealSecretOpponentCost(final RevealSecretOpponentCost cost) {
|
||||
super(cost);
|
||||
}
|
||||
public RevealSecretOpponentCost(final RevealSecretOpponentCost cost) {
|
||||
super(cost);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
UUID playerThatChoseId = (UUID) game.getState().getValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OWNER);
|
||||
if (playerThatChoseId == null || !playerThatChoseId.equals(controllerId)) {
|
||||
return false;
|
||||
}
|
||||
UUID opponentId = (UUID) game.getState().getValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OPPONENT);
|
||||
return opponentId != null;
|
||||
}
|
||||
@Override
|
||||
public boolean canPay(Ability ability, Ability source, UUID controllerId, Game game) {
|
||||
return controllerId != null
|
||||
&& controllerId.equals(ChooseSecretOpponentEffect.getSecretOwner(source, game))
|
||||
&& ChooseSecretOpponentEffect.getChosenPlayer(source, game) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
UUID playerThatChoseId = (UUID) game.getState().getValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OWNER);
|
||||
if (playerThatChoseId == null || !playerThatChoseId.equals(controllerId)) {
|
||||
return false;
|
||||
}
|
||||
UUID opponentId = (UUID) game.getState().getValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OPPONENT);
|
||||
if (opponentId != null) {
|
||||
game.getState().setValue(source.getSourceId() + ChooseSecretOpponentEffect.SECRET_OWNER, null); // because only once, the vale is set to null
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && opponent != null && sourceObject != null) {
|
||||
if (sourceObject instanceof Permanent) {
|
||||
((Permanent) sourceObject).addInfo(ChooseSecretOpponentEffect.SECRET_OPPONENT, null, game);
|
||||
}
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " reveals the secretly chosen opponent " + opponent.getLogName());
|
||||
}
|
||||
paid = true;
|
||||
}
|
||||
@Override
|
||||
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
|
||||
if (controllerId == null || !controllerId.equals(ChooseSecretOpponentEffect.getSecretOwner(source, game))) {
|
||||
return false;
|
||||
}
|
||||
UUID opponentId = ChooseSecretOpponentEffect.getChosenPlayer(source, game);
|
||||
if (opponentId == null) {
|
||||
return paid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RevealSecretOpponentCost copy() {
|
||||
return new RevealSecretOpponentCost(this);
|
||||
ChooseSecretOpponentEffect.setSecretOwner(null, source, game); // because only once, the value is set to null
|
||||
Player controller = game.getPlayer(controllerId);
|
||||
Player opponent = game.getPlayer(opponentId);
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && opponent != null && sourceObject != null) {
|
||||
if (sourceObject instanceof Permanent) {
|
||||
((Permanent) sourceObject).addInfo(ChooseSecretOpponentEffect.SECRET_OPPONENT, null, game);
|
||||
}
|
||||
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " reveals the secretly chosen opponent " + opponent.getLogName());
|
||||
}
|
||||
paid = true;
|
||||
return paid;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public RevealSecretOpponentCost copy() {
|
||||
return new RevealSecretOpponentCost(this);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,16 +4,19 @@ import mage.MageObject;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetOpponent;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
* @author credman0
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class ChooseSecretOpponentEffect extends OneShotEffect {
|
||||
|
||||
|
|
@ -36,33 +39,53 @@ public class ChooseSecretOpponentEffect extends OneShotEffect {
|
|||
if (mageObject == null) {
|
||||
mageObject = game.getObject(source.getSourceId());
|
||||
}
|
||||
if (controller != null && mageObject != null) {
|
||||
TargetOpponent targetOpponent = new TargetOpponent(true);
|
||||
targetOpponent.setTargetName("opponent (secretly)");
|
||||
while (!controller.choose(outcome, targetOpponent, source.getSourceId(), game)) {
|
||||
if (!controller.canRespond()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (targetOpponent.getTargets().isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has secretly chosen an opponent.");
|
||||
}
|
||||
game.getState().setValue(mageObject.getId() + SECRET_OPPONENT, targetOpponent.getTargets().get(0));
|
||||
game.getState().setValue(mageObject.getId() + SECRET_OWNER, controller.getId());
|
||||
if (mageObject instanceof Permanent) {
|
||||
((Permanent) mageObject).addInfo(SECRET_OPPONENT,
|
||||
CardUtil.addToolTipMarkTags(controller.getLogName() + " has secretly chosen an opponent."), game);
|
||||
}
|
||||
if (controller == null || mageObject == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetOpponent targetOpponent = new TargetOpponent(true);
|
||||
targetOpponent.setTargetName("opponent (secretly)");
|
||||
controller.choose(outcome, targetOpponent, source.getSourceId(), game);
|
||||
if (targetOpponent.getFirstTarget() == null) {
|
||||
return false;
|
||||
}
|
||||
game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has secretly chosen an opponent.");
|
||||
setChosenPlayer(targetOpponent.getFirstTarget(), source, game);
|
||||
setSecretOwner(controller.getId(), source, game);
|
||||
if (!(mageObject instanceof Permanent)) {
|
||||
return true;
|
||||
}
|
||||
((Permanent) mageObject).addInfo(
|
||||
SECRET_OPPONENT, CardUtil.addToolTipMarkTags(
|
||||
controller.getLogName() + " has secretly chosen an opponent."
|
||||
), game);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void setChosenPlayer(UUID value, Ability source, Game game) {
|
||||
game.getState().setValue(getthing(source, game) + ChooseSecretOpponentEffect.SECRET_OPPONENT, value);
|
||||
}
|
||||
|
||||
public static UUID getChosenPlayer(Ability source, Game game) {
|
||||
return (UUID) game.getState().getValue(getthing(source, game) + ChooseSecretOpponentEffect.SECRET_OPPONENT);
|
||||
}
|
||||
|
||||
public static void setSecretOwner(UUID value, Ability source, Game game) {
|
||||
game.getState().setValue(getthing(source, game) + ChooseSecretOpponentEffect.SECRET_OWNER, value);
|
||||
}
|
||||
|
||||
public static UUID getSecretOwner(Ability source, Game game) {
|
||||
return (UUID) game.getState().getValue(getthing(source, game) + ChooseSecretOpponentEffect.SECRET_OWNER);
|
||||
}
|
||||
|
||||
private static String getthing(Ability source, Game game) {
|
||||
if (game.getState().getZone(source.getSourceId()) == Zone.BATTLEFIELD) {
|
||||
return "" + source.getSourceId() + '_' + source.getSourceObjectZoneChangeCounter();
|
||||
}
|
||||
return "" + source.getSourceId() + '_' + (source.getSourceObjectZoneChangeCounter() + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChooseSecretOpponentEffect copy() {
|
||||
return new ChooseSecretOpponentEffect(this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue