mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Added Protection keywords to players.
This commit is contained in:
@@ -7354,7 +7354,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
|
|
||||||
int restDamage = damageIn;
|
int restDamage = damageIn;
|
||||||
|
|
||||||
if (CardFactoryUtil.hasProtectionFrom(source, this)) {
|
if (hasProtectionFrom(source)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8008,7 +8008,8 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
getCharacteristics().setCardColorsOverridden(cardColorsOverridden0);
|
getCharacteristics().setCardColorsOverridden(cardColorsOverridden0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean hasProtectionFrom(Card source) {
|
@Override
|
||||||
|
public boolean hasProtectionFrom(Card source) {
|
||||||
if (source == null) {
|
if (source == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -771,7 +771,7 @@ public class CardList implements Iterable<Card> {
|
|||||||
public final CardList getUnprotectedCards(final Card source) {
|
public final CardList getUnprotectedCards(final Card source) {
|
||||||
return this.filter(new CardListFilter() {
|
return this.filter(new CardListFilter() {
|
||||||
public boolean addCard(final Card c) {
|
public boolean addCard(final Card c) {
|
||||||
return !CardFactoryUtil.hasProtectionFrom(source, c);
|
return !c.hasProtectionFrom(source);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -905,7 +905,8 @@ public class GameAction {
|
|||||||
if (tgt.canOnlyTgtOpponent() && !c.getController().getOpponent().isPlayer(pl)) {
|
if (tgt.canOnlyTgtOpponent() && !c.getController().getOpponent().isPlayer(pl)) {
|
||||||
invalid = true;
|
invalid = true;
|
||||||
} else {
|
} else {
|
||||||
// TODO Check Player Protection once it's added.
|
if(pl.hasProtectionFrom(c))
|
||||||
|
invalid = true;
|
||||||
}
|
}
|
||||||
if (invalid) {
|
if (invalid) {
|
||||||
c.unEnchantEntity(pl);
|
c.unEnchantEntity(pl);
|
||||||
|
|||||||
@@ -409,6 +409,10 @@ public abstract class GameEntity extends MyObservable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasProtectionFrom(Card source) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// //////////////////////////////
|
// //////////////////////////////
|
||||||
//
|
//
|
||||||
// generic Object overrides
|
// generic Object overrides
|
||||||
|
|||||||
@@ -533,6 +533,10 @@ public abstract class Player extends GameEntity {
|
|||||||
return damage;
|
return damage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (hasProtectionFrom(source)) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int restDamage = damage;
|
int restDamage = damage;
|
||||||
|
|
||||||
if (isCombat) {
|
if (isCombat) {
|
||||||
@@ -924,13 +928,53 @@ public abstract class Player extends GameEntity {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final boolean canTarget(final SpellAbility sa) {
|
public final boolean canTarget(final SpellAbility sa) {
|
||||||
if (hasKeyword("Shroud") || (!this.isPlayer(sa.getActivatingPlayer()) && hasKeyword("Hexproof"))) {
|
if (hasKeyword("Shroud")
|
||||||
|
|| (!this.isPlayer(sa.getActivatingPlayer()) && hasKeyword("Hexproof"))
|
||||||
|
|| hasProtectionFrom(sa.getSourceCard())) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasProtectionFrom(Card source) {
|
||||||
|
if (getKeywords() != null) {
|
||||||
|
final ArrayList<String> list = getKeywords();
|
||||||
|
|
||||||
|
String kw = "";
|
||||||
|
for (int i = 0; i < list.size(); i++) {
|
||||||
|
kw = list.get(i);
|
||||||
|
|
||||||
|
if (kw.equals("Protection from white") && source.isWhite()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (kw.equals("Protection from blue") && source.isBlue()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (kw.equals("Protection from black") && source.isBlack()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (kw.equals("Protection from red") && source.isRed()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (kw.equals("Protection from green") && source.isGreen()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (kw.startsWith("Protection:")) { // uses isValid
|
||||||
|
final String characteristic = kw.split(":")[1];
|
||||||
|
final String[] characteristics = characteristic.split(",");
|
||||||
|
if (source.isValid(characteristics, this, null)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* canPlaySpells.
|
* canPlaySpells.
|
||||||
|
|||||||
Reference in New Issue
Block a user