wrapped long lines
parent
7446cc7a1b
commit
e2476e37b9
|
@ -21,42 +21,51 @@ public class MagicCardChoice extends MagicChoice {
|
||||||
private final int amount;
|
private final int amount;
|
||||||
|
|
||||||
public MagicCardChoice(final int amount) {
|
public MagicCardChoice(final int amount) {
|
||||||
|
|
||||||
super(getDescription(amount));
|
super(getDescription(amount));
|
||||||
this.amount=amount;
|
this.amount=amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String getDescription(final int amount) {
|
private static final String getDescription(final int amount) {
|
||||||
|
|
||||||
if (amount==1) {
|
if (amount==1) {
|
||||||
return "Choose a card from your hand.";
|
return "Choose a card from your hand.";
|
||||||
} else {
|
} else {
|
||||||
return "Choose "+amount+" cards from your hand.";
|
return "Choose " + amount + " cards from your hand.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createOptions(final Collection<Object> options,final MagicCardList hand,
|
private void createOptions(
|
||||||
final MagicCard cards[],final int count,final int amount,final int index) {
|
final Collection<Object> options,
|
||||||
|
final MagicCardList hand,
|
||||||
|
final MagicCard cards[],
|
||||||
|
final int count,
|
||||||
|
final int amount,
|
||||||
|
final int index) {
|
||||||
|
|
||||||
if (count==amount) {
|
if (count == amount) {
|
||||||
options.add(new MagicCardChoiceResult(cards));
|
options.add(new MagicCardChoiceResult(cards));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (index==hand.size()) {
|
|
||||||
|
if (index == hand.size()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cards[count]=hand.get(index);
|
cards[count]=hand.get(index);
|
||||||
createOptions(options,hand,cards,count+1,amount,index+1);
|
createOptions(options,hand,cards,count+1,amount,index+1);
|
||||||
createOptions(options,hand,cards,count,amount,index+1);
|
createOptions(options,hand,cards,count,amount,index+1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Collection<Object> getArtificialOptions(final MagicGame game,final MagicEvent event,final MagicPlayer player,final MagicSource source) {
|
public Collection<Object> getArtificialOptions(
|
||||||
|
final MagicGame game,
|
||||||
|
final MagicEvent event,
|
||||||
|
final MagicPlayer player,
|
||||||
|
final MagicSource source) {
|
||||||
|
|
||||||
final List<Object> options=new ArrayList<Object>();
|
final List<Object> options = new ArrayList<Object>();
|
||||||
final MagicCardList hand=player.getHand();
|
final MagicCardList hand = player.getHand();
|
||||||
final int actualAmount=Math.min(amount,hand.size());
|
final int actualAmount = Math.min(amount,hand.size());
|
||||||
if (actualAmount>0) {
|
if (actualAmount > 0) {
|
||||||
createOptions(options,hand,new MagicCard[actualAmount],0,actualAmount,0);
|
createOptions(options,hand,new MagicCard[actualAmount],0,actualAmount,0);
|
||||||
} else {
|
} else {
|
||||||
options.add(new MagicCardChoiceResult());
|
options.add(new MagicCardChoiceResult());
|
||||||
|
@ -65,13 +74,16 @@ public class MagicCardChoice extends MagicChoice {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object[] getPlayerChoiceResults(final GameController controller,final MagicGame game,final MagicPlayer player,final MagicSource source) {
|
public Object[] getPlayerChoiceResults(
|
||||||
|
final GameController controller,
|
||||||
|
final MagicGame game,
|
||||||
|
final MagicPlayer player,
|
||||||
|
final MagicSource source) {
|
||||||
|
|
||||||
final MagicCardChoiceResult result=new MagicCardChoiceResult();
|
final MagicCardChoiceResult result=new MagicCardChoiceResult();
|
||||||
final Set<Object> validCards=new HashSet<Object>(player.getHand());
|
final Set<Object> validCards=new HashSet<Object>(player.getHand());
|
||||||
int actualAmount=Math.min(amount,validCards.size());
|
int actualAmount=Math.min(amount,validCards.size());
|
||||||
for (;actualAmount>0;actualAmount--) {
|
for (;actualAmount>0;actualAmount--) {
|
||||||
|
|
||||||
final String message=result.size()>0?result.toString()+"|"+MESSAGE:MESSAGE;
|
final String message=result.size()>0?result.toString()+"|"+MESSAGE:MESSAGE;
|
||||||
controller.focusViewers(0,-1);
|
controller.focusViewers(0,-1);
|
||||||
controller.disableActionButton(false);
|
controller.disableActionButton(false);
|
||||||
|
|
Loading…
Reference in New Issue