mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Some clean up changes.
This commit is contained in:
parent
5469facdd6
commit
5d94ed8dd0
43 changed files with 187 additions and 343 deletions
|
|
@ -82,9 +82,7 @@ class ChancellorEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
ability.setSourceId(source.getSourceId());
|
||||
ability.setControllerId(source.getControllerId());
|
||||
game.addDelayedTriggeredAbility(ability);
|
||||
game.addDelayedTriggeredAbility(ability, source);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,10 +29,7 @@ public class MistmeadowWitchEffect extends OneShotEffect {
|
|||
if (permanent.moveToExile(source.getSourceId(), "Mistmeadow Witch Exile", source.getSourceId(), game)) {
|
||||
//create delayed triggered ability
|
||||
AtTheBeginOfNextEndStepDelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(new ReturnFromExileEffect(source.getSourceId(), Zone.BATTLEFIELD));
|
||||
delayedAbility.setSourceId(source.getSourceId());
|
||||
delayedAbility.setControllerId(source.getControllerId());
|
||||
delayedAbility.setSourceObject(source.getSourceObject(game), game);
|
||||
game.addDelayedTriggeredAbility(delayedAbility);
|
||||
game.addDelayedTriggeredAbility(delayedAbility, source);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,26 +47,19 @@ import mage.util.CardUtil;
|
|||
*/
|
||||
public class ReturnToHandTargetEffect extends OneShotEffect {
|
||||
|
||||
boolean withName;
|
||||
protected boolean multitargetHandling;
|
||||
|
||||
public ReturnToHandTargetEffect() {
|
||||
this(true);
|
||||
this(false);
|
||||
}
|
||||
|
||||
public ReturnToHandTargetEffect(boolean withName) {
|
||||
this(withName, false);
|
||||
}
|
||||
|
||||
public ReturnToHandTargetEffect(boolean withName, boolean multitargetHandling) {
|
||||
public ReturnToHandTargetEffect(boolean multitargetHandling) {
|
||||
super(Outcome.ReturnToHand);
|
||||
this.withName = withName;
|
||||
this.multitargetHandling = multitargetHandling;
|
||||
}
|
||||
|
||||
public ReturnToHandTargetEffect(final ReturnToHandTargetEffect effect) {
|
||||
super(effect);
|
||||
this.withName = effect.withName;
|
||||
this.multitargetHandling = effect.multitargetHandling;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,7 @@
|
|||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
*/
|
||||
package mage.util;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
|
@ -53,12 +52,13 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
protected int modCount;
|
||||
protected int index;
|
||||
|
||||
public CircularList() {}
|
||||
public CircularList() {
|
||||
}
|
||||
|
||||
public CircularList(final CircularList<E> cList) {
|
||||
this.modCount = cList.modCount;
|
||||
for (E entry: cList.list) {
|
||||
this.list.add((E)entry);
|
||||
for (E entry : cList.list) {
|
||||
this.list.add((E) entry);
|
||||
}
|
||||
this.index = cList.index;
|
||||
}
|
||||
|
|
@ -68,7 +68,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Inserts an element into the current position
|
||||
* Inserts an element into the current position
|
||||
*
|
||||
* @param e
|
||||
* @return
|
||||
*/
|
||||
|
|
@ -84,14 +85,13 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
try {
|
||||
list.add(index, element);
|
||||
modCount++;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param e the element to set as current
|
||||
* @return true if element e exists and index was set
|
||||
*/
|
||||
|
|
@ -104,7 +104,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Retrieves the element at the current position
|
||||
* Retrieves the element at the current position
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public E get() {
|
||||
|
|
@ -117,9 +118,9 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the next element in the list. Will loop around to the beginning
|
||||
* Returns the next element in the list. Will loop around to the beginning
|
||||
* of the list if the current element is the last.
|
||||
*
|
||||
*
|
||||
* @return the next element in the list
|
||||
*/
|
||||
public E getNext() {
|
||||
|
|
@ -127,8 +128,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the previous element in the list. Will loop around to the end
|
||||
* of the list if the current element is the first.
|
||||
* Returns the previous element in the list. Will loop around to the end of
|
||||
* the list if the current element is the first.
|
||||
*
|
||||
* @return the previous element in the list
|
||||
*/
|
||||
|
|
@ -153,8 +154,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
checkPointer();
|
||||
modCount++;
|
||||
return ret;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -167,8 +167,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
checkPointer();
|
||||
modCount++;
|
||||
return ret;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -178,8 +177,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
try {
|
||||
index = incrementListPointer(index);
|
||||
return index;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -197,8 +195,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
try {
|
||||
index = decrementListPointer(index);
|
||||
return index;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -212,14 +209,13 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
}
|
||||
|
||||
/**
|
||||
* This method should only be called from a locked method
|
||||
* thus it is not necessary to lock from this method
|
||||
* This method should only be called from a locked method thus it is not
|
||||
* necessary to lock from this method
|
||||
*/
|
||||
private int checkPointer() {
|
||||
if (index > list.size()) {
|
||||
index = list.size() - 1;
|
||||
}
|
||||
else if (index < 0) {
|
||||
} else if (index < 0) {
|
||||
index = 0;
|
||||
}
|
||||
return index;
|
||||
|
|
@ -270,8 +266,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
try {
|
||||
modCount++;
|
||||
return list.addAll(index, c);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -284,8 +279,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
modCount++;
|
||||
checkPointer();
|
||||
return ret;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -298,8 +292,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
modCount++;
|
||||
checkPointer();
|
||||
return ret;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -311,8 +304,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
list.clear();
|
||||
modCount++;
|
||||
index = 0;
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -323,8 +315,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
try {
|
||||
modCount++;
|
||||
return list.set(index, element);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
|
@ -363,7 +354,7 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
return new CircularListIterator<>(index);
|
||||
}
|
||||
|
||||
private class CircularIterator<E> implements Iterator<E> {
|
||||
private class CircularIterator<E> implements Iterator<E> {
|
||||
|
||||
int cursor;
|
||||
int lastIndex;
|
||||
|
|
@ -405,7 +396,8 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
|
||||
}
|
||||
|
||||
private class CircularListIterator<E> implements ListIterator<E> {
|
||||
private class CircularListIterator<E> implements ListIterator<E> {
|
||||
|
||||
int cursor;
|
||||
int lastIndex;
|
||||
int firstIndex;
|
||||
|
|
@ -499,5 +491,4 @@ public class CircularList<E> implements List<E>, Iterable<E>, Serializable {
|
|||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,16 @@
|
|||
/*
|
||||
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||
*
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification, are
|
||||
* permitted provided that the following conditions are met:
|
||||
*
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||
* conditions and the following disclaimer.
|
||||
*
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||
|
|
@ -20,16 +20,15 @@
|
|||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* The views and conclusions contained in the software and documentation are those of the
|
||||
* authors and should not be interpreted as representing official policies, either expressed
|
||||
* or implied, of BetaSteward_at_googlemail.com.
|
||||
*/
|
||||
|
||||
package mage.watchers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
|
|
@ -40,12 +39,13 @@ import mage.game.events.GameEvent;
|
|||
*/
|
||||
public class Watchers extends HashMap<String, Watcher> {
|
||||
|
||||
public Watchers() {}
|
||||
public Watchers() {
|
||||
}
|
||||
|
||||
public Watchers(final Watchers watchers) {
|
||||
for (Map.Entry<String, Watcher> entry: watchers.entrySet()) {
|
||||
watchers.entrySet().stream().forEach((entry) -> {
|
||||
this.put(entry.getKey(), entry.getValue().copy());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Watchers copy() {
|
||||
|
|
@ -59,15 +59,16 @@ public class Watchers extends HashMap<String, Watcher> {
|
|||
}
|
||||
|
||||
public void watch(GameEvent event, Game game) {
|
||||
for (Watcher watcher: this.values()) {
|
||||
for (Iterator<Watcher> it = this.values().iterator(); it.hasNext();) {
|
||||
Watcher watcher = it.next();
|
||||
watcher.watch(event, game);
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
for (Watcher watcher: this.values()) {
|
||||
this.values().stream().forEach((watcher) -> {
|
||||
watcher.reset();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Watcher get(String key, UUID id) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue