-
Notifications
You must be signed in to change notification settings - Fork 581
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Room: First Spell ---- Co-authored-by: tool4ever <[email protected]> Co-authored-by: tool4EvEr <[email protected]> Co-authored-by: TRT <> Co-authored-by: Anthony Calosa <[email protected]>
- Loading branch information
1 parent
88006eb
commit 80b30d9
Showing
30 changed files
with
527 additions
and
34 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
106 changes: 106 additions & 0 deletions
106
forge-game/src/main/java/forge/game/ability/effects/UnlockDoorEffect.java
This file contains 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,106 @@ | ||
package forge.game.ability.effects; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.google.common.collect.Maps; | ||
|
||
import forge.card.CardStateName; | ||
import forge.game.Game; | ||
import forge.game.ability.SpellAbilityEffect; | ||
import forge.game.card.Card; | ||
import forge.game.card.CardCollection; | ||
import forge.game.card.CardLists; | ||
import forge.game.card.CardState; | ||
import forge.game.player.Player; | ||
import forge.game.spellability.SpellAbility; | ||
import forge.game.zone.ZoneType; | ||
import forge.util.Localizer; | ||
|
||
public class UnlockDoorEffect extends SpellAbilityEffect { | ||
|
||
@Override | ||
public void resolve(SpellAbility sa) { | ||
final Card source = sa.getHostCard(); | ||
final Game game = source.getGame(); | ||
final Player activator = sa.getActivatingPlayer(); | ||
|
||
CardCollection list; | ||
|
||
if (sa.hasParam("Choices")) { | ||
Player chooser = activator; | ||
String title = sa.hasParam("ChoiceTitle") ? sa.getParam("ChoiceTitle") : Localizer.getInstance().getMessage("lblChoose") + " "; | ||
|
||
CardCollection choices = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), sa.getParam("Choices"), activator, source, sa); | ||
|
||
Card c = chooser.getController().chooseSingleEntityForEffect(choices, sa, title, Maps.newHashMap()); | ||
if (c == null) { | ||
return; | ||
} | ||
list = new CardCollection(c); | ||
} else { | ||
list = getTargetCards(sa); | ||
} | ||
|
||
for (Card c : list) { | ||
Map<String, Object> params = Maps.newHashMap(); | ||
params.put("Object", c); | ||
switch (sa.getParamOrDefault("Mode", "ThisDoor")) { | ||
case "ThisDoor": | ||
c.unlockRoom(activator, sa.getCardStateName()); | ||
break; | ||
case "Unlock": | ||
List<CardState> states = c.getLockedRooms().stream().map(stateName -> c.getState(stateName)).collect(Collectors.toList()); | ||
|
||
// need to choose Room Name | ||
CardState chosen = activator.getController().chooseSingleCardState(sa, states, "Choose Room to unlock", params); | ||
if (chosen == null) { | ||
continue; | ||
} | ||
c.unlockRoom(activator, chosen.getStateName()); | ||
break; | ||
case "LockOrUnlock": | ||
switch (c.getLockedRooms().size()) { | ||
case 0: | ||
// no locked, all unlocked, can only lock door | ||
List<CardState> unlockStates = c.getUnlockedRooms().stream().map(stateName -> c.getState(stateName)).collect(Collectors.toList()); | ||
CardState chosenUnlock = activator.getController().chooseSingleCardState(sa, unlockStates, "Choose Room to lock", params); | ||
if (chosenUnlock == null) { | ||
continue; | ||
} | ||
c.lockRoom(activator, chosenUnlock.getStateName()); | ||
break; | ||
case 1: | ||
// TODO check for Lock vs Unlock first? | ||
List<CardState> bothStates = Lists.newArrayList(); | ||
bothStates.add(c.getState(CardStateName.LeftSplit)); | ||
bothStates.add(c.getState(CardStateName.RightSplit)); | ||
CardState chosenBoth = activator.getController().chooseSingleCardState(sa, bothStates, "Choose Room to lock or unlock", params); | ||
if (chosenBoth == null) { | ||
continue; | ||
} | ||
if (c.getLockedRooms().contains(chosenBoth.getStateName())) { | ||
c.unlockRoom(activator, chosenBoth.getStateName()); | ||
} else { | ||
c.lockRoom(activator, chosenBoth.getStateName()); | ||
} | ||
break; | ||
case 2: | ||
List<CardState> lockStates = c.getLockedRooms().stream().map(stateName -> c.getState(stateName)).collect(Collectors.toList()); | ||
|
||
// need to choose Room Name | ||
CardState chosenLock = activator.getController().chooseSingleCardState(sa, lockStates, "Choose Room to unlock", params); | ||
if (chosenLock == null) { | ||
continue; | ||
} | ||
c.unlockRoom(activator, chosenLock.getStateName()); | ||
break; | ||
} | ||
break; | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.