Merge branch 'cleanup' into 'master'

Code cleanup

See merge request core-developers/forge!4248
This commit is contained in:
Hans Mackowiak
2021-03-23 17:17:37 +00:00
37 changed files with 196 additions and 227 deletions

View File

@@ -1120,9 +1120,8 @@ public class AiController {
CardCollection discards = CardLists.filter(player.getCardsIn(ZoneType.Hand), CardPredicates.hasCMC(cmc));
if (discards.isEmpty()) {
return null;
} else {
return new CardCollection(ComputerUtilCard.getWorstAI(discards));
}
return new CardCollection(ComputerUtilCard.getWorstAI(discards));
}
if (sa.hasParam("AnyNumber")) {

View File

@@ -2929,9 +2929,8 @@ public class ComputerUtil {
}
if (targetSpellCard == null) {
return false;
} else {
sa.getTargets().add(targetSpellCard);
}
sa.getTargets().add(targetSpellCard);
return true;
}

View File

@@ -1214,10 +1214,9 @@ public class ComputerUtilCard {
final float valueNow = Math.max(valueTempo, threat);
if (valueNow < 0.2) { //hard floor to reduce ridiculous odds for instants over time
return false;
} else {
final float chance = MyRandom.getRandom().nextFloat();
return chance < valueNow;
}
final float chance = MyRandom.getRandom().nextFloat();
return chance < valueNow;
}
/**

View File

@@ -162,10 +162,9 @@ public class ComputerUtilCost {
Card pref = ComputerUtil.getCardPreference(ai, source, "DiscardCost", typeList);
if (pref == null) {
return false;
} else {
typeList.remove(pref);
hand.remove(pref);
}
typeList.remove(pref);
hand.remove(pref);
}
}
}

View File

@@ -108,9 +108,7 @@ public class PlayerControllerAi extends PlayerController {
if (abilities.size() == 0) {
return null;
}
else {
return abilities.get(0);
}
return abilities.get(0);
}
public AiController getAi() {

View File

@@ -30,40 +30,38 @@ public class AmassAi extends SpellAbilityAi {
if (!aiArmies.isEmpty()) {
return CardLists.count(aiArmies, CardPredicates.canReceiveCounters(CounterEnumType.P1P1)) > 0;
} else {
final String tokenScript = "b_0_0_zombie_army";
final int amount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("Num", "1"), sa);
}
final String tokenScript = "b_0_0_zombie_army";
final int amount = AbilityUtils.calculateAmount(host, sa.getParamOrDefault("Num", "1"), sa);
Card token = TokenInfo.getProtoType(tokenScript, sa, false);
Card token = TokenInfo.getProtoType(tokenScript, sa, false);
if (token == null) {
return false;
}
token.setController(ai, 0);
token.setLastKnownZone(ai.getZone(ZoneType.Battlefield));
boolean result = true;
// need to check what the cards would be on the battlefield
// do not attach yet, that would cause Events
CardCollection preList = new CardCollection(token);
game.getAction().checkStaticAbilities(false, Sets.newHashSet(token), preList);
if (token.canReceiveCounters(CounterEnumType.P1P1)) {
token.setCounters(CounterEnumType.P1P1, amount);
}
if (token.isCreature() && token.getNetToughness() < 1) {
result = false;
}
//reset static abilities
game.getAction().checkStaticAbilities(false);
return result;
if (token == null) {
return false;
}
token.setController(ai, 0);
token.setLastKnownZone(ai.getZone(ZoneType.Battlefield));
boolean result = true;
// need to check what the cards would be on the battlefield
// do not attach yet, that would cause Events
CardCollection preList = new CardCollection(token);
game.getAction().checkStaticAbilities(false, Sets.newHashSet(token), preList);
if (token.canReceiveCounters(CounterEnumType.P1P1)) {
token.setCounters(CounterEnumType.P1P1, amount);
}
if (token.isCreature() && token.getNetToughness() < 1) {
result = false;
}
//reset static abilities
game.getAction().checkStaticAbilities(false);
return result;
}
@Override

View File

@@ -1452,12 +1452,11 @@ public class ChangeZoneAi extends SpellAbilityAi {
if (sa.getTargets().size() == 0 || sa.getTargets().size() < tgt.getMinTargets(sa.getHostCard(), sa)) {
sa.resetTargets();
return false;
} else {
if (!ComputerUtil.shouldCastLessThanMax(ai, source)) {
return false;
}
break;
}
if (!ComputerUtil.shouldCastLessThanMax(ai, source)) {
return false;
}
break;
}
list.remove(choice);
@@ -1958,9 +1957,8 @@ public class ChangeZoneAi extends SpellAbilityAi {
if (choice != null) {
sa.getTargets().add(choice);
return true;
} else {
return false;
}
return false;
}
private static CardCollection getSafeTargetsIfUnlessCostPaid(Player ai, SpellAbility sa, Iterable<Card> potentialTgts) {

View File

@@ -141,27 +141,26 @@ public class ChooseSourceAi extends SpellAbilityAi {
Card bestCreature = ComputerUtilCard.getBestCreatureAI(permanentSources);
if (bestCreature != null) {
return bestCreature;
} else {
// No optimal creature was found above, so try to broaden the choice.
if (!Iterables.isEmpty(options)) {
List<Card> oppCreatures = CardLists.filter(options, Predicates.and(CardPredicates.Presets.CREATURES,
Predicates.not(CardPredicates.isOwner(aiChoser))));
List<Card> aiNonCreatures = CardLists.filter(options, Predicates.and(Predicates.not(CardPredicates.Presets.CREATURES),
CardPredicates.Presets.PERMANENTS, CardPredicates.isOwner(aiChoser)));
}
// No optimal creature was found above, so try to broaden the choice.
if (!Iterables.isEmpty(options)) {
List<Card> oppCreatures = CardLists.filter(options, Predicates.and(CardPredicates.Presets.CREATURES,
Predicates.not(CardPredicates.isOwner(aiChoser))));
List<Card> aiNonCreatures = CardLists.filter(options, Predicates.and(Predicates.not(CardPredicates.Presets.CREATURES),
CardPredicates.Presets.PERMANENTS, CardPredicates.isOwner(aiChoser)));
if (!oppCreatures.isEmpty()) {
return ComputerUtilCard.getBestCreatureAI(oppCreatures);
} else if (!aiNonCreatures.isEmpty()) {
return Aggregates.random(aiNonCreatures);
} else {
return Aggregates.random(options);
}
} else if (!game.getStack().isEmpty()) {
// No permanent for the AI to choose. Should normally not happen unless using dev mode or something,
// but when it does happen, choose the top card on stack if possible (generally it'll be the SA
// source) in order to choose at least something, or the game will hang.
return game.getStack().peekAbility().getHostCard();
if (!oppCreatures.isEmpty()) {
return ComputerUtilCard.getBestCreatureAI(oppCreatures);
} else if (!aiNonCreatures.isEmpty()) {
return Aggregates.random(aiNonCreatures);
} else {
return Aggregates.random(options);
}
} else if (!game.getStack().isEmpty()) {
// No permanent for the AI to choose. Should normally not happen unless using dev mode or something,
// but when it does happen, choose the top card on stack if possible (generally it'll be the SA
// source) in order to choose at least something, or the game will hang.
return game.getStack().peekAbility().getHostCard();
}
// Should never get here

View File

@@ -140,7 +140,7 @@ public class ControlExchangeAi extends SpellAbilityAi {
return false;
}
if (aiWorst != null && aiWorst != bestFirstTgt) {
if (aiWorst != bestFirstTgt) {
if (bestFirstTgt.isCreature() && aiWorst.isCreature()) {
if ((ComputerUtilCard.evaluateCreature(bestFirstTgt) > ComputerUtilCard.evaluateCreature(aiWorst) + creatureThreshold) || sa.isMandatory()) {
sa.getTargets().add(aiWorst);

View File

@@ -268,9 +268,8 @@ public class ControlGainAi extends SpellAbilityAi {
List<Card> list = CardLists.getTargetableCards(ai.getCardsIn(ZoneType.Battlefield), sa);
if (list.isEmpty()) {
return false;
} else {
sa.getTargets().add(ComputerUtilCard.getWorstAI(list));
}
sa.getTargets().add(ComputerUtilCard.getWorstAI(list));
}
}

View File

@@ -68,7 +68,7 @@ public class CopySpellAbilityAi extends SpellAbilityAi {
}
}
if (top.isWrapper() || !(top instanceof SpellAbility || top.isActivatedAbility())) {
if (top.isWrapper() || top.isActivatedAbility()) {
// Shouldn't even try with triggered or wrapped abilities at this time, will crash
return false;
} else if (top.getApi() == ApiType.CopySpellAbility) {

View File

@@ -642,10 +642,10 @@ public class BoosterGenerator {
if (toAdd == null) {
continue;
} else {
itOp.remove();
}
itOp.remove();
if (invert) {
toAdd = Predicates.not(toAdd);
}
@@ -658,8 +658,6 @@ public class BoosterGenerator {
}
return Predicates.and(conditions);
}
}

View File

@@ -203,7 +203,7 @@ public class GameLogFormatter extends IGameEventVisitor.Base<GameLogEntry> {
@Override
public GameLogEntry visit(GameEventTurnBegan event) {
String message = Localizer.getInstance().getMessage("lblLogTurnNOwnerByPlayer", String.valueOf(event.turnNumber), event.turnOwner.toString());;
String message = Localizer.getInstance().getMessage("lblLogTurnNOwnerByPlayer", String.valueOf(event.turnNumber), event.turnOwner.toString());
return new GameLogEntry(GameLogEntryType.TURN, message);
}

View File

@@ -558,7 +558,7 @@ public class AbilityUtils {
else if (hType.startsWith("Property") && ability instanceof SpellAbility) {
String defined = hType.split("Property")[1];
for (Player p : game.getPlayersInTurnOrder()) {
if (p.hasProperty(defined, ((SpellAbility) ability).getActivatingPlayer(), ability.getHostCard(), (SpellAbility) ability)) {
if (p.hasProperty(defined, ((SpellAbility) ability).getActivatingPlayer(), ability.getHostCard(), ability)) {
players.add(p);
}
}
@@ -1105,7 +1105,7 @@ public class AbilityUtils {
}
// For merged permanent
if (c instanceof CardCollection) {
o = ((CardCollection) c).get(0).getController().getOpponents();;
o = ((CardCollection) c).get(0).getController().getOpponents();
}
}
else if (defParsed.endsWith("Owner")) {
@@ -1828,13 +1828,11 @@ public class AbilityUtils {
}
}
if (ctb instanceof CardTraitBase) {
if (l[0].startsWith("CountersAddedThisTurn")) {
final String[] parts = l[0].split(" ");
CounterType cType = CounterType.getType(parts[1]);
if (l[0].startsWith("CountersAddedThisTurn")) {
final String[] parts = l[0].split(" ");
CounterType cType = CounterType.getType(parts[1]);
return CardFactoryUtil.doXMath(game.getCounterAddedThisTurn(cType, parts[2], parts[3], c, player, ctb), expr, c);
}
return CardFactoryUtil.doXMath(game.getCounterAddedThisTurn(cType, parts[2], parts[3], c, player, ctb), expr, c);
}
}
return CardFactoryUtil.xCount(c, s2);

View File

@@ -54,10 +54,9 @@ public class AttachEffect extends SpellAbilityEffect {
if (targets.isEmpty()) {
return;
} else {
attachTo = targets.get(0);
}
attachTo = targets.get(0);
String attachToName = null;
if (attachTo instanceof Card) {
attachToName = CardTranslation.getTranslatedName(((Card)attachTo).getName());

View File

@@ -261,7 +261,7 @@ public class CountersMoveEffect extends SpellAbilityEffect {
}
for (final Card dest : tgtCards) {
if (null != source && null != dest) {
if (null != dest) {
// rule 121.5: If the first and second objects are the same object, nothing
// happens
if (source.equals(dest)) {

View File

@@ -160,10 +160,9 @@ public abstract class TokenEffectBase extends SpellAbilityEffect {
tok.attachToEntity(ge);
return true;
} else {
// not a GameEntity, cant be attach
return false;
}
// not a GameEntity, cant be attach
return false;
}
protected void addPumpUntil(SpellAbility sa, final Card c, long timestamp) {

View File

@@ -3565,7 +3565,7 @@ public class Card extends GameEntity implements Comparable<Card>, IHasSVars {
// values that are printed on card
public final void setBasePowerString(final String s) {
currentState.setBasePowerString(s);;
currentState.setBasePowerString(s);
}
public final void setBaseToughnessString(final String s) {

View File

@@ -1508,14 +1508,14 @@ public class CardProperty {
String what = property.substring("blocking".length());
if (StringUtils.isEmpty(what)) return combat.isBlocking(card);
if (what.startsWith("Source")) return combat.isBlocking(card, source) ;
if (what.startsWith("Source")) return combat.isBlocking(card, source);
if (what.startsWith("CreatureYouCtrl")) {
for (final Card c : CardLists.filter(sourceController.getCardsIn(ZoneType.Battlefield), Presets.CREATURES))
if (combat.isBlocking(card, c))
return true;
return false;
} else {
for(Card c : AbilityUtils.getDefinedCards(source, what, spellAbility)) {
for (Card c : AbilityUtils.getDefinedCards(source, what, spellAbility)) {
if (combat.isBlocking(card, c)) {
return true;
}

View File

@@ -89,22 +89,20 @@ public class CostReveal extends CostPartWithList {
} else if (this.getType().equals("SameColor")) {
if (amount == null) {
return false;
} else {
for (final Card card : handList) {
if (CardLists.filter(handList, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
return c.sharesColorWith(card);
}
}).size() >= amount) {
return true;
}
}
return false;
}
for (final Card card : handList) {
if (CardLists.filter(handList, new Predicate<Card>() {
@Override
public boolean apply(final Card c) {
return c.sharesColorWith(card);
}
}).size() >= amount) {
return true;
}
}
return false;
} else {
return (amount == null) || (amount <= getMaxAmountX(ability, payer));
//System.out.println("revealcost - " + amount + type + handList);
}
}

View File

@@ -198,7 +198,7 @@ public class Player extends GameEntity implements Comparable<Player> {
private final Map<ZoneType, PlayerZone> zones = Maps.newEnumMap(ZoneType.class);
private final Map<Long, Integer> adjustLandPlays = Maps.newHashMap();
private final Set<Long> adjustLandPlaysInfinite = Sets.newHashSet();
private Map<Card, Card> maingameCardsMap = Maps.newHashMap();;
private Map<Card, Card> maingameCardsMap = Maps.newHashMap();
private CardCollection currentPlanes = new CardCollection();
private Set<String> prowl = Sets.newHashSet();
@@ -3448,10 +3448,11 @@ public class Player extends GameEntity implements Comparable<Player> {
return true;
}
if (this.hasKeyword("CantSearchLibrary")) {
if (hasKeyword("CantSearchLibrary")) {
return false;
} else return targetPlayer == null || !targetPlayer.equals(sa.getActivatingPlayer())
|| !hasKeyword("Spells and abilities you control can't cause you to search your library.");
}
return targetPlayer == null || !targetPlayer.equals(sa.getActivatingPlayer())
|| !hasKeyword("Spells and abilities you control can't cause you to search your library.");
}

View File

@@ -83,7 +83,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable
}
// do performanceMode only for cases where the activator is different than controller
if (!Spell.performanceMode && activator != null && !card.getController().equals(activator)) {
if (!Spell.performanceMode && !card.getController().equals(activator)) {
// always make a lki copy in this case?
card = CardUtil.getLKICopy(card);
card.setController(activator, 0);

View File

@@ -290,12 +290,11 @@ public class SpellAbilityCondition extends SpellAbilityVariables {
Card first = Iterables.getFirst(tgts, null);
if (first == null) {
return false;
} else {
byte firstColor = CardUtil.getColors(first).getColor();
for (Card c : tgts) {
if (CardUtil.getColors(c).getColor() != firstColor) {
return false;
}
}
byte firstColor = CardUtil.getColors(first).getColor();
for (Card c : tgts) {
if (CardUtil.getColors(c).getColor() != firstColor) {
return false;
}
}
}

View File

@@ -489,19 +489,18 @@ public class TargetRestrictions {
if (this.tgtZone.contains(ZoneType.Stack)) {
// Stack Zone targets are considered later
return true;
} else {
for (final Card c : game.getCardsIn(this.tgtZone)) {
if (!c.isValid(this.validTgts, sa.getActivatingPlayer(), srcCard, sa)) {
continue;
}
if (isTargeted && !sa.canTarget(c)) {
continue;
}
if (sa.getTargets().contains(c)) {
continue;
}
return true;
}
for (final Card c : game.getCardsIn(this.tgtZone)) {
if (!c.isValid(this.validTgts, sa.getActivatingPlayer(), srcCard, sa)) {
continue;
}
if (isTargeted && !sa.canTarget(c)) {
continue;
}
if (sa.getTargets().contains(c)) {
continue;
}
return true;
}
return false;

View File

@@ -283,13 +283,12 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
// AbilityStatic should do nothing below
return;
}
else {
for (OptionalCost s : sp.getOptionalCosts()) {
source.addOptionalCostPaid(s);
}
// The ability is added to stack HERE
si = push(sp);
for (OptionalCost s : sp.getOptionalCosts()) {
source.addOptionalCostPaid(s);
}
// The ability is added to stack HERE
si = push(sp);
// Copied spells aren't cast per se so triggers shouldn't run for them.
Map<AbilityKey, Object> runParams = AbilityKey.newMap();

View File

@@ -766,22 +766,28 @@ public class FDeckChooser extends JPanel implements IDecksComboBoxListener {
if (deckType.startsWith(NetDeckCategory.PREFIX)) {
netDeckCategory = NetDeckCategory.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckCategory.PREFIX.length()));
return DeckType.NET_DECK;
} else if (deckType.startsWith(NetDeckArchiveStandard.PREFIX)) {
}
if (deckType.startsWith(NetDeckArchiveStandard.PREFIX)) {
NetDeckArchiveStandard = NetDeckArchiveStandard.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveStandard.PREFIX.length()));
return DeckType.NET_ARCHIVE_STANDARD_DECK;
} else if (deckType.startsWith(NetDeckArchivePioneer.PREFIX)) {
}
if (deckType.startsWith(NetDeckArchivePioneer.PREFIX)) {
NetDeckArchivePioneer = NetDeckArchivePioneer.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchivePioneer.PREFIX.length()));
return DeckType.NET_ARCHIVE_PIONEER_DECK;
} else if (deckType.startsWith(NetDeckArchiveModern.PREFIX)) {
}
if (deckType.startsWith(NetDeckArchiveModern.PREFIX)) {
NetDeckArchiveModern = NetDeckArchiveModern.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveModern.PREFIX.length()));
return DeckType.NET_ARCHIVE_MODERN_DECK;
} else if (deckType.startsWith(NetDeckArchiveLegacy.PREFIX)) {
}
if (deckType.startsWith(NetDeckArchiveLegacy.PREFIX)) {
NetDeckArchiveLegacy = NetDeckArchiveLegacy.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveLegacy.PREFIX.length()));
return DeckType.NET_ARCHIVE_LEGACY_DECK;
} else if (deckType.startsWith(NetDeckArchiveVintage.PREFIX)) {
}
if (deckType.startsWith(NetDeckArchiveVintage.PREFIX)) {
NetDeckArchiveVintage = NetDeckArchiveVintage.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveVintage.PREFIX.length()));
return DeckType.NET_ARCHIVE_VINTAGE_DECK;
} else if (deckType.startsWith(NetDeckArchiveBlock.PREFIX)) {
}
if (deckType.startsWith(NetDeckArchiveBlock.PREFIX)) {
NetDeckArchiveBlock = NetDeckArchiveBlock.selectAndLoad(lstDecks.getGameType(), deckType.substring(NetDeckArchiveBlock.PREFIX.length()));
return DeckType.NET_ARCHIVE_BLOCK_DECK;
}

View File

@@ -715,15 +715,14 @@ public class VLobby implements ILobbyView {
if (sel == null) {
return;
} else {
if (sel.contains("Use deck's default avatar") && deck != null && deck.has(DeckSection.Avatar)) {
vanguardAvatar = deck.get(DeckSection.Avatar).get(0);
} else { //Only other string is "Random"
if (playerPanels.get(playerIndex).isAi()) { //AI
vanguardAvatar = Aggregates.random(getNonRandomAiAvatars());
} else { //Human
vanguardAvatar = Aggregates.random(getNonRandomHumanAvatars());
}
}
if (sel.contains("Use deck's default avatar") && deck != null && deck.has(DeckSection.Avatar)) {
vanguardAvatar = deck.get(DeckSection.Avatar).get(0);
} else { //Only other string is "Random"
if (playerPanels.get(playerIndex).isAi()) { //AI
vanguardAvatar = Aggregates.random(getNonRandomAiAvatars());
} else { //Human
vanguardAvatar = Aggregates.random(getNonRandomHumanAvatars());
}
}
}

View File

@@ -126,9 +126,7 @@ public class QuickGauntletLister extends JPanel {
if (previousSelect == null) {
return null;
}
else {
return GauntletIO.getGauntletFile(previousSelect.getGauntletData());
}
return GauntletIO.getGauntletFile(previousSelect.getGauntletData());
}
private class DeleteButton extends SkinnedButton {

View File

@@ -1357,24 +1357,23 @@ public final class CMatchUI
private List<GameEntityView> getTargets(SpellAbilityStackInstance si, List<GameEntityView> result){
if(si == null) {
return result;
} else {
FCollectionView<CardView> targetCards = CardView.getCollection(si.getTargetChoices().getTargetCards());
for(CardView currCardView: targetCards) {
result.add(currCardView);
}
for(SpellAbility currSA : si.getTargetChoices().getTargetSpells()) {
CardView currCardView = currSA.getCardView();
result.add(currCardView);
}
FCollectionView<PlayerView> targetPlayers = PlayerView.getCollection(si.getTargetChoices().getTargetPlayers());
for(PlayerView currPlayerView : targetPlayers) {
result.add(currPlayerView);
}
return getTargets(si.getSubInstance(),result);
}
FCollectionView<CardView> targetCards = CardView.getCollection(si.getTargetChoices().getTargetCards());
for(CardView currCardView: targetCards) {
result.add(currCardView);
}
for(SpellAbility currSA : si.getTargetChoices().getTargetSpells()) {
CardView currCardView = currSA.getCardView();
result.add(currCardView);
}
FCollectionView<PlayerView> targetPlayers = PlayerView.getCollection(si.getTargetChoices().getTargetPlayers());
for(PlayerView currPlayerView : targetPlayers) {
result.add(currPlayerView);
}
return getTargets(si.getSubInstance(),result);
}
private void addBigImageToStackModalPanel(JPanel mainPanel, SpellAbilityStackInstance si) {

View File

@@ -90,9 +90,8 @@ public class AutoUpdater {
int option = SOptionPane.showOptionDialog(message, localizer.getMessage("lblManualCheck"), null, options, 0);
if (option < 1) {
return false;
} else {
updateChannel = options.get(option);
}
updateChannel = options.get(option);
}
if (buildVersion.contains("SNAPSHOT")) {

View File

@@ -327,17 +327,15 @@ public abstract class AbstractGuiGame implements IGuiGame, IMayViewCards {
// Don't immediately close, wait for win/lose screen
return false;
}
else {
// since the nextGameDecision might come from somewhere else it will try and concede too
ignoreConcedeChain = true;
for (PlayerView player : getLocalPlayers()) {
if (!player.isAI()) {
getGameController(player).nextGameDecision(NextGameDecision.QUIT);
}
// since the nextGameDecision might come from somewhere else it will try and concede too
ignoreConcedeChain = true;
for (PlayerView player : getLocalPlayers()) {
if (!player.isAI()) {
getGameController(player).nextGameDecision(NextGameDecision.QUIT);
}
ignoreConcedeChain = false;
return false;
}
ignoreConcedeChain = false;
return false;
}
else if (spectator == null) {
return true; //if no local players or spectator, just quit

View File

@@ -28,21 +28,20 @@ public class CompatibleObjectDecoder extends LengthFieldBasedFrameDecoder {
ByteBuf frame = (ByteBuf)super.decode(ctx, in);
if (frame == null) {
return null;
} else {
ObjectInputStream ois = GuiBase.hasPropertyConfig() ?
new ObjectInputStream(new LZ4BlockInputStream(new ByteBufInputStream(frame, true))):
}
ObjectInputStream ois = GuiBase.hasPropertyConfig() ?
new ObjectInputStream(new LZ4BlockInputStream(new ByteBufInputStream(frame, true))):
new CObjectInputStream(new LZ4BlockInputStream(new ByteBufInputStream(frame, true)),this.classResolver);
Object var5 = null;
try {
var5 = ois.readObject();
} catch (StreamCorruptedException e) {
System.err.println(String.format("Version Mismatch: %s", e.getMessage()));
} finally {
ois.close();
}
return var5;
Object var5 = null;
try {
var5 = ois.readObject();
} catch (StreamCorruptedException e) {
System.err.println(String.format("Version Mismatch: %s", e.getMessage()));
} finally {
ois.close();
}
return var5;
}
}

View File

@@ -352,7 +352,7 @@ public class FControlGameEventHandler extends IGameEventVisitor.Base<Void> {
@Override
public Void visit(final GameEventCardAttachment event) {
final Game game = event.equipment.getGame();
final Zone zEq = (Zone)game.getZoneOf(event.equipment);
final Zone zEq = game.getZoneOf(event.equipment);
if (event.oldEntiy instanceof Card) {
updateZone(game.getZoneOf((Card)event.oldEntiy));
}

View File

@@ -393,14 +393,13 @@ public abstract class GuiDownloadService implements Runnable {
protected Proxy getProxy() {
if (type == 0) {
return Proxy.NO_PROXY;
} else {
try {
return new Proxy(TYPES[type], new InetSocketAddress(txtAddress.getText(), Integer.parseInt(txtPort.getText())));
} catch (final Exception ex) {
BugReporter.reportException(ex,
"Proxy connection could not be established!\nProxy address: %s\nProxy port: %s",
txtAddress.getText(), txtPort.getText());
}
}
try {
return new Proxy(TYPES[type], new InetSocketAddress(txtAddress.getText(), Integer.parseInt(txtPort.getText())));
} catch (final Exception ex) {
BugReporter.reportException(ex,
"Proxy connection could not be established!\nProxy address: %s\nProxy port: %s",
txtAddress.getText(), txtPort.getText());
}
return null;
}

View File

@@ -725,17 +725,15 @@ public class HumanPlay {
if (ability.getSacrificedAsOffering() == null) {
System.out.println("Sacrifice input for Offering cancelled");
return false;
} else {
offering = ability.getSacrificedAsOffering();
}
offering = ability.getSacrificedAsOffering();
}
if (ability.isEmerge()) {
if (ability.getSacrificedAsEmerge() == null) {
System.out.println("Sacrifice input for Emerge cancelled");
return false;
} else {
emerge = ability.getSacrificedAsEmerge();
}
emerge = ability.getSacrificedAsEmerge();
}
if (!toPay.isPaid()) {
// Input is somehow clearing out the offering card?

View File

@@ -694,12 +694,10 @@ public class PlayerControllerHuman extends PlayerController implements IGameCont
}
break;
}
if (sa != null) {
tempShowCard(show);
boolean result = InputConfirm.confirm(this, ((Card) sa.getHostCard().getFirstRemembered()).getView(), message);
endTempShowCards();
return result;
}
tempShowCard(show);
boolean result = InputConfirm.confirm(this, ((Card) sa.getHostCard().getFirstRemembered()).getView(), message);
endTempShowCards();
return result;
}
// The general case: display the source of the SA in the prompt on mouse over

View File

@@ -318,17 +318,15 @@ public class TargetSelection {
// Not enough targets, cancel targeting
return false;
}
else {
Object madeChoice = mandatory ? controller.getGui().one(message, selectOptions) : controller.getGui().oneOrNone(message, selectOptions);
if (madeChoice == null) {
return false;
}
if (madeChoice instanceof StackItemView) {
ability.getTargets().add(stackItemViewCache.get(madeChoice).getSpellAbility(true));
}
else {// 'FINISH TARGETING' chosen
bTargetingDone = true;
}
Object madeChoice = mandatory ? controller.getGui().one(message, selectOptions) : controller.getGui().oneOrNone(message, selectOptions);
if (madeChoice == null) {
return false;
}
if (madeChoice instanceof StackItemView) {
ability.getTargets().add(stackItemViewCache.get(madeChoice).getSpellAbility(true));
}
else {// 'FINISH TARGETING' chosen
bTargetingDone = true;
}
}
return true;