MagicDiscardEvent cannot discard the source

master
melvin 2014-07-31 10:51:53 +08:00
parent 18318d90b0
commit 1340d2c1f7
3 changed files with 6 additions and 1 deletions

View File

@ -67,6 +67,7 @@ public class MagicCardChoice extends MagicChoice {
final List<Object> options = new ArrayList<Object>();
final MagicCardList hand = new MagicCardList(player.getHand());
hand.remove(source);
Collections.sort(hand);
final int actualAmount = Math.min(amount,hand.size());
if (actualAmount > 0) {
@ -86,6 +87,7 @@ public class MagicCardChoice extends MagicChoice {
final MagicCardChoiceResult result=new MagicCardChoiceResult();
final Set<Object> validCards=new HashSet<Object>(player.getHand());
validCards.remove(source);
int actualAmount=Math.min(amount,validCards.size());
for (;actualAmount>0;actualAmount--) {
final String message=result.size()>0?result.toString()+"|"+MESSAGE:MESSAGE;

View File

@ -22,6 +22,7 @@ public class MagicRandomCardChoice extends MagicChoice {
private MagicCardChoiceResult discard(final MagicPlayer player, final MagicSource source) {
final MagicCardChoiceResult result=new MagicCardChoiceResult();
final MagicCardList hand=new MagicCardList(player.getHand());
hand.remove(source);
hand.shuffle();
final int actualAmount=Math.min(hand.size(),amount);
for (int i = 0; i < actualAmount; i++) {

View File

@ -55,8 +55,10 @@ public class MagicDiscardEvent extends MagicEvent {
EVENT_ACTION,
"PN " + genDescription(player,amount)
);
//check if source is in player's hand
final int minHandSize = player.getHand().contains(source) ? amount + 1 : amount;
conds = new MagicCondition[]{
MagicConditionFactory.HandAtLeast(amount)
MagicConditionFactory.HandAtLeast(minHandSize)
};
}