- Continuous static abilities can now add keywords to players.

- Added Ivory Mask.
This commit is contained in:
Sloth
2011-09-07 12:52:07 +00:00
parent 5e7d9a7492
commit 2d40122299
5 changed files with 68 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ public class StaticEffect {
private Card source = new Card();
private int keywordNumber = 0;
private CardList affectedCards = new CardList();
private ArrayList<Player> affectedPlayers = new ArrayList<Player>();
private int xValue = 0;
private int yValue = 0;
private long timestamp = -1;
@@ -596,7 +597,14 @@ public class StaticEffect {
public void setAffectedCards(CardList list) {
affectedCards = list;
}
public ArrayList<Player> getAffectedPlayers() {
return affectedPlayers;
}
public void setAffectedPlayers(ArrayList<Player> list) {
affectedPlayers = list;
}
/**
* <p>Setter for the field <code>xValue</code>.</p>
*

View File

@@ -53,6 +53,7 @@ public class StaticEffects {
*/
final void removeStaticEffect(final StaticEffect se) {
CardList affectedCards = se.getAffectedCards();
ArrayList<Player> affectedPlayers = se.getAffectedPlayers();
HashMap<String, String> params = se.getParams();
int powerBonus = 0;
@@ -98,6 +99,15 @@ public class StaticEffects {
addColors = CardUtil.getShortColorsString(
new ArrayList<String>(Arrays.asList(params.get("SetColor").split(" & "))));
}
//modify players
for (Player p : affectedPlayers) {
// add keywords
if (addKeywords != null)
for (String keyword : addKeywords)
p.removeKeyword(keyword);
}
//modify the affected card
for (int i = 0; i < affectedCards.size(); i++) {

View File

@@ -25,8 +25,10 @@ public class StaticAbility_Continuous {
StaticEffect se = new StaticEffect();
CardList affectedCards = getAffectedCards(stAb);
ArrayList<Player> affectedPlayers = getAffectedPlayers(stAb);
se.setAffectedCards(affectedCards);
se.setAffectedPlayers(affectedPlayers);
se.setParams(params);
se.setTimestamp(hostCard.getTimestamp());
AllZone.getStaticEffects().addStaticEffect(se);
@@ -144,6 +146,15 @@ public class StaticAbility_Continuous {
sVars[i] = hostCard.getSVar(sVars[i]);
addTriggers = sVars;
}
//modify players
for (Player p : affectedPlayers) {
// add keywords
if (addKeywords != null)
for (String keyword : addKeywords)
p.addKeyword(keyword);
}
//start modifying the cards
for (int i = 0; i < affectedCards.size(); i++) {
@@ -215,6 +226,32 @@ public class StaticAbility_Continuous {
}
}
private static ArrayList<Player> getAffectedPlayers(StaticAbility stAb) {
HashMap<String, String> params = stAb.getMapParams();
Card hostCard = stAb.getHostCard();
Player controller = hostCard.getController();
ArrayList<Player> players = new ArrayList<Player>();
if(!params.containsKey("Affected")) {
return players;
}
String[] strngs = params.get("Affected").split(",");
for (String str : strngs) {
if(str.equals("Player") || str.equals("You")) {
players.add(controller);
}
if(str.equals("Player") || str.equals("Opponent")) {
players.add(controller.getOpponent());
}
}
return players;
}
private static CardList getAffectedCards(StaticAbility stAb) {
HashMap<String, String> params = stAb.getMapParams();
Card hostCard = stAb.getHostCard();