Merge origin/master

This commit is contained in:
fireshoes 2015-09-15 09:36:20 -05:00
commit 04738515df
3 changed files with 88 additions and 20 deletions

View file

@ -30,13 +30,19 @@ package mage.sets.masterseditioniv;
import java.util.UUID;
import mage.ConditionalMana;
import mage.MageInt;
import mage.MageObject;
import mage.Mana;
import mage.abilities.Ability;
import mage.abilities.condition.Condition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.mana.ConditionalColorlessManaAbility;
import mage.abilities.mana.builder.ConditionalManaBuilder;
import mage.abilities.mana.conditional.ArtifactCastConditionalMana;
import mage.abilities.mana.conditional.ManaCondition;
import mage.cards.CardImpl;
import mage.constants.AbilityType;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.game.Game;
/**
*
@ -71,11 +77,39 @@ class SoldeviMachinistManaBuilder extends ConditionalManaBuilder {
@Override
public ConditionalMana build(Object... options) {
return new ArtifactCastConditionalMana(this.mana);
return new ArtifactAbilityConditionalMana(this.mana);
}
@Override
public String getRule() {
return "Spend this mana only to cast artifact spells";
return "Spend this mana only to activate abilities of artifacts";
}
}
class ArtifactAbilityConditionalMana extends ConditionalMana {
public ArtifactAbilityConditionalMana(Mana mana) {
super(mana);
staticText = "Spend this mana only to activate abilities of artifacts";
addCondition(new ArtifactAbilityManaCondition());
}
}
class ArtifactAbilityManaCondition extends ManaCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
if (source != null && source.getAbilityType().equals(AbilityType.ACTIVATED)) {
MageObject object = game.getObject(source.getSourceId());
if (object != null && object.getCardType().contains(CardType.ARTIFACT)) {
return true;
}
}
return false;
}
@Override
public boolean apply(Game game, Ability source, UUID originalId) {
return apply(game, source);
}
}

View file

@ -108,12 +108,12 @@ public class LookLibraryControllerEffect extends OneShotEffect {
if (source instanceof SpellAbility) {
Card sourceCard = game.getCard(source.getSourceId());
if (sourceCard != null) {
windowName = sourceCard.getName();
windowName = sourceCard.getIdName();
}
} else {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
windowName = sourcePermanent.getName();
windowName = sourcePermanent.getIdName();
}
}

View file

@ -851,28 +851,53 @@ public abstract class GameImpl implements Game, Serializable {
Player choosingPlayer = null;
if (choosingPlayerId != null) {
choosingPlayer = this.getPlayer(choosingPlayerId);
if (choosingPlayer != null && !choosingPlayer.isInGame()) {
choosingPlayer = null;
}
}
if (choosingPlayer == null) {
choosingPlayerId = pickChoosingPlayer();
if (choosingPlayerId == null) {
return;
}
choosingPlayer = getPlayer(choosingPlayerId);
}
if (choosingPlayer == null) {
return;
}
getState().setChoosingPlayerId(choosingPlayerId); // needed to start/stop the timer if active
if (choosingPlayer != null && choosingPlayer.choose(Outcome.Benefit, targetPlayer, null, this)) {
startingPlayerId = targetPlayer.getTargets().get(0);
Player startingPlayer = state.getPlayer(startingPlayerId);
StringBuilder message = new StringBuilder(choosingPlayer.getLogName()).append(" chooses that ");
if (choosingPlayer.getId().equals(startingPlayerId)) {
message.append("he or she");
} else {
message.append(startingPlayer.getLogName());
}
message.append(" takes the first turn");
this.informPlayers(message.toString());
} else {
// not possible to choose starting player, stop here
} else if (getState().getPlayers().size() < 3) {
// not possible to choose starting player, choosing player has probably conceded, so stop here
return;
}
if (startingPlayerId == null) {
// choose any available player as starting player
for (Player player : state.getPlayers().values()) {
if (player.isInGame()) {
startingPlayerId = player.getId();
break;
}
}
if (startingPlayerId == null) {
return;
}
}
Player startingPlayer = state.getPlayer(startingPlayerId);
if (startingPlayer == null) {
logger.debug("Starting player not found. playerId:" + startingPlayerId);
return;
}
StringBuilder message = new StringBuilder(choosingPlayer.getLogName()).append(" chooses that ");
if (choosingPlayer.getId().equals(startingPlayerId)) {
message.append("he or she");
} else {
message.append(startingPlayer.getLogName());
}
message.append(" takes the first turn");
this.informPlayers(message.toString());
//20091005 - 103.3
int startingHandSize = 7;
@ -980,6 +1005,7 @@ public abstract class GameImpl implements Game, Serializable {
}
}
}
}
protected UUID findWinnersAndLosers() {
@ -1014,9 +1040,17 @@ public abstract class GameImpl implements Game, Serializable {
protected UUID pickChoosingPlayer() {
UUID[] players = getPlayers().keySet().toArray(new UUID[0]);
UUID playerId = players[rnd.nextInt(players.length)];
fireInformEvent(state.getPlayer(playerId).getLogName() + " won the toss");
return playerId;
UUID playerId;
while (!hasEnded()) {
playerId = players[rnd.nextInt(players.length)];
Player player = getPlayer(playerId);
if (player != null && player.isInGame()) {
fireInformEvent(state.getPlayer(playerId).getLogName() + " won the toss");
return player.getId();
}
}
logger.debug("Game was not possible to pick a choosing player. GameId:" + getId());
return null;
}
@Override