From 1123e18ca46a98a76cbf23ea2243c819a368ea64 Mon Sep 17 00:00:00 2001 From: Sloth Date: Mon, 6 May 2013 20:41:04 +0000 Subject: [PATCH] - Added the static ability MayLookAt. - Enabled card detail panel when choosing a face down card that you may look at. - Added Bane Alley Broker. --- .gitattributes | 2 + res/cardsfolder/b/bane_alley_broker.txt | 16 +++++ src/main/java/forge/Card.java | 18 +++++ .../card/staticability/StaticAbility.java | 12 ++-- .../staticability/StaticAbilityMayLookAt.java | 66 +++++++++++++++++++ src/main/java/forge/game/ai/AiController.java | 2 + src/main/java/forge/gui/GuiChoose.java | 12 +++- .../gui/match/nonsingleton/ZoneAction.java | 4 +- 8 files changed, 124 insertions(+), 8 deletions(-) create mode 100644 res/cardsfolder/b/bane_alley_broker.txt create mode 100644 src/main/java/forge/card/staticability/StaticAbilityMayLookAt.java diff --git a/.gitattributes b/.gitattributes index 110ee89d750..5f25f929391 100644 --- a/.gitattributes +++ b/.gitattributes @@ -749,6 +749,7 @@ res/cardsfolder/b/balustrade_spy.txt -text res/cardsfolder/b/bamboozle.txt -text res/cardsfolder/b/bandage.txt svneol=native#text/plain res/cardsfolder/b/bane_alley_blackguard.txt -text +res/cardsfolder/b/bane_alley_broker.txt -text res/cardsfolder/b/bane_of_the_living.txt svneol=native#text/plain res/cardsfolder/b/banefire.txt -text res/cardsfolder/b/baneful_omen.txt -text @@ -14031,6 +14032,7 @@ src/main/java/forge/card/staticability/StaticAbilityCantTarget.java -text src/main/java/forge/card/staticability/StaticAbilityContinuous.java svneol=native#text/plain src/main/java/forge/card/staticability/StaticAbilityCostChange.java -text src/main/java/forge/card/staticability/StaticAbilityETBTapped.java -text +src/main/java/forge/card/staticability/StaticAbilityMayLookAt.java -text src/main/java/forge/card/staticability/StaticAbilityPreventDamage.java svneol=native#text/plain src/main/java/forge/card/staticability/package-info.java svneol=native#text/plain src/main/java/forge/card/trigger/Trigger.java svneol=native#text/plain diff --git a/res/cardsfolder/b/bane_alley_broker.txt b/res/cardsfolder/b/bane_alley_broker.txt new file mode 100644 index 00000000000..e92e1e11fe1 --- /dev/null +++ b/res/cardsfolder/b/bane_alley_broker.txt @@ -0,0 +1,16 @@ +Name:Bane Alley Broker +ManaCost:1 U B +Types:Creature Human Rogue +Text:no text +PT:0/3 +A:AB$ Draw | Cost$ T | NumCards$ 1 | SubAbility$ DBExile | SpellDescription$ Draw a card, then exile a card from your hand face down. +SVar:DBExile:DB$ ChangeZone | Origin$ Hand | Destination$ Exile | ChangeType$ Card | ChangeNum$ 1 | ExileFaceDown$ True | Mandatory$ True | RememberChanged$ True +S:Mode$ MayLookAt | Affected$ Card.IsRemembered | Player$ You | AffectedZone$ Exile | Description$ You may look at cards exiled with CARDNAME. +A:AB$ ChooseCard | Cost$ U B T | Defined$ You | Amount$ 1 | Mandatory$ True | AILogic$ AtLeast1 | ChoiceTitle$ Choose a card to put into your hand | Choices$ Card.IsRemembered | ChoiceZone$ Exile | SubAbility$ MoveChosen | SpellDescription$ Return a card exiled with CARDNAME to its owner's hand. +SVar:MoveChosen:DB$ ChangeZone | Origin$ Exile | Destination$ Hand | Defined$ ChosenCard +T:Mode$ ChangesZone | Origin$ Exile | Destination$ Any | Static$ True | ValidCard$ Card.IsRemembered | Execute$ DBForget +SVar:DBForget:DB$ Pump | ForgetObjects$ TriggeredCard +T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Any | Static$ True | ValidCard$ Card.Self | Execute$ DBCleanup +SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True +Oracle:{T}: Draw a card, then exile a card from your hand face down.\nYou may look at cards exiled with Bane Alley Broker.\n{U}{B}, {T}: Return a card exiled with Bane Alley Broker to its owner's hand. +SetInfo:GTC Uncommon \ No newline at end of file diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index 2018a77cea1..487a83a3c9e 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -8298,6 +8298,24 @@ public class Card extends GameEntity implements Comparable { return true; } + public boolean canBeSeenBy(final Player p) { + final GameState game = this.getGame(); + if (getController().equals(p) && hasKeyword("You may look at this card.")) { + return true; + } + if (getController().isOpponentOf(p) && hasKeyword("Your opponent may look at this card.")) { + return true; + } + for (Card host : game.getCardsIn(ZoneType.Battlefield)) { + final ArrayList staticAbilities = host.getStaticAbilities(); + for (final StaticAbility stAb : staticAbilities) { + if (stAb.applyAbility("MayLookAt", this, p)) { + return true; + } + } + } + return false; + } CardRules cardRules; public CardRules getRules() { diff --git a/src/main/java/forge/card/staticability/StaticAbility.java b/src/main/java/forge/card/staticability/StaticAbility.java index dac6307b005..a2c0edbf0b0 100644 --- a/src/main/java/forge/card/staticability/StaticAbility.java +++ b/src/main/java/forge/card/staticability/StaticAbility.java @@ -287,11 +287,11 @@ public class StaticAbility { * the mode * @param card * the card - * @param activator + * @param player * the activator * @return true, if successful */ - public final boolean applyAbility(final String mode, final Card card, final Player activator) { + public final boolean applyAbility(final String mode, final Card card, final Player player) { // don't apply the ability if it hasn't got the right mode if (!this.params.get("Mode").equals(mode)) { @@ -303,11 +303,15 @@ public class StaticAbility { } if (mode.equals("CantBeCast")) { - return StaticAbilityCantBeCast.applyCantBeCastAbility(this, card, activator); + return StaticAbilityCantBeCast.applyCantBeCastAbility(this, card, player); } if (mode.equals("CantPlayLand")) { - return StaticAbilityCantBeCast.applyCantPlayLandAbility(this, card, activator); + return StaticAbilityCantBeCast.applyCantPlayLandAbility(this, card, player); + } + + if (mode.equals("MayLookAt")) { + return StaticAbilityMayLookAt.applyMayLookAtAbility(this, card, player); } return false; diff --git a/src/main/java/forge/card/staticability/StaticAbilityMayLookAt.java b/src/main/java/forge/card/staticability/StaticAbilityMayLookAt.java new file mode 100644 index 00000000000..3bf40743499 --- /dev/null +++ b/src/main/java/forge/card/staticability/StaticAbilityMayLookAt.java @@ -0,0 +1,66 @@ +/* + * Forge: Play Magic: the Gathering. + * Copyright (C) 2011 Forge Team + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package forge.card.staticability; + +import java.util.HashMap; + +import forge.Card; +import forge.game.GameState; +import forge.game.player.Player; +import forge.game.zone.ZoneType; + +/** + * The Class StaticAbility_CantBeCast. + */ +public class StaticAbilityMayLookAt { + + /** + * TODO Write javadoc for this method. + * + * @param stAb + * a StaticAbility + * @param card + * the card + * @param activator + * the player + * @return true, if successful + */ + public static boolean applyMayLookAtAbility(final StaticAbility stAb, final Card card, final Player player) { + final HashMap params = stAb.getMapParams(); + final Card hostCard = stAb.getHostCard(); + + if (params.containsKey("Affected") + && !card.isValid(params.get("Affected").split(","), hostCard.getController(), hostCard)) { + return false; + } + + if (params.containsKey("Player") && player != null + && !player.isValid(params.get("Player"), hostCard.getController(), hostCard)) { + return false; + } + + if (params.containsKey("AffectedZone")) { + ZoneType zone = card.getGame().getZoneOf(card).getZoneType(); + if (!ZoneType.listValueOf(params.get("AffectedZone")).contains(zone)) { + return false; + } + } + + return true; + } +} diff --git a/src/main/java/forge/game/ai/AiController.java b/src/main/java/forge/game/ai/AiController.java index 96de04459f9..74489d2f4ab 100644 --- a/src/main/java/forge/game/ai/AiController.java +++ b/src/main/java/forge/game/ai/AiController.java @@ -666,6 +666,8 @@ public class AiController { options = CardLists.getValidCards(options, "Permanent.YouCtrl,Permanent.tapped", host.getController(), host); } choice = ComputerUtilCard.getBestAI(options); + } else { + choice = ComputerUtilCard.getBestAI(options); } return choice; diff --git a/src/main/java/forge/gui/GuiChoose.java b/src/main/java/forge/gui/GuiChoose.java index 3f80320685a..88e0dc6fae1 100644 --- a/src/main/java/forge/gui/GuiChoose.java +++ b/src/main/java/forge/gui/GuiChoose.java @@ -18,7 +18,10 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import forge.Card; +import forge.CardCharacteristicName; import forge.FThreads; +import forge.Singletons; +import forge.card.cardfactory.CardFactory; import forge.gui.match.CMatchUI; import forge.item.InventoryItem; @@ -118,7 +121,14 @@ public class GuiChoose { @Override public void valueChanged(final ListSelectionEvent ev) { if (list.getSelectedValue() instanceof Card) { - CMatchUI.SINGLETON_INSTANCE.setCard((Card) list.getSelectedValue()); + Card card = (Card) list.getSelectedValue(); + if (card.isFaceDown()) { + if (card.canBeSeenBy(Singletons.getControl().getLobby().getGuiPlayer().getPlayer(card.getGame()))) { + card = CardFactory.copyCard(card); + card.setState(CardCharacteristicName.Original); + } + } + CMatchUI.SINGLETON_INSTANCE.setCard(card); GuiUtils.clearPanelSelections(); GuiUtils.setPanelSelection((Card) list.getSelectedValue()); diff --git a/src/main/java/forge/gui/match/nonsingleton/ZoneAction.java b/src/main/java/forge/gui/match/nonsingleton/ZoneAction.java index 04f0b669869..d2c3986c625 100644 --- a/src/main/java/forge/gui/match/nonsingleton/ZoneAction.java +++ b/src/main/java/forge/gui/match/nonsingleton/ZoneAction.java @@ -54,9 +54,7 @@ class ZoneAction extends ForgeAction { for (Card crd : choices) { Card toAdd = crd; if (crd.isFaceDown()) { - boolean ctrldByUiPlayer = crd.getController().getLobbyPlayer() == Singletons.getControl().getLobby().getGuiPlayer(); - boolean canSee = ctrldByUiPlayer && crd.hasKeyword("You may look at this card.") || crd.hasKeyword("Your opponent may look at this card."); - if (canSee) { + if (crd.canBeSeenBy(Singletons.getControl().getLobby().getGuiPlayer().getPlayer(crd.getGame()))) { toAdd = CardFactory.copyCard(crd); toAdd.setState(CardCharacteristicName.Original); } else {