예제 #1
0
 @Override
 public boolean isValid(Game game) {
   if (!super.isValid(game)) return false;
   // we need a good location
   if (newLocation == null) {
     invalidMessage = "Location can't be null";
     return false;
   }
   // Make sure the player does not put robber or pirate on the edge of the
   // map,
   // which is forbidden
   if (game.board().hexes().isAtEdge(newLocation)) {
     invalidMessage = "putting robber on the edge is not allowed";
     return false;
   }
   // TODO: check if a previous action included rolling a 7,
   // or playing a soldier development card
   // Player may not leave the robber on the same location
   if (game.robber().location().equals(newLocation)) {
     invalidMessage = "putting robber back onto same location is not allowed";
     return false;
   }
   Hex hex = game.board().hexes().get(newLocation);
   if (!hex.isRobberPlaceable()) {
     invalidMessage = "Can't place robber or pirate on a " + hex.getName();
     return false;
   }
   return super.isValid(game);
 }
예제 #2
0
 @Override
 public void perform(Game game) {
   game.robber().setLocation(newLocation);
   // TODO: fix message
   // _Message = String.Format("{0} put the robber on the {1}",
   // xmlGame.GetPlayer(Sender).XmlPlayer.Name,
   // Location.ToString(xmlGame.Board));
   super.perform(game);
 }