}
@Override
public boolean executer(String parametres) {
String[] arg = parametres.split(":");
Game game = CommandLineLauncher.getGame();
Zone from;
Zone to;
List<Card> cards = new ArrayList<Card>();
if (arg.length == 3) {
String[] split = arg[0].split("-");
if (split.length == 1)
from = game.getZones().get(split[0]);
else if (split.length == 2)
try {
from = game.getPlayers().get(Integer.valueOf(split[0]))
.getZones().get(split[1]);
} catch (NumberFormatException e) {
System.out.println("Player number conversion error");
return false;
}
else
return false;
split = arg[1].split("-");
if (split.length == 1)
to = game.getZones().get(split[0]);
else if (split.length == 2)
try {
to = game.getPlayers().get(Integer.valueOf(split[0]))
.getZones().get(split[1]);
} catch (NumberFormatException e) {
System.out.println("Player number conversion error");
return false;
}
else
return false;
for (Card card : from.getSortedList()) {
if (card.getCardId() == Integer.valueOf(arg[2])) {
ActionPlayYourCards action = null;
for (Action act : game.getActions()) {
if (act instanceof ActionPlayYourCards) {
//FIXME : et si y'a plusieurs ActionplayCards ? et bah plouf ! => il faut utiliser les modules :)
try {
action = (ActionPlayYourCards) act.getClass()
.newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
}
cards.add(card);
try {
action.playerActed(new ActionEvent(game,
CommandLineLauncher.getCurrentPlayer(), from,
to, cards));
} catch (ActionException e) {
System.out.println("error during playing cards");
}
game.registerAction(action);
return true;
}
}
}