mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* Balancing Act and Restore Balance - Fixed that range of players was ignored (cbt33).
This commit is contained in:
parent
44a81f8162
commit
fdca147d4d
2 changed files with 118 additions and 108 deletions
|
@ -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,65 +90,67 @@ class BalancingActEffect extends OneShotEffect<BalancingActEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int minPermanent = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE;
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
//PERMANENTS
|
if (controller != null) {
|
||||||
for(Player player : game.getPlayers().values()){
|
int minPermanent = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE;
|
||||||
if(player != null){
|
// count minimal permanets
|
||||||
int count = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getId(), game).size();
|
for(UUID playerId : controller.getInRange()){
|
||||||
if(count < minPermanent){
|
Player player = game.getPlayer(playerId);
|
||||||
minPermanent = count;
|
if(player != null){
|
||||||
|
int count = game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getId(), game).size();
|
||||||
|
if(count < minPermanent){
|
||||||
|
minPermanent = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
// sacrifice permanents over the minimum
|
||||||
|
for(UUID playerId : controller.getInRange()){
|
||||||
for(Player player : game.getPlayers().values()){
|
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);
|
||||||
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
||||||
for(Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getId(), game)){
|
for(Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledPermanent(), player.getId(), source.getId(), game)){
|
||||||
if(permanent != null && !target.getTargets().contains(permanent.getId())){
|
if(permanent != null && !target.getTargets().contains(permanent.getId())){
|
||||||
permanent.sacrifice(source.getSourceId(), game);
|
permanent.sacrifice(source.getSourceId(), game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// count minimal cards in hand
|
||||||
//CARD IN HAND
|
for(UUID playerId : controller.getInRange()){
|
||||||
for(Player player : game.getPlayers().values()){
|
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){
|
||||||
minCard = count;
|
minCard = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// discard cards over the minimum
|
||||||
for(Player player : game.getPlayers().values()){
|
for(UUID playerId : controller.getInRange()){
|
||||||
if(player != null){
|
Player player = game.getPlayer(playerId);
|
||||||
TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard());
|
if(player != null){
|
||||||
target.setRequired(true);
|
TargetCardInHand target = new TargetCardInHand(minCard, new FilterCard());
|
||||||
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
target.setRequired(true);
|
||||||
Cards cards = player.getHand().copy();
|
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
||||||
for(UUID cardUUID : cards){
|
Cards cards = player.getHand().copy();
|
||||||
Card card = player.getHand().get(cardUUID, game);
|
for(UUID cardUUID : cards){
|
||||||
if(card != null && !target.getTargets().contains(cardUUID)){
|
Card card = player.getHand().get(cardUUID, game);
|
||||||
player.discard(card, source, game);
|
if(card != null && !target.getTargets().contains(cardUUID)){
|
||||||
|
player.discard(card, source, game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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,87 +95,93 @@ class RestoreBalanceEffect extends OneShotEffect<RestoreBalanceEffect> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public boolean apply(Game game, Ability source) {
|
||||||
int minLand = Integer.MAX_VALUE, minCreature = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE;
|
Player controller = game.getPlayer(source.getControllerId());
|
||||||
//LAND
|
if (controller != null) {
|
||||||
for(Player player : game.getPlayers().values()){
|
int minLand = Integer.MAX_VALUE, minCreature = Integer.MAX_VALUE, minCard = Integer.MAX_VALUE;
|
||||||
if(player != null){
|
//LAND
|
||||||
int count = game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), player.getId(), source.getId(), game).size();
|
for(UUID playerId : controller.getInRange()){
|
||||||
if(count < minLand){
|
Player player = game.getPlayer(playerId);
|
||||||
minLand = count;
|
if(player != null){
|
||||||
|
int count = game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), player.getId(), source.getId(), game).size();
|
||||||
|
if(count < minLand){
|
||||||
|
minLand = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
for(UUID playerId : controller.getInRange()){
|
||||||
for(Player player : game.getPlayers().values()){
|
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);
|
||||||
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
||||||
for(Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), player.getId(), source.getId(), game)){
|
for(Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledLandPermanent(), player.getId(), source.getId(), game)){
|
||||||
if(permanent != null && !target.getTargets().contains(permanent.getId())){
|
if(permanent != null && !target.getTargets().contains(permanent.getId())){
|
||||||
permanent.sacrifice(source.getSourceId(), game);
|
permanent.sacrifice(source.getSourceId(), game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
//CREATURE
|
||||||
//CREATURE
|
for(UUID playerId : controller.getInRange()){
|
||||||
for(Player player : game.getPlayers().values()){
|
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){
|
||||||
minCreature = count;
|
minCreature = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
for(UUID playerId : controller.getInRange()){
|
||||||
for(Player player : game.getPlayers().values()){
|
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);
|
||||||
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
||||||
for(Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), player.getId(), source.getId(), game)){
|
for(Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), player.getId(), source.getId(), game)){
|
||||||
if(permanent != null && !target.getTargets().contains(permanent.getId())){
|
if(permanent != null && !target.getTargets().contains(permanent.getId())){
|
||||||
permanent.sacrifice(source.getSourceId(), game);
|
permanent.sacrifice(source.getSourceId(), game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
//CARD IN HAND
|
||||||
//CARD IN HAND
|
for(UUID playerId : controller.getInRange()){
|
||||||
for(Player player : game.getPlayers().values()){
|
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){
|
||||||
minCard = count;
|
minCard = count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
for(UUID playerId : controller.getInRange()){
|
||||||
for(Player player : game.getPlayers().values()){
|
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);
|
||||||
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
if(target.choose(Outcome.Benefit, player.getId(), source.getId(), game)){
|
||||||
Cards cards = player.getHand().copy();
|
Cards cards = player.getHand().copy();
|
||||||
for(UUID cardUUID : cards){
|
for(UUID cardUUID : cards){
|
||||||
Card card = player.getHand().get(cardUUID, game);
|
Card card = player.getHand().get(cardUUID, game);
|
||||||
if(card != null && !target.getTargets().contains(cardUUID)){
|
if(card != null && !target.getTargets().contains(cardUUID)){
|
||||||
player.discard(card, source, game);
|
player.discard(card, source, game);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue