* Balancing Act and Restore Balance - Fixed that range of players was ignored (cbt33).

This commit is contained in:
LevelX2 2013-09-20 11:18:38 +02:00
parent 44a81f8162
commit fdca147d4d
2 changed files with 118 additions and 108 deletions

View file

@ -57,8 +57,8 @@ public class BalancingAct extends CardImpl<BalancingAct> {
this.color.setWhite(true); this.color.setWhite(true);
this.getSpellAbility().addEffect(new BalancingActEffect());
// Each player chooses a number of permanents he or she controls equal to the number of permanents controlled by the player who controls the fewest, then sacrifices the rest. Each player discards cards the same way. // Each player chooses a number of permanents he or she controls equal to the number of permanents controlled by the player who controls the fewest, then sacrifices the rest. Each player discards cards the same way.
this.getSpellAbility().addEffect(new BalancingActEffect());
} }
public BalancingAct(final BalancingAct card) { public BalancingAct(final BalancingAct card) {
@ -76,6 +76,7 @@ class BalancingActEffect extends OneShotEffect<BalancingActEffect> {
public BalancingActEffect() { public BalancingActEffect() {
super(Outcome.Sacrifice); super(Outcome.Sacrifice);
staticText = "Each player chooses a number of lands he or she controls equal to the number of lands controlled by the player who controls the fewest, then sacrifices the rest. Players sacrifice creatures and discard cards the same way";
} }
public BalancingActEffect(final mage.sets.odyssey.BalancingActEffect effect) { public BalancingActEffect(final mage.sets.odyssey.BalancingActEffect effect) {
@ -89,9 +90,12 @@ class BalancingActEffect extends OneShotEffect<BalancingActEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int minPermanent = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE; int minPermanent = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE;
//PERMANENTS // count minimal permanets
for(Player player : game.getPlayers().values()){ for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
int count = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getId(), game).size(); int count = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getId(), game).size();
if(count < minPermanent){ if(count < minPermanent){
@ -99,8 +103,9 @@ class BalancingActEffect extends OneShotEffect<BalancingActEffect> {
} }
} }
} }
// sacrifice permanents over the minimum
for(Player player : game.getPlayers().values()){ for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
TargetControlledPermanent target = new TargetControlledPermanent(minPermanent, minPermanent, new FilterControlledPermanent(), true); TargetControlledPermanent target = new TargetControlledPermanent(minPermanent, minPermanent, new FilterControlledPermanent(), true);
target.setRequired(true); target.setRequired(true);
@ -114,11 +119,9 @@ class BalancingActEffect extends OneShotEffect<BalancingActEffect> {
} }
} }
// count minimal cards in hand
for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
//CARD IN HAND
for(Player player : game.getPlayers().values()){
if(player != null){ if(player != null){
int count = player.getHand().size(); int count = player.getHand().size();
if(count < minCard){ if(count < minCard){
@ -127,7 +130,9 @@ class BalancingActEffect extends OneShotEffect<BalancingActEffect> {
} }
} }
for(Player player : game.getPlayers().values()){ // discard cards over the minimum
for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard()); TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard());
target.setRequired(true); target.setRequired(true);
@ -145,9 +150,7 @@ class BalancingActEffect extends OneShotEffect<BalancingActEffect> {
return true; return true;
} }
return false;
@Override
public String getText(Mode mode) {
return "Each player chooses a number of lands he or she controls equal to the number of lands controlled by the player who controls the fewest, then sacrifices the rest. Players sacrifice creatures and discard cards the same way";
} }
} }

View file

@ -81,6 +81,7 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
public RestoreBalanceEffect() { public RestoreBalanceEffect() {
super(Outcome.Sacrifice); super(Outcome.Sacrifice);
staticText = "Each player chooses a number of lands he or she controls equal to the number of lands controlled by the player who controls the fewest, then sacrifices the rest. Players sacrifice creatures and discard cards the same way";
} }
public RestoreBalanceEffect(final RestoreBalanceEffect effect) { public RestoreBalanceEffect(final RestoreBalanceEffect effect) {
@ -94,9 +95,12 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int minLand = Integer.MAX_VALUE, minCreature = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE; int minLand = Integer.MAX_VALUE, minCreature = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE;
//LAND //LAND
for(Player player : game.getPlayers().values()){ for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
int count = game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), player.getId(), source.getId(), game).size(); int count = game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), player.getId(), source.getId(), game).size();
if(count < minLand){ if(count < minLand){
@ -105,7 +109,8 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
} }
} }
for(Player player : game.getPlayers().values()){ for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
TargetControlledPermanent target = new TargetControlledPermanent(minLand, minLand, new FilterControlledLandPermanent(), true); TargetControlledPermanent target = new TargetControlledPermanent(minLand, minLand, new FilterControlledLandPermanent(), true);
target.setRequired(true); target.setRequired(true);
@ -121,7 +126,8 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
//CREATURE //CREATURE
for(Player player : game.getPlayers().values()){ for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
int count = game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), player.getId(), source.getId(), game).size(); int count = game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), player.getId(), source.getId(), game).size();
if(count < minCreature){ if(count < minCreature){
@ -130,7 +136,8 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
} }
} }
for(Player player : game.getPlayers().values()){ for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
TargetControlledPermanent target = new TargetControlledPermanent(minCreature, minCreature, new FilterControlledCreaturePermanent(), true); TargetControlledPermanent target = new TargetControlledPermanent(minCreature, minCreature, new FilterControlledCreaturePermanent(), true);
target.setRequired(true); target.setRequired(true);
@ -145,7 +152,8 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
} }
//CARD IN HAND //CARD IN HAND
for(Player player : game.getPlayers().values()){ for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
int count = player.getHand().size(); int count = player.getHand().size();
if(count < minCard){ if(count < minCard){
@ -154,7 +162,8 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
} }
} }
for(Player player : game.getPlayers().values()){ for(UUID playerId : controller.getInRange()){
Player player = game.getPlayer(playerId);
if(player != null){ if(player != null){
TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard()); TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard());
target.setRequired(true); target.setRequired(true);
@ -172,9 +181,7 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
return true; return true;
} }
return false;
@Override
public String getText(Mode mode) {
return "Each player chooses a number of lands he or she controls equal to the number of lands controlled by the player who controls the fewest, then sacrifices the rest. Players sacrifice creatures and discard cards the same way";
} }
} }