mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 12:48:00 +00:00
Add Expend and Teapot Slinger (#5731)
* Add Expend and Teapot Slinger * Fixes --------- Co-authored-by: tool4EvEr <tool4EvEr@192.168.0.60>
This commit is contained in:
@@ -194,6 +194,7 @@ public class GameSnapshot {
|
||||
newPlayer.setLibrarySearched(origPlayer.getLibrarySearched());
|
||||
newPlayer.setSpellsCastLastTurn(origPlayer.getSpellsCastLastTurn());
|
||||
newPlayer.setCommitedCrimeThisTurn(origPlayer.getCommittedCrimeThisTurn());
|
||||
newPlayer.setExpentThisTurn(origPlayer.getExpentThisTurn());
|
||||
for (int j = 0; j < origPlayer.getSpellsCastThisTurn(); j++) {
|
||||
newPlayer.addSpellCastThisTurn();
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
private int lifeGainedTimesThisTurn;
|
||||
private int lifeGainedByTeamThisTurn;
|
||||
private int committedCrimeThisTurn;
|
||||
private int expentThisTurn;
|
||||
private int numManaShards;
|
||||
private int numPowerSurgeLands;
|
||||
private int numLibrarySearchedOwn; //The number of times this player has searched his library
|
||||
@@ -2557,6 +2558,7 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
setNumManaConversion(0);
|
||||
|
||||
setCommitedCrimeThisTurn(0);
|
||||
setExpentThisTurn(0);
|
||||
|
||||
damageReceivedThisTurn.clear();
|
||||
planeswalkedToThisTurn.clear();
|
||||
@@ -3864,6 +3866,13 @@ public class Player extends GameEntity implements Comparable<Player> {
|
||||
committedCrimeThisTurn = v;
|
||||
}
|
||||
|
||||
public int getExpentThisTurn() {
|
||||
return expentThisTurn;
|
||||
}
|
||||
public void setExpentThisTurn(int v) {
|
||||
expentThisTurn = v;
|
||||
}
|
||||
|
||||
public void visitAttractions(int light) {
|
||||
CardCollection attractions = CardLists.filter(getCardsIn(ZoneType.Battlefield), CardPredicates.isAttractionWithLight(light));
|
||||
for (Card c : attractions) {
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.game.trigger;
|
||||
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* TriggerManaExpend class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class TriggerManaExpend extends Trigger {
|
||||
public TriggerManaExpend(final Map<String, String> params, final Card host, final boolean intrinsic) {
|
||||
super(params, host, intrinsic);
|
||||
}
|
||||
|
||||
/** {@inheritDoc}
|
||||
* @param runParams*/
|
||||
@Override
|
||||
public final boolean performTest(final Map<AbilityKey, Object> runParams) {
|
||||
if (!matchesValidParam("Player", runParams.get(AbilityKey.Player))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int targetAmount = Integer.parseInt(mapParams.get("Amount"));
|
||||
int actualAmount = (int) runParams.get(AbilityKey.Amount);
|
||||
return targetAmount == actualAmount;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void setTriggeringObjects(final SpellAbility sa, Map<AbilityKey, Object> runParams) {
|
||||
sa.setTriggeringObjectsFrom(runParams, AbilityKey.Amount, AbilityKey.Player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getImportantStackObjects(SpellAbility sa) {
|
||||
return sa.getTriggeringObject(AbilityKey.Player) + " expended " + sa.getTriggeringObject(AbilityKey.Amount) + " mana";
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package forge.game.trigger;
|
||||
|
||||
import forge.game.card.Card;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Map;
|
||||
|
||||
import forge.game.card.Card;
|
||||
|
||||
|
||||
/**
|
||||
* TODO: Write javadoc for this type.
|
||||
@@ -95,6 +95,7 @@ public enum TriggerType {
|
||||
LifeLostAll(TriggerLifeLostAll.class),
|
||||
LosesGame(TriggerLosesGame.class),
|
||||
ManaAdded(TriggerManaAdded.class),
|
||||
ManaExpend(TriggerManaExpend.class),
|
||||
Mentored(TriggerMentored.class),
|
||||
Milled(TriggerMilled.class),
|
||||
MilledOnce(TriggerMilledOnce.class),
|
||||
|
||||
@@ -353,6 +353,35 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
runParams.put(AbilityKey.CardLKI, lki);
|
||||
thisTurnCast.add(lki);
|
||||
sp.getActivatingPlayer().addSpellCastThisTurn();
|
||||
|
||||
// Add expend mana
|
||||
Map<Player, Integer> expendPlayers = Maps.newHashMap();
|
||||
|
||||
for (Mana m : sp.getPayingMana()) {
|
||||
// TODO this currently assumes that all mana came from your own pool
|
||||
// but with Assist some might belong to another player instead
|
||||
Player manaPayer = sp.getActivatingPlayer();
|
||||
|
||||
expendPlayers.put(manaPayer, expendPlayers.getOrDefault(manaPayer, 0) + 1);
|
||||
}
|
||||
|
||||
for (Entry<Player, Integer> entry : expendPlayers.entrySet()) {
|
||||
Player manaPayer = entry.getKey();
|
||||
int startingMana = manaPayer.getExpentThisTurn();
|
||||
int totalMana = startingMana + entry.getValue();
|
||||
|
||||
if (totalMana == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
manaPayer.setExpentThisTurn(totalMana);
|
||||
for(int i = startingMana + 1; i <= totalMana; i++) {
|
||||
Map<AbilityKey, Object> expendParams = AbilityKey.mapFromPlayer(manaPayer);
|
||||
expendParams.put(AbilityKey.SpellAbility, sp);
|
||||
expendParams.put(AbilityKey.Amount, i);
|
||||
game.getTriggerHandler().runTrigger(TriggerType.ManaExpend, expendParams, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
runParams.put(AbilityKey.Cost, sp.getPayCosts());
|
||||
|
||||
Reference in New Issue
Block a user