Merge branch 'companion' into 'master'

Restrictions for companion

Closes #1767

See merge request core-developers/forge!4171
This commit is contained in:
Michael Kamensky
2021-03-12 07:31:15 +00:00
2 changed files with 6 additions and 6 deletions

View File

@@ -2577,14 +2577,10 @@ public class Player extends GameEntity implements Comparable<Player> {
for (final Card card : game.getCardsIn(ZoneType.Stack)) { for (final Card card : game.getCardsIn(ZoneType.Stack)) {
if (!card.equals(source)) { if (!card.equals(source)) {
onlyThis = false; onlyThis = false;
//System.out.println("StackCard: " + card + " vs SourceCard: " + source);
} }
} }
PhaseHandler now = game.getPhaseHandler(); PhaseHandler now = game.getPhaseHandler();
//System.out.println("now.isPlayerTurn(player) - " + now.isPlayerTurn(player));
//System.out.println("now.getPhase().isMain() - " + now.getPhase().isMain());
//System.out.println("onlyThis - " + onlyThis);
return onlyThis && now.isPlayerTurn(this) && now.getPhase().isMain(); return onlyThis && now.isPlayerTurn(this) && now.getPhase().isMain();
} }
@@ -3144,11 +3140,10 @@ public class Player extends GameEntity implements Comparable<Player> {
DetachedCardEffect eff = new DetachedCardEffect(companion, name); DetachedCardEffect eff = new DetachedCardEffect(companion, name);
String addToHandAbility = "Mode$ Continuous | EffectZone$ Command | Affected$ Card.YouOwn+EffectSource | AffectedZone$ Command | AddAbility$ MoveToHand"; String addToHandAbility = "Mode$ Continuous | EffectZone$ Command | Affected$ Card.YouOwn+EffectSource | AffectedZone$ Command | AddAbility$ MoveToHand";
String moveToHand = "ST$ ChangeZone | Cost$ 3 | Defined$ Self | Origin$ Command | Destination$ Hand | ActivationZone$ Command | SpellDescription$ Companion - Put CARDNAME in to your hand"; String moveToHand = "ST$ ChangeZone | Cost$ 3 | Defined$ Self | Origin$ Command | Destination$ Hand | SorcerySpeed$ True | ActivationZone$ Command | SpellDescription$ Companion - Put CARDNAME in to your hand";
eff.setSVar("MoveToHand", moveToHand); eff.setSVar("MoveToHand", moveToHand);
eff.addStaticAbility(addToHandAbility); eff.addStaticAbility(addToHandAbility);
// TODO Probably remove this effect when the moved to hand
return eff; return eff;
} }

View File

@@ -2231,6 +2231,11 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
} }
public boolean canCastTiming(Card host, Player activator) { public boolean canCastTiming(Card host, Player activator) {
// for companion
if (this instanceof AbilityStatic && getRestrictions().isSorcerySpeed() && !activator.canCastSorcery()) {
return false;
}
// no spell or no activated ability, no check there // no spell or no activated ability, no check there
if (!isSpell() && !isActivatedAbility()) { if (!isSpell() && !isActivatedAbility()) {
return true; return true;