mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
* Mana Clash - Fixed use in available mana calculation (related to #6698).
This commit is contained in:
parent
674fd6b1a5
commit
6a65e5bb23
6 changed files with 61 additions and 15 deletions
|
|
@ -90,6 +90,7 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
|
|||
*
|
||||
* @param zone The {@link Zone} to search for
|
||||
* {@link ActivatedManaAbilityImpl mana abilities}.
|
||||
* @param playerId The id of the player to check availability for
|
||||
* @return All {@link ActivatedManaAbilityImpl mana abilities} for the given
|
||||
* {@link Zone} that can be used.
|
||||
*
|
||||
|
|
@ -97,7 +98,7 @@ public interface Abilities<T extends Ability> extends List<T>, Serializable {
|
|||
* @see mage.players.PlayerImpl#getManaAvailable(mage.game.Game)
|
||||
* @see mage.players.PlayerImpl#getAvailableManaProducers(mage.game.Game)
|
||||
*/
|
||||
Abilities<ActivatedManaAbilityImpl> getAvailableActivatedManaAbilities(Zone zone, Game game);
|
||||
Abilities<ActivatedManaAbilityImpl> getAvailableActivatedManaAbilities(Zone zone, UUID playerId, Game game);
|
||||
|
||||
/**
|
||||
* Retrieves all {@link StaticAbility static abilities} in the given
|
||||
|
|
|
|||
|
|
@ -131,11 +131,11 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
|
|||
}
|
||||
|
||||
@Override
|
||||
public Abilities<ActivatedManaAbilityImpl> getAvailableActivatedManaAbilities(Zone zone, Game game) {
|
||||
public Abilities<ActivatedManaAbilityImpl> getAvailableActivatedManaAbilities(Zone zone, UUID playerId, Game game) {
|
||||
return stream()
|
||||
.filter(ability -> ability instanceof ActivatedManaAbilityImpl)
|
||||
.filter(ability -> ability.getZone().match(zone))
|
||||
.filter(ability -> (((ActivatedManaAbilityImpl) ability).canActivate(ability.getControllerId(), game).canActivate()))
|
||||
.filter(ability -> (((ActivatedManaAbilityImpl) ability).canActivate(playerId, game).canActivate()))
|
||||
.map(ability -> (ActivatedManaAbilityImpl) ability)
|
||||
.collect(Collectors.toCollection(AbilitiesImpl::new));
|
||||
|
||||
|
|
|
|||
|
|
@ -2891,18 +2891,18 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
|
||||
List<Abilities<ActivatedManaAbilityImpl>> sourceWithoutManaCosts = new ArrayList<>();
|
||||
List<Abilities<ActivatedManaAbilityImpl>> sourceWithCosts = new ArrayList<>();
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(playerId, game)) { // Some permanents allow use of abilities from non controlling players. so check all permanents in range
|
||||
Boolean canUse = null;
|
||||
boolean canAdd = false;
|
||||
boolean withCost = false;
|
||||
Abilities<ActivatedManaAbilityImpl> manaAbilities
|
||||
= permanent.getAbilities().getAvailableActivatedManaAbilities(Zone.BATTLEFIELD, game);
|
||||
= permanent.getAbilities().getAvailableActivatedManaAbilities(Zone.BATTLEFIELD, playerId, game); // returns ability only if canActivate is true
|
||||
for (Iterator<ActivatedManaAbilityImpl> it = manaAbilities.iterator(); it.hasNext();) {
|
||||
ActivatedManaAbilityImpl ability = it.next();
|
||||
if (canUse == null) {
|
||||
canUse = permanent.canUseActivatedAbilities(game);
|
||||
}
|
||||
if (canUse && ability.canActivate(playerId, game).canActivate()) {
|
||||
if (canUse) {
|
||||
// abilities without Tap costs have to be handled as separate sources, because they can be used also
|
||||
if (!ability.hasTapCost()) {
|
||||
it.remove();
|
||||
|
|
@ -2985,7 +2985,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// returns only mana producers that don't require mana payment
|
||||
protected List<MageObject> getAvailableManaProducers(Game game) {
|
||||
List<MageObject> result = new ArrayList<>();
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(playerId, game)) { // Some permanents allow use of abilities from non controlling players. so check all permanents in range
|
||||
Boolean canUse = null;
|
||||
boolean canAdd = false;
|
||||
for (ActivatedManaAbilityImpl ability : permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) {
|
||||
|
|
@ -3025,7 +3025,7 @@ public abstract class PlayerImpl implements Player, Serializable {
|
|||
// returns only mana producers that require mana payment
|
||||
public List<Permanent> getAvailableManaProducersWithCost(Game game) {
|
||||
List<Permanent> result = new ArrayList<>();
|
||||
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(playerId)) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(playerId, game)) {
|
||||
Boolean canUse = null;
|
||||
for (ActivatedManaAbilityImpl ability : permanent.getAbilities().getActivatedManaAbilities(Zone.BATTLEFIELD)) {
|
||||
if (canUse == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue