mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
fix couple of sonar issues
This commit is contained in:
parent
41357c15ff
commit
1cf6d99515
5 changed files with 21 additions and 30 deletions
|
@ -40,7 +40,7 @@ public enum TableManager {
|
|||
|
||||
// protected static ScheduledExecutorService expireExecutor = ThreadExecutor.getInstance().getExpireExecutor();
|
||||
private final Logger logger = Logger.getLogger(TableManager.class);
|
||||
private static final DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||
private final DateFormat formatter = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
private final ConcurrentHashMap<UUID, TableController> controllers = new ConcurrentHashMap<>();
|
||||
private final ReadWriteLock controllersLock = new ReentrantReadWriteLock();
|
||||
|
|
|
@ -50,13 +50,13 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
|
||||
// checks for compatibility
|
||||
EffectType needType = EffectType.CONTINUOUS;
|
||||
if (effect != null && !effect.getEffectType().equals(needType)) {
|
||||
if (effect.getEffectType() != needType) {
|
||||
Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
|
||||
}
|
||||
if (otherwiseEffect != null && !otherwiseEffect.getEffectType().equals(needType)) {
|
||||
if (otherwiseEffect != null && otherwiseEffect.getEffectType() != needType) {
|
||||
Assert.fail("ConditionalContinuousEffect supports only " + needType.toString() + " but found " + effect.getEffectType().toString());
|
||||
}
|
||||
if (effect != null && otherwiseEffect != null && !effect.getEffectType().equals(otherwiseEffect.getEffectType())) {
|
||||
if (otherwiseEffect != null && effect.getEffectType() != otherwiseEffect.getEffectType()) {
|
||||
Assert.fail("ConditionalContinuousEffect must be same but found " + effect.getEffectType().toString() + " and " + otherwiseEffect.getEffectType().toString());
|
||||
}
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
if (condition == null && baseCondition != null) {
|
||||
condition = baseCondition;
|
||||
}
|
||||
boolean conditionState = condition.apply(game, source);
|
||||
boolean conditionState = condition != null && condition.apply(game, source);
|
||||
if (conditionState) {
|
||||
effect.setTargetPointer(this.targetPointer);
|
||||
return effect.apply(game, source);
|
||||
|
@ -127,10 +127,10 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
otherwiseEffect.setTargetPointer(this.targetPointer);
|
||||
return otherwiseEffect.apply(game, source);
|
||||
}
|
||||
if (!conditionState && effect.getDuration() == Duration.OneUse) {
|
||||
if (effect.getDuration() == Duration.OneUse) {
|
||||
used = true;
|
||||
}
|
||||
if (!conditionState && effect.getDuration() == Duration.Custom) {
|
||||
if (effect.getDuration() == Duration.Custom) {
|
||||
this.discard();
|
||||
}
|
||||
return false;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package mage.abilities.effects.common;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.Mode;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
|
@ -9,8 +8,9 @@ import mage.constants.Outcome;
|
|||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class FightTargetsEffect extends OneShotEffect {
|
||||
|
@ -57,27 +57,23 @@ public class FightTargetsEffect extends OneShotEffect {
|
|||
return creature1.fight(creature2, source, game);
|
||||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(card.getName() + " has been fizzled.");
|
||||
}
|
||||
}
|
||||
if (!game.isSimulation()) {
|
||||
game.informPlayers(card.getName() + " has been fizzled.");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FightTargetsEffect
|
||||
copy() {
|
||||
public FightTargetsEffect copy() {
|
||||
return new FightTargetsEffect(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String
|
||||
getText(Mode mode
|
||||
) {
|
||||
if (staticText
|
||||
!= null && !staticText
|
||||
.isEmpty()) {
|
||||
public String getText(Mode mode) {
|
||||
if (staticText != null && !staticText.isEmpty()) {
|
||||
return staticText;
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@ import mage.game.permanent.Permanent;
|
|||
import org.apache.log4j.Logger;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class LoseAbilityAttachedEffect extends ContinuousEffectImpl {
|
||||
|
@ -47,7 +46,7 @@ public class LoseAbilityAttachedEffect extends ContinuousEffectImpl {
|
|||
while (creature.getAbilities().contains(ability)) {
|
||||
if (!creature.getAbilities().remove(ability)) {
|
||||
// Something went wrong - ability has an other id?
|
||||
logger.warn("ability" + ability.getRule() + "couldn't be removed.");
|
||||
logger.warn("ability" + ability.getRule() + "couldn't be removed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,11 +58,7 @@ public class LoseAbilityAttachedEffect extends ContinuousEffectImpl {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(attachmentType.verb());
|
||||
sb.append(" creature ");
|
||||
if (duration == Duration.WhileOnBattlefield) {
|
||||
sb.append("loses ");
|
||||
} else {
|
||||
sb.append("loses ");
|
||||
}
|
||||
sb.append("loses ");
|
||||
sb.append(ability.getRule());
|
||||
staticText = sb.toString();
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ public class TurnMods extends ArrayList<TurnMod> {
|
|||
ListIterator<TurnMod> it = this.listIterator(this.size());
|
||||
while (it.hasPrevious()) {
|
||||
TurnMod turnMod = it.previous();
|
||||
if (turnMod.getExtraPhase() != null && turnMod.getPlayerId().equals(playerId) && turnMod.getExtraPhase() != null && (turnMod.getAfterPhase() == null || turnMod.getAfterPhase() == afterPhase)) {
|
||||
if (turnMod.getExtraPhase() != null && turnMod.getPlayerId().equals(playerId) && (turnMod.getAfterPhase() == null || turnMod.getAfterPhase() == afterPhase)) {
|
||||
it.remove();
|
||||
return turnMod;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue