mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 05:22:02 -08:00
* Replicate abilities - fixed that AI can freeze the game after play card with replicate (AI don't use it now);
This commit is contained in:
parent
a249dcffd8
commit
1ae9fc883e
4 changed files with 74 additions and 23 deletions
|
|
@ -1,12 +1,12 @@
|
|||
|
||||
package mage.abilities.costs;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.game.Game;
|
||||
import mage.target.Targets;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Cost extends Serializable {
|
||||
|
||||
UUID getId();
|
||||
|
|
@ -15,6 +15,10 @@ public interface Cost extends Serializable {
|
|||
|
||||
void setText(String text);
|
||||
|
||||
/**
|
||||
* Check is it possible to pay
|
||||
* For mana it checks only single color and amount available, not total mana cost
|
||||
*/
|
||||
boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game);
|
||||
|
||||
boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.abilities.costs;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
|
|
@ -6,7 +5,7 @@ import mage.game.Game;
|
|||
|
||||
/**
|
||||
* Interface for abilities that add additional costs to the source.
|
||||
*
|
||||
* <p>
|
||||
* Example of such additional source costs:
|
||||
* {@link mage.abilities.keyword.KickerAbility}
|
||||
*
|
||||
|
|
@ -14,6 +13,7 @@ import mage.game.Game;
|
|||
*/
|
||||
public interface OptionalAdditionalSourceCosts {
|
||||
|
||||
// TODO: add AI support to use buyback, replicate and other additional costs (current version can't calc available mana before buyback use)
|
||||
void addOptionalAdditionalCosts(Ability ability, Game game);
|
||||
|
||||
String getCastMessageSuffix();
|
||||
|
|
|
|||
|
|
@ -88,8 +88,12 @@ public class ReplicateAbility extends StaticAbility implements OptionalAdditiona
|
|||
int numActivations = additionalCost.getActivateCount();
|
||||
times = (numActivations + 1) + (numActivations == 0 ? " time " : " times ");
|
||||
}
|
||||
|
||||
// test costs
|
||||
// TODO: add AI support to find max number of possible activations (from available mana)
|
||||
// canPay checks only single mana available, not total mana usage
|
||||
if (additionalCost.canPay(ability, sourceId, controllerId, game)
|
||||
&& player.chooseUse(Outcome.Benefit, new StringBuilder("Pay ").append(times).append(additionalCost.getText(false)).append(" ?").toString(), ability, game)) {
|
||||
&& player.chooseUse(/*Outcome.Benefit*/Outcome.AIDontUseIt, new StringBuilder("Pay ").append(times).append(additionalCost.getText(false)).append(" ?").toString(), ability, game)) {
|
||||
additionalCost.activate();
|
||||
for (Iterator it = ((Costs) additionalCost).iterator(); it.hasNext(); ) {
|
||||
Cost cost = (Cost) it.next();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue