-
Notifications
You must be signed in to change notification settings - Fork 824
Implement rooms (Bottomless Pool // Locker Room) #13786
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
oscscull
wants to merge
33
commits into
magefree:master
Choose a base branch
from
oscscull:implement-rooms
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 9 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
b1c96aa
get rooms entering the battlefield
oscscull 82f6025
gets etb working properly
oscscull c69cb9c
mostly working, needs text and mana costs to be perfected
oscscull 1a29e7e
adds mana values
oscscull d634c3c
adds rules text hiding
oscscull b3e4fab
working except on rules text
oscscull d27f3bb
adds more needed stuff
oscscull 0309c12
finish main room features
oscscull 63f5e29
clean up, revert accidental formatting
oscscull 6a9ff16
renames
oscscull f0ec5cc
Add first test, add matching code for rooms to test code
oscscull 6240446
expand testing, fix issues
oscscull 8c0eb8d
unneeded import
oscscull cc87208
fix name predicate edge case
oscscull 159825a
add unlock test
oscscull 4db99d5
simplify
oscscull 08f8452
revert this. I don't know that the logic here was wrong - i need to c…
oscscull fc130c9
add flicker tests
oscscull 947b55a
checkpoint up to failing test (copy not working)
oscscull 57f304f
Get copy on stack working
oscscull 524ec0f
Add clone test
oscscull f6943ca
Test name match (stack)
oscscull 3b32f07
reanimate after counter
oscscull 53463bd
on battlefield tests
oscscull 49dbf27
add the pithing needle example
oscscull 7f49d1a
Add test of changing one permanent into two rooms
oscscull 13c6f3b
Don't think this is correct behaviour pinned in test. (Maybe I'm miss…
oscscull 8a239cb
revert this (formatted accidentally)
oscscull c1db8f1
fix
oscscull 52b846f
Merge remote-tracking branch 'upstream/master' into implement-rooms
oscscull 2aa0784
add subtype to halves
oscscull 75a347f
Merge remote-tracking branch 'upstream/master' into implement-rooms
oscscull 3d054f6
fix subtype
oscscull File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package mage.cards.b; | ||
|
||
import java.util.UUID; | ||
|
||
import mage.abilities.common.DealsDamageToAPlayerAllTriggeredAbility; | ||
import mage.abilities.common.UnlockThisDoorTriggeredAbility; | ||
import mage.abilities.effects.common.DrawCardSourceControllerEffect; | ||
import mage.abilities.effects.common.ReturnToHandTargetEffect; | ||
import mage.cards.CardSetInfo; | ||
import mage.cards.RoomCard; | ||
import mage.constants.CardType; | ||
import mage.constants.SetTargetPointer; | ||
import mage.constants.SpellAbilityType; | ||
import mage.constants.SubType; | ||
import mage.constants.TargetController; | ||
import mage.filter.StaticFilters; | ||
import mage.target.common.TargetCreaturePermanent; | ||
|
||
/** | ||
* @author oscscull | ||
*/ | ||
public final class BottomlessPoolLockerRoom extends RoomCard { | ||
|
||
public BottomlessPoolLockerRoom(UUID ownerId, CardSetInfo setInfo) { | ||
super(ownerId, setInfo, | ||
new CardType[] { CardType.ENCHANTMENT }, | ||
"{U}", "{4}{U}", SpellAbilityType.SPLIT); | ||
this.subtype.add(SubType.ROOM); | ||
|
||
// Left half ability - "When you unlock this door" trigger (delayed triggered | ||
// ability) | ||
UnlockThisDoorTriggeredAbility left = new UnlockThisDoorTriggeredAbility( | ||
new ReturnToHandTargetEffect(), false, true); | ||
left.addTarget(new TargetCreaturePermanent(0, 1)); | ||
|
||
// Right half ability - "Whenever creatures you control deal combat damage" | ||
DealsDamageToAPlayerAllTriggeredAbility right = new DealsDamageToAPlayerAllTriggeredAbility( | ||
new DrawCardSourceControllerEffect(1), | ||
StaticFilters.FILTER_CONTROLLED_A_CREATURE, | ||
false, SetTargetPointer.PLAYER, true, true, TargetController.OPPONENT); | ||
|
||
this.AddRoomAbilities(left, right); | ||
} | ||
|
||
private BottomlessPoolLockerRoom(final BottomlessPoolLockerRoom card) { | ||
super(card); | ||
} | ||
|
||
@Override | ||
public BottomlessPoolLockerRoom copy() { | ||
return new BottomlessPoolLockerRoom(this); | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
113 changes: 113 additions & 0 deletions
113
Mage/src/main/java/mage/abilities/common/RoomUnlockAbility.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
package mage.abilities.common; | ||
|
||
import mage.abilities.Ability; | ||
import mage.abilities.SpecialAction; | ||
import mage.abilities.condition.common.RoomLeftHalfLockedCondition; | ||
import mage.abilities.condition.common.RoomRightHalfLockedCondition; | ||
import mage.abilities.costs.mana.ManaCosts; | ||
import mage.abilities.effects.OneShotEffect; | ||
import mage.constants.Outcome; | ||
import mage.constants.TimingRule; | ||
import mage.constants.Zone; | ||
import mage.game.Game; | ||
import mage.game.permanent.Permanent; | ||
|
||
|
||
/** | ||
* @author oscscull | ||
* Special action for Room cards to unlock a locked half by paying its mana | ||
* cost. | ||
* This ability is only present if the corresponding half is currently locked. | ||
*/ | ||
public class RoomUnlockAbility extends SpecialAction { | ||
|
||
private final boolean isLeftHalf; | ||
|
||
public RoomUnlockAbility(ManaCosts costs, boolean isLeftHalf) { | ||
super(Zone.BATTLEFIELD, null); | ||
this.addCost(costs); | ||
|
||
this.isLeftHalf = isLeftHalf; | ||
this.timing = TimingRule.SORCERY; | ||
|
||
// only works if the relevant half is *locked* | ||
if (isLeftHalf) { | ||
this.setCondition(RoomLeftHalfLockedCondition.instance); | ||
} else { | ||
this.setCondition(RoomRightHalfLockedCondition.instance); | ||
} | ||
|
||
// Adds the effect to pay + unlock the half | ||
this.addEffect(new RoomUnlockHalfEffect(isLeftHalf)); | ||
} | ||
|
||
protected RoomUnlockAbility(final RoomUnlockAbility ability) { | ||
super(ability); | ||
this.isLeftHalf = ability.isLeftHalf; | ||
} | ||
|
||
@Override | ||
public RoomUnlockAbility copy() { | ||
return new RoomUnlockAbility(this); | ||
} | ||
|
||
@Override | ||
public String getRule() { | ||
StringBuilder sb = new StringBuilder(); | ||
sb.append(getManaCostsToPay().getText()).append(": "); | ||
sb.append("Unlock the "); | ||
sb.append(isLeftHalf ? "left" : "right").append(" half."); | ||
sb.append(" <i>(Activate only as a sorcery, and only if the "); | ||
sb.append(isLeftHalf ? "left" : "right").append(" half is locked.)</i>"); | ||
return sb.toString(); | ||
} | ||
} | ||
|
||
/** | ||
* Allows you to pay to unlock the door | ||
*/ | ||
class RoomUnlockHalfEffect extends OneShotEffect { | ||
|
||
private final boolean isLeftHalf; | ||
|
||
public RoomUnlockHalfEffect(boolean isLeftHalf) { | ||
super(Outcome.Neutral); | ||
this.isLeftHalf = isLeftHalf; | ||
staticText = "unlock the " + (isLeftHalf ? "left" : "right") + " half"; | ||
} | ||
|
||
private RoomUnlockHalfEffect(final RoomUnlockHalfEffect effect) { | ||
super(effect); | ||
this.isLeftHalf = effect.isLeftHalf; | ||
} | ||
|
||
@Override | ||
public RoomUnlockHalfEffect copy() { | ||
return new RoomUnlockHalfEffect(this); | ||
} | ||
|
||
@Override | ||
public boolean apply(Game game, Ability source) { | ||
Permanent permanent = source.getSourcePermanentIfItStillExists(game); | ||
if (permanent == null) { | ||
permanent = game.getPermanent(source.getSourceId()); | ||
} | ||
|
||
if (permanent == null) { | ||
return false; | ||
} | ||
|
||
if (isLeftHalf && permanent.isLeftHalfUnlocked()) { | ||
return false; | ||
} | ||
if (!isLeftHalf && permanent.isRightHalfUnlocked()) { | ||
return false; | ||
} | ||
|
||
if (isLeftHalf) { | ||
return permanent.unlockLeftHalf(game, source); | ||
} else { | ||
return permanent.unlockRightHalf(game, source); | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
Mage/src/main/java/mage/abilities/common/UnlockThisDoorTriggeredAbility.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package mage.abilities.common; | ||
|
||
import mage.abilities.TriggeredAbilityImpl; | ||
import mage.abilities.effects.Effect; | ||
import mage.constants.Zone; | ||
import mage.game.Game; | ||
import mage.game.events.GameEvent; | ||
|
||
/** | ||
* Delayed triggered ability for "when you unlock this door" effects | ||
* | ||
* @author oscscull | ||
*/ | ||
public class UnlockThisDoorTriggeredAbility extends TriggeredAbilityImpl { | ||
|
||
private final boolean isLeftHalf; | ||
|
||
public UnlockThisDoorTriggeredAbility(Effect effect, boolean optional, boolean isLeftHalf) { | ||
super(Zone.BATTLEFIELD, effect, isLeftHalf); | ||
this.isLeftHalf = isLeftHalf; | ||
this.setTriggerPhrase("When you unlock this door, "); | ||
} | ||
|
||
private UnlockThisDoorTriggeredAbility(final UnlockThisDoorTriggeredAbility ability) { | ||
super(ability); | ||
this.isLeftHalf = ability.isLeftHalf; | ||
} | ||
|
||
@Override | ||
public boolean checkEventType(GameEvent event, Game game) { | ||
return isLeftHalf ? event.getType() == GameEvent.EventType.UNLOCK_LEFT_DOOR | ||
: event.getType() == GameEvent.EventType.UNLOCK_RIGHT_DOOR; | ||
} | ||
|
||
@Override | ||
public boolean checkTrigger(GameEvent event, Game game) { | ||
return event.getTargetId().equals(getSourceId()); | ||
} | ||
|
||
@Override | ||
public UnlockThisDoorTriggeredAbility copy() { | ||
return new UnlockThisDoorTriggeredAbility(this); | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
Mage/src/main/java/mage/abilities/condition/common/RoomLeftHalfLockedCondition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package mage.abilities.condition.common; | ||
|
||
import mage.abilities.Ability; | ||
import mage.abilities.condition.Condition; | ||
import mage.game.Game; | ||
import mage.game.permanent.Permanent; | ||
|
||
/** | ||
* @author oscscull | ||
* Checks if a Permanent's left half is LOCKED (i.e., NOT unlocked). | ||
*/ | ||
public enum RoomLeftHalfLockedCondition implements Condition { | ||
instance; | ||
|
||
@Override | ||
public boolean apply(Game game, Ability source) { | ||
Permanent permanent = source.getSourcePermanentIfItStillExists(game); | ||
if (permanent == null) { | ||
permanent = game.getPermanent(source.getSourceId()); | ||
} | ||
|
||
// Return true if the permanent exists and its left half is NOT unlocked | ||
return permanent != null && !permanent.isLeftHalfUnlocked(); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
Mage/src/main/java/mage/abilities/condition/common/RoomRightHalfLockedCondition.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package mage.abilities.condition.common; | ||
|
||
import mage.abilities.Ability; | ||
import mage.abilities.condition.Condition; | ||
import mage.game.Game; | ||
import mage.game.permanent.Permanent; | ||
|
||
/** | ||
* @author oscscull | ||
* Checks if a Permanent's right half is LOCKED (i.e., NOT unlocked). | ||
*/ | ||
public enum RoomRightHalfLockedCondition implements Condition { | ||
instance; | ||
|
||
@Override | ||
public boolean apply(Game game, Ability source) { | ||
Permanent permanent = source.getSourcePermanentIfItStillExists(game); | ||
if (permanent == null) { | ||
permanent = game.getPermanent(source.getSourceId()); | ||
} | ||
|
||
// Return true if the permanent exists and its right half is NOT unlocked | ||
return permanent != null && !permanent.isRightHalfUnlocked(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
// Return an empty string so that the "if (!conditionText.isEmpty())" | ||
// check in TriggeredAbilityImpl.getRule() evaluates to false. | ||
return ""; | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's good to use card hint to show rooms status in popup hints, e.g. "green icon left door unlocked", "red icon right door locked", etc