move code that does not use game/event outside of MagicSourceEvent

master
melvinzhang 2017-08-21 11:22:27 +08:00
parent 12aafc5b83
commit e5fa047f89
1 changed files with 14 additions and 11 deletions

View File

@ -3439,6 +3439,16 @@ public enum MagicRuleEventAction {
: optional ? "PN may$ " + mayTense(contextRule)
: capitalize(playerRule);
final MagicMatchedCostEvent matchedCost =
mayDoMatched ? mayDoCost
: mustDoMatched ? mustDoCost
: mayDontMatched ? mayDontCost
: mustDontMatched ? mustDontCost
: MagicRegularCostEvent.NONE;
final boolean hasCost = matchedCost != MagicRegularCostEvent.NONE;
final boolean elseAction = mayDontMatched || mustDontMatched;
return new MagicSourceEvent(
ruleAction,
matcher,
@ -3450,25 +3460,18 @@ public enum MagicRuleEventAction {
return;
}
final MagicMatchedCostEvent matchedCost =
mayDoMatched ? mayDoCost
: mustDoMatched ? mustDoCost
: mayDontMatched ? mayDontCost
: mustDontMatched ? mustDontCost
: MagicRegularCostEvent.NONE;
final MagicEvent costEvent = matchedCost.getEvent(event.getSource());
if ((matchedCost == MagicRegularCostEvent.NONE || costEvent.isSatisfied()) &&
if ((hasCost == false || costEvent.isSatisfied()) &&
(optional == false || event.isYes())) {
if (matchedCost != MagicRegularCostEvent.NONE) {
if (hasCost) {
game.addEvent(costEvent);
}
if (mayDontMatched == false && mustDontMatched == false) {
if (elseAction == false) {
action.executeEvent(game, event);
}
} else {
if (mayDontMatched || mustDontMatched) {
if (elseAction) {
action.executeEvent(game, event);
}
}