removed duplicate code in CField

This commit is contained in:
Maxmtg
2012-11-11 16:54:57 +00:00
parent 833b1966a7
commit cffa7da63a

View File

@@ -102,27 +102,27 @@ public class CField implements ICDoc {
private final MouseListener madBlack = new MouseAdapter() { @Override private final MouseListener madBlack = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
blackAction(); } }; manaAction(Constant.Color.BLACK); } };
private final MouseListener madBlue = new MouseAdapter() { @Override private final MouseListener madBlue = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
blueAction(); } }; manaAction(Constant.Color.BLUE); } };
private final MouseListener madGreen = new MouseAdapter() { @Override private final MouseListener madGreen = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
greenAction(); } }; manaAction(Constant.Color.GREEN); } };
private final MouseListener madRed = new MouseAdapter() { @Override private final MouseListener madRed = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
redAction(); } }; manaAction(Constant.Color.RED); } };
private final MouseListener madWhite = new MouseAdapter() { @Override private final MouseListener madWhite = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
whiteAction(); } }; manaAction(Constant.Color.WHITE); } };
private final MouseListener madColorless = new MouseAdapter() { @Override private final MouseListener madColorless = new MouseAdapter() { @Override
public void mousePressed(final MouseEvent e) { public void mousePressed(final MouseEvent e) {
colorlessAction(); } }; manaAction(Constant.Color.COLORLESS); } };
// Hand, Graveyard, Library, Flashback, Exile zones, attached to hand. // Hand, Graveyard, Library, Flashback, Exile zones, attached to hand.
private final Observer observerZones = new Observer() { private final Observer observerZones = new Observer() {
@@ -479,7 +479,7 @@ public class CField implements ICDoc {
} }
/** */ /** */
private void blackAction() { private void manaAction(String constantColor) {
if (CField.this.player.isComputer()) { if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana"); System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here // TODO: Mindslaver might need to add changes here
@@ -487,77 +487,7 @@ public class CField implements ICDoc {
final Input in = Singletons.getModel().getMatch().getInput().getInput(); final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputPayMana) { if (in instanceof InputPayMana) {
// Do something // Do something
((InputPayMana) in).selectManaPool(Constant.Color.BLACK); ((InputPayMana) in).selectManaPool(constantColor);
}
}
}
/** */
private void blueAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputPayMana) {
// Do something
((InputPayMana) in).selectManaPool(Constant.Color.BLUE);
}
}
}
/** */
private void greenAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputPayMana) {
// Do something
((InputPayMana) in).selectManaPool(Constant.Color.GREEN);
}
}
}
/** */
private void redAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputPayMana) {
// Do something
((InputPayMana) in).selectManaPool(Constant.Color.RED);
}
}
}
/** */
private void whiteAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputPayMana) {
// Do something
((InputPayMana) in).selectManaPool(Constant.Color.WHITE);
}
}
}
/** */
private void colorlessAction() {
if (CField.this.player.isComputer()) {
System.out.println("Stop trying to spend the AI's mana");
// TODO: Mindslaver might need to add changes here
} else {
final Input in = Singletons.getModel().getMatch().getInput().getInput();
if (in instanceof InputPayMana) {
// Do something
((InputPayMana) in).selectManaPool(Constant.Color.COLORLESS);
} }
} }
} }