Example #1
0
  public static TaskExecutionFailure failureFromException(@NotNull Exception e) {

    TaskExecutionFailureImplementationFault fault = new TaskExecutionFailureImplementationFault();
    fault.setMessage(e.getMessage());
    StringWriter sw = new StringWriter();
    PrintWriter pw = new PrintWriter(sw);
    e.printStackTrace(pw);
    pw.close();
    fault.setFaultTrace(sw.toString());
    fault.setFaultClass(e.getClass().getName());

    StackTraceElement[] se = e.getStackTrace();
    if (se.length > 0) fault.setFaultLocation(se[0].toString());

    TaskExecutionFailure tef = new TaskExecutionFailure();

    tef.setImplementationFault(fault);

    return tef;
  }
Example #2
0
  public void mouseReleased(MouseEvent e) {
    // traitement bouton aide relache
    if (this.terrain.getGui().getEquipeActuel().estMosco()) {
      this.terrain.aideSoviet.traiterBoutonRelache(e);
    } else {
      this.terrain.aideSued.traiterBoutonRelache(e);
    }

    if (this.terrain.getPopupRestart().isActivate()) {
      this.terrain.getPopupRestart().traiterBoutonsPopupRelache(e);
      // si le clique sur le oui est valide
      if (this.terrain.getPopupRestart().getOui().isClicValide()) {
        this.terrain.setImagePopup(null);
        this.terrain.getPopupRestart().getOui().setClicValide(false);
        // on relance une partie avec les memes config
        this.terrain.getGui().setDernierCoup(null);
        this.terrain.setAideActiveSoviet(false);
        this.terrain.setAideActiveSued(false);
        this.terrain.getGui().relancer(-1);
        this.terrain.getPopupRestart().setActivate(false);

      }
      // sinon si le clic du non est valide
      else if (this.terrain.getPopupRestart().getNon().isClicValide()) {
        this.terrain.setImagePopup(null);
        this.terrain.getPopupRestart().setActivate(false);
        this.terrain.setAideActiveSoviet(false);
        this.terrain.setAideActiveSued(false);
        this.terrain.getPopupRestart().getNon().setClicValide(false);
        this.terrain.getGui().getFrame().remove(this.terrain);
        // on relance une partie avec les memes config
        this.terrain.getGui().getNoyau().menuPrincipal();
      }

    }
    /*sinon si le popup est active*/
    else if (this.terrain.getEquipeBloquee().isActivate()) {
      this.terrain.getEquipeBloquee().traiterBoutonsPopupRelache(e);
      // si le clique sur le oui est valide
      if (this.terrain.getEquipeBloquee().getOui().isClicValide()) {
        this.terrain.setImagePopup(null);
        this.terrain.getEquipeBloquee().setActivate(false);
        this.terrain.getEquipeBloquee().getOui().setClicValide(false);
        // on relance une partie avec les memes config
        this.terrain.getGui().setDernierCoup(null);
        this.terrain.getGui().relancer(-1);

      }
      // sinon si le clic du non est valide
      else if (this.terrain.getEquipeBloquee().getNon().isClicValide()) {
        this.terrain.setImagePopup(null);
        this.terrain.getEquipeBloquee().setActivate(false);
        this.terrain.getEquipeBloquee().getNon().setClicValide(false);
        this.terrain.getGui().getFrame().remove(this.terrain);
        // on relance une partie avec les memes config
        this.terrain.getGui().getNoyau().menuPrincipal();
      }
    } else if (this.terrain.getSound().estDansBox(e.getPoint())) {
      this.terrain.getGui().getNoyau().getOptionConfig().switchSound();
      try {
        this.terrain.getGui().getNoyau().getOptionConfig().sauvegarder();
      } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
      }
      this.terrain.getSound().setEstCoche(false);
      this.terrain.repaint();
    }
    // traiter le clic sur le bouton aide
    else if (this.terrain.getAideSoviet().isClicValide()) {
      this.terrain.getBoxToArbitre().send(JobArbitre.aide(Equipe.MOSCO));
    } else if (this.terrain.getAideSued().isClicValide()) {
      this.terrain.getBoxToArbitre().send(JobArbitre.aide(Equipe.SUEDE));
    } else {
      if (this.terrain.getGui().getSuedois().isIA()
          || this.terrain.getGui().getMoscovite().isIA()) {
        this.terrain.getAnnuler().traiterBoutonRelache(e);
        this.terrain.getRefaire().traiterBoutonRelache(e);

        if (this.terrain.getGui().isPause()) this.terrain.getPlay().traiterBoutonRelache(e);
        else this.terrain.getPause().traiterBoutonRelache(e);
      }
      this.terrain.getMenu().traiterBoutonRelache(e);

      if (this.terrain.getMenu().isClicValide()) {
        this.terrain.getGui().pause();
        this.terrain.getMenu().setClicValide(false);
        EnregistreurContainer a = new EnregistreurContainer(this.terrain);
        this.terrain.getGui().getMenuPlateau().setScreenshot(a);
        this.terrain.getGui().demarrer();
      }

      if (this.terrain.getGui().getMoscovite().isIA()
          && !this.terrain.getGui().getEquipeActuel().estMosco()) {
        this.terrain.getDifficulteSovietPlus().traiterBoutonRelache(e);
        this.terrain.getDifficulteSovietMoins().traiterBoutonRelache(e);
      }
      if (this.terrain.getGui().getSuedois().isIA()
          && !this.terrain.getGui().getEquipeActuel().estSuede()) {
        this.terrain.getDifficulteSuedPlus().traiterBoutonRelache(e);
        this.terrain.getDifficulteSuedMoins().traiterBoutonRelache(e);
      }
      if (this.terrain.getGui().getEquipeActuel().estMosco()) {
        this.terrain.getChangerSuedGauche().traiterBoutonRelache(e);
        this.terrain.getChangerSuedDroit().traiterBoutonRelache(e);
      }
      if (this.terrain.getGui().getEquipeActuel().estSuede()) {
        this.terrain.getChangerSovietDroit().traiterBoutonRelache(e);
        this.terrain.getChangerSovietGauche().traiterBoutonRelache(e);
      }
      if (this.terrain.getMenu().isClicValide()) {
        this.terrain.getMenu().setClicValide(false);
        EnregistreurContainer a = new EnregistreurContainer(this.terrain);
        this.terrain.getGui().getMenuPlateau().setScreenshot(a);
        this.terrain.getGui().demarrer();
      }
      // GESTION DES FLECHES POUR LA DIFFICULTE
      if (this.terrain.getDifficulteSovietPlus().isClicValide()) {
        this.terrain.getDifficulteSovietPlus().setClicValide(false);
        this.terrain.getGui().getBoxToArbitre().send(JobArbitre.difficultee(+1, Equipe.MOSCO));
        int diff = (this.terrain.getGui().getNoyau().getConfigPartie().getDifficulteeJ1() + 1) % 3;
        this.terrain.getGui().getNoyau().getConfigPartie().setDifficulteeJ1(diff);
      }
      if (this.terrain.getDifficulteSovietMoins().isClicValide()) {
        this.terrain.getDifficulteSovietMoins().setClicValide(false);
        this.terrain.getGui().getBoxToArbitre().send(JobArbitre.difficultee(-1, Equipe.MOSCO));
        int diff = (this.terrain.getGui().getNoyau().getConfigPartie().getDifficulteeJ1() - 1) % 3;
        if (diff == -1) diff = 2;
        this.terrain.getGui().getNoyau().getConfigPartie().setDifficulteeJ1(diff);
      }
      if (this.terrain.getDifficulteSuedPlus().isClicValide()) {
        this.terrain.getDifficulteSuedPlus().setClicValide(false);
        this.terrain.getGui().getBoxToArbitre().send(JobArbitre.difficultee(+1, Equipe.SUEDE));
        int diff = (this.terrain.getGui().getNoyau().getConfigPartie().getDifficulteeJ2() + 1) % 3;
        this.terrain.getGui().getNoyau().getConfigPartie().setDifficulteeJ2(diff);
      }
      if (this.terrain.getDifficulteSuedMoins().isClicValide()) {
        this.terrain.getDifficulteSuedMoins().setClicValide(false);
        this.terrain.getGui().getBoxToArbitre().send(JobArbitre.difficultee(-1, Equipe.SUEDE));
        int diff = (this.terrain.getGui().getNoyau().getConfigPartie().getDifficulteeJ2() - 1) % 3;
        if (diff == -1) diff = 2;
        this.terrain.getGui().getNoyau().getConfigPartie().setDifficulteeJ2(diff);
      }
      // GESTION DES FLECHES POUR LE TYPE DE JOUEUR
      if (this.terrain.getChangerSuedGauche().isClicValide()) {
        this.terrain.getChangerSuedGauche().setClicValide(false);
        this.terrain.getBoxToArbitre().send(JobArbitre.IAtoJoueur(Equipe.SUEDE));
      }
      if (this.terrain.getChangerSuedDroit().isClicValide()) {
        this.terrain.getChangerSuedDroit().setClicValide(false);
        this.terrain.getBoxToArbitre().send(JobArbitre.IAtoJoueur(Equipe.SUEDE));
      }
      if (this.terrain.getChangerSovietDroit().isClicValide()) {
        this.terrain.getChangerSovietDroit().setClicValide(false);
        this.terrain.getBoxToArbitre().send(JobArbitre.IAtoJoueur(Equipe.MOSCO));
      }
      if (this.terrain.getChangerSovietGauche().isClicValide()) {
        this.terrain.getChangerSovietGauche().setClicValide(false);
        this.terrain.getBoxToArbitre().send(JobArbitre.IAtoJoueur(Equipe.MOSCO));
      }

      // traiter les boutons du MenuPlateau + bouton a linterieur de sauvegarder et charger
      if (this.terrain.getGui().getSuedois().isIA()
          || this.terrain.getGui().getMoscovite().isIA()) {
        if (this.terrain.getAnnuler().isClicValide()) {
          try {
            this.terrain.getBoxToArbitre().send(JobArbitre.annuler());
            this.terrain.getGui().setDernierCoup(null);
          } catch (Exception e1) {
            e1.printStackTrace();
          }
          this.terrain.getAnnuler().setClicValide(false);
        }
        if (this.terrain.getRefaire().isClicValide()) {
          try {
            this.terrain.getBoxToArbitre().send(JobArbitre.refaire());
            this.terrain.getGui().setDernierCoup(null);
          } catch (Exception e1) {
            e1.printStackTrace();
          }
          this.terrain.getRefaire().setClicValide(false);
        }
        if (this.terrain.getPause().isClicValide()) {
          this.terrain.getPause().setClicValide(false);
          this.terrain.getGui().pause();
        }
        if (this.terrain.getPlay().isClicValide()) {
          this.terrain.getPlay().setClicValide(false);
          this.terrain.getGui().finPause();
        }
      }
    }
  }