Skip to content

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
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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 Jun 17, 2025
82f6025
gets etb working properly
oscscull Jun 18, 2025
c69cb9c
mostly working, needs text and mana costs to be perfected
oscscull Jun 19, 2025
1a29e7e
adds mana values
oscscull Jun 19, 2025
d634c3c
adds rules text hiding
oscscull Jun 19, 2025
b3e4fab
working except on rules text
oscscull Jun 22, 2025
d27f3bb
adds more needed stuff
oscscull Jun 25, 2025
0309c12
finish main room features
oscscull Jun 26, 2025
63f5e29
clean up, revert accidental formatting
oscscull Jun 26, 2025
6a9ff16
renames
oscscull Jul 3, 2025
f0ec5cc
Add first test, add matching code for rooms to test code
oscscull Jul 6, 2025
6240446
expand testing, fix issues
oscscull Jul 9, 2025
8c0eb8d
unneeded import
oscscull Jul 9, 2025
cc87208
fix name predicate edge case
oscscull Jul 10, 2025
159825a
add unlock test
oscscull Jul 10, 2025
4db99d5
simplify
oscscull Jul 10, 2025
08f8452
revert this. I don't know that the logic here was wrong - i need to c…
oscscull Jul 10, 2025
fc130c9
add flicker tests
oscscull Jul 10, 2025
947b55a
checkpoint up to failing test (copy not working)
oscscull Jul 19, 2025
57f304f
Get copy on stack working
oscscull Jul 20, 2025
524ec0f
Add clone test
oscscull Jul 20, 2025
f6943ca
Test name match (stack)
oscscull Jul 21, 2025
3b32f07
reanimate after counter
oscscull Jul 21, 2025
53463bd
on battlefield tests
oscscull Jul 21, 2025
49dbf27
add the pithing needle example
oscscull Jul 21, 2025
7f49d1a
Add test of changing one permanent into two rooms
oscscull Jul 21, 2025
13c6f3b
Don't think this is correct behaviour pinned in test. (Maybe I'm miss…
oscscull Jul 21, 2025
8a239cb
revert this (formatted accidentally)
oscscull Jul 21, 2025
c1db8f1
fix
oscscull Jul 21, 2025
52b846f
Merge remote-tracking branch 'upstream/master' into implement-rooms
oscscull Jul 21, 2025
2aa0784
add subtype to halves
oscscull Jul 22, 2025
75a347f
Merge remote-tracking branch 'upstream/master' into implement-rooms
oscscull Jul 22, 2025
3d054f6
fix subtype
oscscull Jul 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions Mage.Sets/src/mage/cards/b/BottomlessPoolLockerRoom.java
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);
}
}
1 change: 1 addition & 0 deletions Mage.Sets/src/mage/sets/DuskmournHouseOfHorror.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ private DuskmournHouseOfHorror() {
cards.add(new SetCardInfo("Blazemire Verge", 329, Rarity.RARE, mage.cards.b.BlazemireVerge.class, NON_FULL_USE_VARIOUS));
cards.add(new SetCardInfo("Bleeding Woods", 257, Rarity.COMMON, mage.cards.b.BleedingWoods.class));
cards.add(new SetCardInfo("Boilerbilges Ripper", 127, Rarity.COMMON, mage.cards.b.BoilerbilgesRipper.class));
cards.add(new SetCardInfo("Bottomless Pool // Locker Room", 43, Rarity.UNCOMMON, mage.cards.b.BottomlessPoolLockerRoom.class));
cards.add(new SetCardInfo("Break Down the Door", 170, Rarity.UNCOMMON, mage.cards.b.BreakDownTheDoor.class));
cards.add(new SetCardInfo("Broodspinner", 211, Rarity.UNCOMMON, mage.cards.b.Broodspinner.class));
cards.add(new SetCardInfo("Cackling Slasher", 85, Rarity.COMMON, mage.cards.c.CacklingSlasher.class));
Expand Down
113 changes: 113 additions & 0 deletions Mage/src/main/java/mage/abilities/common/RoomUnlockAbility.java
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);
}
}
}
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);
}
}
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 {
Copy link
Member

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

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();
}
}
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 "";
}
}
Loading