Exemplo n.º 1
0
 public ActionRedirect updateMousePosition(
     final IUIBean bean, final String listenerType, final String actionName, final EventObject e) {
   final GameBean gb = (GameBean) bean;
   gb.setMouseActualX(new Integer(EventMethods.getX(e)));
   gb.setMouseActualY(new Integer(EventMethods.getY(e)));
   return null;
 }
Exemplo n.º 2
0
  /**
   * Construire insertion Vérifier insertion Compter score Enregistrer
   *
   * @param bean
   * @param listenerType
   * @param actionName
   * @param e
   * @return
   * @throws NoSuchMethodException
   * @throws ScrabbleException
   */
  public ActionRedirect validate(
      final IUIBean bean, final String listenerType, final String actionName, final EventObject e)
      throws ScrabbleException {
    GameAction.LOG.info("Appui sur le bouton 'Valider'");
    final GameBean gb = (GameBean) bean;
    final Map<String, IComponent> c = ScrabbleBeansHelper.getComponents();
    final UserInteractions ui = this.getUiOwner();
    final ILetterBranchGroup[][] lbgs =
        ((ChangeTurnBean) ui.getBean(ChangeTurnBean.ID_BEAN)).getLetterBranchGroups();
    if (lbgs == null) {
      throw new ScrabbleException("Pas de jeu en cours");
    }
    final int turn = ((Integer) ScrabbleSessionsHandler.get().get(ChangeTurnBean.TURN)).intValue();
    final int[][] alignment = new int[lbgs[turn].length][2];
    final char[] letters = new char[lbgs[turn].length];

    c.get("getAligns").execute(lbgs[turn], alignment, letters);

    final Object i = c.get("createInsertion").execute(alignment, letters);

    String[] words = null;
    try {
      words = (String[]) c.get("validateInsertion").executeAndThrow(i);
    } catch (InvocationTargetException e1) {
      throw new ScrabbleException(e1.getTargetException().getMessage());
    }
    c.get("insert").execute(i);

    final int score = ((Integer) c.get("countScore").execute(i)).intValue();

    c.get("storeScore").execute(new Integer(turn), words, new Integer(score));

    if (turn == 0) {
      gb.getScoresTableModel().addRow();
    }
    String text = "";
    for (String word : words) {
      text += word + "\n";
    }
    if (text.length() > 0) {
      text = text.substring(0, text.length() - 1);
    }
    gb.getScoresTableModel().setValueAt(text + "\t" + score, -1, turn);

    for (final ILetterBranchGroup lbg : lbgs[turn]) {
      if (BoundsChecker.isOverBoard(lbg)) {
        lbg.setOld();
        c.get("setOld").execute(new Integer(turn), new Integer(lbg.getIdTray()));
      }
    }
    return ((ChangeTurnAction) this.getUiOwner().getAction(ChangeTurnAction.class.getName()))
        .changeTurn(ui.getBean(ChangeTurnBean.ID_BEAN), listenerType, actionName, e);
  }
Exemplo n.º 3
0
 public ActionRedirect forwardBackward(
     final IUIBean bean, final String listenerType, final String actionName, final EventObject e) {
   final GameBean gb = (GameBean) bean;
   MoveObjectHelper.move(
       gb.getSc3d(),
       GameBean.CAMERA,
       gb.getSc3d().getCameraTransformGroup(),
       2,
       EventMethods.getWheelRotation(e),
       0,
       EventMethods.getScrollAmount(e),
       0,
       0);
   return null;
 }
Exemplo n.º 4
0
  private void setPressedAttributes(final GameBean gb, final Session session, final EventObject e) {
    gb.setMousePressX(new Integer(EventMethods.getX(e)));
    gb.setMousePressY(new Integer(EventMethods.getY(e)));
    gb.setButtonPressed(new Integer(EventMethods.getButton(e)));

    Object stg =
        S3DHelper.getScenePicker()
            .getTransformGroupAt(
                gb.getSc3d(), "LetterBranchGroup", EventMethods.getX(e), EventMethods.getY(e));
    if (stg == null) {
      stg = gb.getSc3d().getCameraTransformGroup();
      gb.setTypeOfObjectMoved(GameBean.CAMERA);
    } else {
      gb.setTypeOfObjectMoved("Letter");
    }

    gb.setMoveObject(stg);
  }
Exemplo n.º 5
0
  public ActionRedirect movement(
      final IUIBean bean, final String listenerType, final String actionName, final EventObject e) {
    final GameBean gb = (GameBean) bean;
    final Session session = ScrabbleSessionsHandler.get();
    final Integer turn = (Integer) session.get(ChangeTurnBean.TURN);
    int turnInt = 0;
    if (turn != null) {
      turnInt = turn.intValue();
    }

    MoveObjectHelper.move(
        gb.getSc3d(),
        gb.getTypeOfObjectMoved(),
        gb.getMoveObject(),
        gb.getButtonPressed().intValue(),
        gb.getMouseActualX().intValue(),
        gb.getMousePressX().intValue(),
        gb.getMouseActualY().intValue(),
        gb.getMousePressY().intValue(),
        turnInt);
    return null;
  }
Exemplo n.º 6
0
 public ActionRedirect changeSkin(
     final IUIBean bean, final String listenerType, final String actionName, final EventObject e) {
   final GameBean gb = (GameBean) bean;
   InitAppearance.changeLaf60((Class<?>) gb.getSkinCbxValue());
   return null;
 }