forked from External/mage
Update *.sh and *.java files to use Unix line endings
This commit is contained in:
parent
a6d03c925f
commit
9c7982e8f6
273 changed files with 26704 additions and 26704 deletions
|
|
@ -1,104 +1,104 @@
|
|||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public class MeleeAbility extends AttacksTriggeredAbility {
|
||||
|
||||
public MeleeAbility() {
|
||||
super(new BoostSourceEffect(new MeleeDynamicValue(), new MeleeDynamicValue(), Duration.EndOfTurn), false);
|
||||
this.addWatcher(new MeleeWatcher());
|
||||
}
|
||||
|
||||
public MeleeAbility(final MeleeAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MeleeAbility copy() {
|
||||
return new MeleeAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "melee <i>(Whenever this creature attacks, it gets +1/+1 until end of turn for each opponent you attacked this combat.)</i>";
|
||||
}
|
||||
}
|
||||
|
||||
class MeleeWatcher extends Watcher {
|
||||
|
||||
private Map<UUID, Set<UUID>> playersAttacked = new HashMap<>(0);
|
||||
|
||||
public MeleeWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.BEGIN_COMBAT_STEP_PRE) {
|
||||
this.playersAttacked.clear();
|
||||
}
|
||||
else if (event.getType() == EventType.ATTACKER_DECLARED) {
|
||||
Set<UUID> attackedPlayers = this.playersAttacked.getOrDefault(event.getPlayerId(), new HashSet<>(1));
|
||||
attackedPlayers.add(event.getTargetId());
|
||||
this.playersAttacked.put(event.getPlayerId(), attackedPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberOfAttackedPlayers(UUID attackerId) {
|
||||
if (this.playersAttacked.get(attackerId) != null) {
|
||||
return this.playersAttacked.get(attackerId).size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class MeleeDynamicValue implements DynamicValue {
|
||||
|
||||
private boolean valueChecked = false;
|
||||
private int lockedInValue;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
MeleeWatcher watcher = game.getState().getWatcher(MeleeWatcher.class);
|
||||
if (watcher != null) {
|
||||
if (!valueChecked) {
|
||||
this.lockedInValue = watcher.getNumberOfAttackedPlayers(sourceAbility.getControllerId());
|
||||
valueChecked = true;
|
||||
}
|
||||
return this.lockedInValue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MeleeDynamicValue copy() {
|
||||
return new MeleeDynamicValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "number of opponents you attacked this combat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
}
|
||||
|
||||
package mage.abilities.keyword;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.AttacksTriggeredAbility;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.continuous.BoostSourceEffect;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public class MeleeAbility extends AttacksTriggeredAbility {
|
||||
|
||||
public MeleeAbility() {
|
||||
super(new BoostSourceEffect(new MeleeDynamicValue(), new MeleeDynamicValue(), Duration.EndOfTurn), false);
|
||||
this.addWatcher(new MeleeWatcher());
|
||||
}
|
||||
|
||||
public MeleeAbility(final MeleeAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MeleeAbility copy() {
|
||||
return new MeleeAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "melee <i>(Whenever this creature attacks, it gets +1/+1 until end of turn for each opponent you attacked this combat.)</i>";
|
||||
}
|
||||
}
|
||||
|
||||
class MeleeWatcher extends Watcher {
|
||||
|
||||
private Map<UUID, Set<UUID>> playersAttacked = new HashMap<>(0);
|
||||
|
||||
public MeleeWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.BEGIN_COMBAT_STEP_PRE) {
|
||||
this.playersAttacked.clear();
|
||||
}
|
||||
else if (event.getType() == EventType.ATTACKER_DECLARED) {
|
||||
Set<UUID> attackedPlayers = this.playersAttacked.getOrDefault(event.getPlayerId(), new HashSet<>(1));
|
||||
attackedPlayers.add(event.getTargetId());
|
||||
this.playersAttacked.put(event.getPlayerId(), attackedPlayers);
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumberOfAttackedPlayers(UUID attackerId) {
|
||||
if (this.playersAttacked.get(attackerId) != null) {
|
||||
return this.playersAttacked.get(attackerId).size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
class MeleeDynamicValue implements DynamicValue {
|
||||
|
||||
private boolean valueChecked = false;
|
||||
private int lockedInValue;
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
MeleeWatcher watcher = game.getState().getWatcher(MeleeWatcher.class);
|
||||
if (watcher != null) {
|
||||
if (!valueChecked) {
|
||||
this.lockedInValue = watcher.getNumberOfAttackedPlayers(sourceAbility.getControllerId());
|
||||
valueChecked = true;
|
||||
}
|
||||
return this.lockedInValue;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MeleeDynamicValue copy() {
|
||||
return new MeleeDynamicValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "number of opponents you attacked this combat";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue