Skip to content

Commit

Permalink
Merge branch 'magefree:master' into FDN-collation
Browse files Browse the repository at this point in the history
  • Loading branch information
tiera3 authored Dec 28, 2024
2 parents 4318373 + 6b9532f commit fced2ab
Show file tree
Hide file tree
Showing 15 changed files with 319 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -898,7 +898,7 @@ private void declareBlockers(Game game, UUID activePlayerId) {
return;
}

CombatUtil.sortByPower(attackers, false);
CombatUtil.sortByPower(attackers, false); // most powerfull go to first

CombatInfo combatInfo = CombatUtil.blockWithGoodTrade2(game, attackers, possibleBlockers);
Player player = game.getPlayer(playerId);
Expand All @@ -909,6 +909,7 @@ private void declareBlockers(Game game, UUID activePlayerId) {
List<Permanent> blockers = entry.getValue();
if (blockers != null) {
for (Permanent blocker : blockers) {
// TODO: buggy or miss on multi blocker requirements?!
player.declareBlocker(player.getId(), blocker.getId(), attackerId, game);
blocked = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static List<Permanent> canKillOpponent(Game game, List<Permanent> attacke
}
}

sortByPower(blockableAttackers, true);
sortByPower(blockableAttackers, false); // most powerfull go to first

// imagine that most powerful will be blocked as 1-vs-1
List<Permanent> attackersThatWontBeBlocked = new ArrayList<>(blockableAttackers);
Expand Down Expand Up @@ -83,28 +83,17 @@ public static boolean canBeBlocked(Game game, Permanent attacker, List<Permanent
}

public static void sortByPower(List<Permanent> permanents, final boolean ascending) {
Collections.sort(permanents, new Comparator<Permanent>() {
@Override
public int compare(Permanent o1, Permanent o2) {
if (ascending) {
return o2.getPower().getValue() - o1.getPower().getValue();
} else {
return o1.getPower().getValue() - o2.getPower().getValue();
}
}
});
permanents.sort(Comparator.comparingInt(p -> p.getPower().getValue()));
if (!ascending) {
Collections.reverse(permanents);
}
}

public static Permanent getWorstCreature(List<Permanent> creatures) {
if (creatures.isEmpty()) {
return null;
}
Collections.sort(creatures, new Comparator<Permanent>() {
@Override
public int compare(Permanent o1, Permanent o2) {
return o2.getPower().getValue() - o1.getPower().getValue();
}
});
creatures.sort(Comparator.comparingInt(p -> p.getPower().getValue()));
return creatures.get(0);
}

Expand Down
2 changes: 1 addition & 1 deletion Mage.Sets/src/mage/cards/b/BeckoningWillOWisp.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ enum BeckoningWillOWispPredicate implements ObjectSourcePlayerPredicate<Permanen
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
UUID playerId = (UUID) game.getState().getValue(input.getSourceId() + "_" + game.getState().getZoneChangeCounter(input.getSourceId()) + "_chosenOpponent");
return playerId != null && playerId.equals(game.getCombat().getDefendingPlayerId(input.getObject().getId(), game));
return playerId != null && playerId.equals(game.getCombat().getDefendingPlayerId(input.getObject().getId(), game, false));
}
}

Expand Down
21 changes: 10 additions & 11 deletions Mage.Sets/src/mage/cards/d/DefiantVanguard.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package mage.cards.d;

import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility;
Expand All @@ -16,11 +15,7 @@
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.ComparisonType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.common.FilterPermanentCard;
import mage.filter.predicate.mageobject.ManaValuePredicate;
import mage.game.Game;
Expand All @@ -29,14 +24,18 @@
import mage.target.common.TargetCardInLibrary;
import mage.target.targetpointer.FixedTarget;

import java.util.UUID;

/**
*
* @author bunchOfDevs
*/
public final class DefiantVanguard extends CardImpl {

protected static final String EFFECT_KEY = "DefiantVanguardEffect_";

private static final FilterPermanentCard filter = new FilterPermanentCard("Rebel permanent card with mana value 4 or less");


static {
filter.add(SubType.REBEL.getPredicate());
filter.add(new ManaValuePredicate(ComparisonType.FEWER_THAN, 5));
Expand Down Expand Up @@ -100,8 +99,8 @@ public boolean checkTrigger(GameEvent event, Game game) {
Permanent blocked = game.getPermanent(event.getTargetId());
if (blocker != null
&& blocked != null) {
game.getState().setValue(blocked.toString(), blocked.getZoneChangeCounter(game)); // in case the attacker changes zone
game.getState().setValue(blocker.toString(), blocker.getZoneChangeCounter(game)); // in case the blocker changes zone
game.getState().setValue(DefiantVanguard.EFFECT_KEY + blocked.getId(), blocked.getZoneChangeCounter(game)); // in case the attacker changes zone
game.getState().setValue(DefiantVanguard.EFFECT_KEY + blocker.getId(), blocker.getZoneChangeCounter(game)); // in case the blocker changes zone
getAllEffects().setTargetPointer(new FixedTarget(blocked.getId()));
return true;
}
Expand Down Expand Up @@ -131,13 +130,13 @@ public boolean apply(Game game, Ability source) {
Permanent blockedCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
Permanent defiantVanguard = game.getPermanent(source.getSourceId());
if (blockedCreature != null) {
if (game.getState().getValue(blockedCreature.toString()).equals(blockedCreature.getZoneChangeCounter(game))) { // true if it did not change zones
if (game.getState().getValue(DefiantVanguard.EFFECT_KEY + blockedCreature.getId()).equals(blockedCreature.getZoneChangeCounter(game))) { // true if it did not change zones
blockedCreature.destroy(source, game, false);
result = true;
}
}
if (defiantVanguard != null) {
if (game.getState().getValue(defiantVanguard.toString()).equals(defiantVanguard.getZoneChangeCounter(game))) { // true if it did not change zones
if (game.getState().getValue(DefiantVanguard.EFFECT_KEY + defiantVanguard.getId()).equals(defiantVanguard.getZoneChangeCounter(game))) { // true if it did not change zones
defiantVanguard.destroy(source, game, false);
result = true;
}
Expand Down
1 change: 0 additions & 1 deletion Mage.Sets/src/mage/cards/o/OgreMarauder.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;

/**
*
Expand Down
6 changes: 3 additions & 3 deletions Mage.Sets/src/mage/cards/s/SharaeOfNumbingDepths.java
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public boolean checkEventType(GameEvent event, Game game) {
public boolean checkTrigger(GameEvent event, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
return permanent != null
&& StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE.match(permanent, game)
&& isControlledBy(event.getPlayerId());
&& isControlledBy(event.getPlayerId()) // whenever you tap
&& StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE.match(permanent, this.getControllerId(), this, game);
}
}
}
1 change: 0 additions & 1 deletion Mage.Sets/src/mage/cards/s/SkymarkRoc.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.target.common.TargetCreaturePermanent;

/**
Expand Down
3 changes: 1 addition & 2 deletions Mage.Sets/src/mage/cards/u/UlamogTheCeaselessHunger.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.game.stack.Spell;
import mage.players.Player;
Expand Down Expand Up @@ -113,7 +112,7 @@ public boolean checkEventType(GameEvent event, Game game) {

@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent sourcePermanent = game.getPermanent(this.getSourceId());
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(this.getSourceId());
if (sourcePermanent != null
&& event.getSourceId() != null
&& event.getSourceId().equals(this.getSourceId())) {
Expand Down
3 changes: 1 addition & 2 deletions Mage.Sets/src/mage/cards/w/WardscaleDragon.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
Expand Down Expand Up @@ -73,7 +72,7 @@ public boolean checksEventType(GameEvent event, Game game) {
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && sourcePermanent.isAttacking()) {
return event.getPlayerId().equals(game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game));
return event.getPlayerId().equals(game.getCombat().getDefendingPlayerId(sourcePermanent.getId(), game, false));
}
return false;
}
Expand Down
3 changes: 3 additions & 0 deletions Mage.Sets/src/mage/cards/z/ZurgoAndOjutai.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public boolean checkEventType(GameEvent event, Game game) {

@Override
public boolean checkEvent(DamagedEvent event, Game game) {
if (!event.isCombatDamage()) {
return false;
}
Permanent permanent = game.getPermanent(event.getSourceId());
Permanent defender = game.getPermanent(event.getTargetId());
return permanent != null
Expand Down
Loading

0 comments on commit fced2ab

Please sign in to comment.