Merge with 145b5b04bab982c1d549a22fef9fc40e6f07a002

master
BeHolder1 2011-09-03 09:46:01 +02:00
commit 789fef53f9
13 changed files with 36 additions and 34 deletions

View File

@ -218,7 +218,7 @@ public class MCTSAI implements MagicAI {
final int bestC,
final int sims) {
final StringBuffer out = new StringBuffer();
final StringBuilder out = new StringBuilder();
final long duration = System.currentTimeMillis() - START_TIME;
out.append("MCTS" +
@ -437,7 +437,7 @@ public class MCTSAI implements MagicAI {
}
private static String CR2String(Object[] choiceResults) {
final StringBuffer buffer=new StringBuffer();
final StringBuilder buffer=new StringBuilder();
if (choiceResults!=null) {
buffer.append(" (");
boolean first=true;
@ -455,7 +455,7 @@ public class MCTSAI implements MagicAI {
}
private boolean printPath(final List<MCTSGameTree> path) {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
for (MCTSGameTree p : path) {
sb.append(" -> ").append(p.desc);
}

View File

@ -136,7 +136,7 @@ public class DeckUtils {
}
// Find up to 3 of the most common colors in the deck.
final StringBuffer colorText=new StringBuffer();
final StringBuilder colorText=new StringBuilder();
while (colorText.length()<3) {
int maximum=0;
int index=0;

View File

@ -27,7 +27,7 @@ public class HighQualityCardImagesProvider implements CardImagesProvider {
final MagicCardDefinition cardDefinition,
final int index) {
final int imageIndex=index%cardDefinition.getImageCount();
final StringBuffer buffer=new StringBuffer();
final StringBuilder buffer=new StringBuilder();
buffer.append(MagicMain.getGamePath()).append(File.separator);
buffer.append(cardDefinition.isToken()?"tokens":"cards").append(File.separator);
buffer.append(cardDefinition.getImageName());

View File

@ -57,7 +57,7 @@ public enum MagicColor {
case Red: return MagicAbility.ProtectionFromRed;
case White: return MagicAbility.ProtectionFromWhite;
}
return null;
throw new RuntimeException("No protection ability for MagicColor " + this);
}
public MagicAbility getLandwalkAbility() {
@ -68,7 +68,7 @@ public enum MagicColor {
case Red: return MagicAbility.Mountainwalk;
case White: return MagicAbility.PlainsWalk;
}
return null;
throw new RuntimeException("No landwalk ability for MagicColor " + this);
}
public MagicSubType getLandSubType() {
@ -79,7 +79,7 @@ public enum MagicColor {
case Red: return MagicSubType.Mountain;
case White: return MagicSubType.Plains;
}
return null;
throw new RuntimeException("No land subtype for MagicColor " + this);
}
public MagicManaType getManaType() {
@ -101,7 +101,7 @@ public enum MagicColor {
case Red: return IconImages.RED;
case White: return IconImages.WHITE;
}
return null;
throw new RuntimeException("No icon for MagicColor " + this);
}
public static int getFlags(final String colors) {
@ -120,13 +120,13 @@ public enum MagicColor {
if (color.symbol==usymbol) {
return color;
}
}
return null;
}
throw new RuntimeException("No corresponding MagicColor for " + symbol);
}
public static String getRandomColors(final int count) {
final List<Character> colors=new ArrayList<Character>(Arrays.<Character>asList('b','u','g','r','w'));
final StringBuffer colorText=new StringBuffer();
final StringBuilder colorText=new StringBuilder();
for (int c=count;c>0;c--) {
final int index=MagicRandom.nextInt(colors.size());
colorText.append((char)colors.remove(index));

View File

@ -263,7 +263,7 @@ public class MagicGame {
}
public String getIdString() {
StringBuffer sb = new StringBuffer(toString());
StringBuilder sb = new StringBuilder(toString());
sb.append('\n');
sb.append(keys[0]);
for (int i = 1; i < keys.length; i++) {

View File

@ -55,6 +55,6 @@ public enum MagicManaType {
case Red: return small?IconImages.COST_RED:IconImages.RED;
case White: return small?IconImages.COST_WHITE:IconImages.WHITE;
}
return null;
throw new RuntimeException("No icon available for MagicManaType " + this);
}
}

View File

@ -14,10 +14,10 @@ public enum MagicPermanentState {
SacrificeAtEndOfTurn("sacrifice at end of turn","{S}"),
RemoveAtEndOfTurn("remove from game at end of turn","{E}"),
RemoveAtEndOfYourTurn("remove from game at end of your turn","{E}"),
ExcludeManaSource("exclude as mana source",null),
ExcludeFromCombat("exclude from combat",null),
Kicked("kicked",null),
Destroyed("destroyed",null),
ExcludeManaSource("exclude as mana source",""),
ExcludeFromCombat("exclude from combat",""),
Kicked("kicked",""),
Destroyed("destroyed",""),
ReturnToOwnerAtEndOfTurn("return to owner at end of turn","{R}"),
;

View File

@ -119,7 +119,7 @@ public class MagicPlayer implements MagicTarget {
}
public String getIdString() {
StringBuffer sb = new StringBuffer();
StringBuilder sb = new StringBuilder();
sb.append(keys[0]);
for (int i = 1; i < keys.length; i++) {
sb.append(' ');

View File

@ -28,7 +28,7 @@ public class MagicCardChoiceResult extends ArrayList<MagicCard> implements Magic
@Override
public String toString() {
final StringBuffer buffer=new StringBuffer();
final StringBuilder buffer=new StringBuilder();
for (final MagicCard card : this) {
if (buffer.length()>0) {
buffer.append(", ");

View File

@ -47,7 +47,7 @@ public class MagicExcludeResult implements MagicMappable {
@Override
public String toString() {
final StringBuffer buffer=new StringBuffer();
final StringBuilder buffer=new StringBuilder();
for (int index=0,flag=1;index<excludePermanents.size();index++,flag<<=1) {
if (buffer.length()>0) {
buffer.append(", ");

View File

@ -11,20 +11,22 @@ public class MagicRemoveCounterEvent extends MagicEvent {
@Override
public void executeEvent(final MagicGame game,final MagicEvent event,final Object[] data,final Object[] choices) {
final int amount=(Integer)data[2];
game.doAction(new MagicChangeCountersAction((MagicPermanent)data[0],(MagicCounterType)data[1],-amount,true));
}
};
public MagicRemoveCounterEvent(final MagicPermanent permanent,final MagicCounterType counterType,final int amount) {
super(permanent,permanent.getController(),new Object[]{permanent,counterType,amount},EVENT_ACTION,getDescription(permanent,counterType,amount));
super(
permanent,
permanent.getController(),
new Object[]{permanent,counterType,amount},
EVENT_ACTION,
getDescription(permanent,counterType,amount));
}
private static String getDescription(final MagicPermanent permanent,final MagicCounterType counterType,final int amount) {
final StringBuffer description=new StringBuffer("Remove ");
final StringBuilder description=new StringBuilder("Remove ");
if (amount==1) {
description.append("a ").append(counterType.getName()).append(" counter");
} else {
@ -33,4 +35,4 @@ public class MagicRemoveCounterEvent extends MagicEvent {
description.append(" from ").append(permanent.getName()).append('.');
return description.toString();
}
}
}

View File

@ -35,14 +35,14 @@ public class MagicCombatDamagePhase extends MagicPhase {
final int lifeAfter=defendingPlayer.getLife();
final int poisonAfter=defendingPlayer.getPoison();
final StringBuffer message=new StringBuffer();
final StringBuilder message=new StringBuilder();
if (lifeAfter>lifeBefore) {
message.append(" gains " + (lifeAfter-lifeBefore) + " life.");
message.append(" gains ").append(lifeAfter-lifeBefore).append(" life.");
} else if (lifeAfter<lifeBefore) {
message.append(" loses " + (lifeBefore-lifeAfter) + " life.");
message.append(" loses ").append(lifeBefore-lifeAfter).append(" life.");
}
if (poisonAfter>poisonBefore) {
message.append(" gets " + (poisonAfter-poisonBefore) + " poison counters.");
message.append(" gets ").append(poisonAfter-poisonBefore).append(" poison counters.");
}
if (message.length()>0) {
game.logMessage(defendingPlayer,"{c}" + playerName + message.toString());

View File

@ -103,7 +103,7 @@ public class PermanentViewerInfo {
}
private static String getText(final MagicGame game,final MagicPermanent permanent,final long abilityFlags) {
final StringBuffer textBuffer=new StringBuffer("");
final StringBuilder textBuffer=new StringBuilder();
// States
if (isTargeted(game,permanent)) {
@ -169,7 +169,7 @@ public class PermanentViewerInfo {
if (first) {
first=false;
if (textBuffer.length()>0) {
textBuffer.append("|");
textBuffer.append('|');
}
} else {
textBuffer.append(", ");
@ -186,7 +186,7 @@ public class PermanentViewerInfo {
if (first) {
first=false;
if (textBuffer.length()>0) {
textBuffer.append("|");
textBuffer.append('|');
}
} else {
textBuffer.append(", ");