Package org.mozilla.javascript

Examples of org.mozilla.javascript.ScriptableObject$GetterSlot


      final String user, final String diskNumber, final String pointString)
      throws GameEngineException {
    Step step = MiniProfiler.step("API.saveReinforcements");
    try {

      final ScriptableObject point = ge.execute("_=" + pointString);

      ge.invoke(table, "saveReinforcement", new Object[] { user,
          diskNumber, point });

      saveTable(table);
View Full Code Here


  protected void updateRatings(ScriptableObject table)
      throws GameEngineException {
    Step step = MiniProfiler.step("API.updateRatings");
    try {
      // loop over all the players in the table
      ScriptableObject players = (ScriptableObject) table.get("players");

      List<Object> playerNames = Arrays.asList(players.getIds());
      for (Object playerName : playerNames) {
        ScriptableObject player = getPlayer((String) playerName);
        Double adjustment = (Double) ge.invoke(table,
            "getRatingAdjustment", new Object[] { playerName });

        Object object = player.get("rating");
        if (object == null || !(object instanceof Number)) {
          object = new Double(0);
        }
        Double rating = ((Number) object).doubleValue();
        rating += adjustment;
View Full Code Here

                        .equals("null") ? Integer
                    .parseInt(diskData[headers
                        .indexOf("limit")]) : 0;
                int cost = Integer.parseInt(diskData[headers
                    .indexOf("cost")]);
                ScriptableObject disk = createDisk(
                    diskName,
                    type,
                    attack,
                    defense,
                    toughness,
View Full Code Here

      "/com/antonytrupe/tend/Trade.js",
      "/com/antonytrupe/tend/Settlement.js" });

  public ScriptableObject createBoard() throws GameEngineException {

    ScriptableObject board = ge.execute("new Board();");

    ge.invoke(board, "grow", new Integer[] { 1, 0, 3, 1 });
    // board.grow(1, 0, 3, 1);

    ge.invoke(board, "grow", new Integer[] { 0, 1, 5, 3 });
View Full Code Here

  }

  private ScriptableObject getBoard() throws GameEngineException {
    HashMap<String, String> hashMap = ge.persistence.get("Board");
    ScriptableObject board = createBoard();
    update(board, hashMap.get("json"));
    return board;
  }
View Full Code Here

    return board;
  }

  public ScriptableObject getBoard(long l) throws GameEngineException {
    HashMap<String, Object> hashMap = ge.persistence.get("Board", l);
    ScriptableObject board = createBoard();
    update(board, (String) hashMap.get("json"));
    return board;
  }
View Full Code Here

  }

  protected ScriptableObject joinBoard(Long boardId, String userName)
      throws GameEngineException {

    ScriptableObject board;
    if (boardId == null) {
      board = createBoard();

    } else {
      board = getBoard(boardId);
View Full Code Here

    String json = "";
    switch (action) {
    case GET_BOARD: {

      final Long boardId = getBoardId(parameters);
      final ScriptableObject board;
      if (boardId != null) {
        board = getBoard(boardId);

      } else {
        board = getBoard();

      }
      json += "\"board\":";
      json += stringify(board);
      break;
    }
    case JOIN_BOARD:
      if (user == null || user == "") {
        // /login.html?return_to=hex%252Fapi%253Faction%253DJOIN_BOARD
        final Long boardId = getBoardId(parameters);
        try {
          response.sendRedirect("/login.html?return_to=tend%252Fapi%253Faction%253DJOIN_BOARD%2526id%253D"
              + boardId);
          return null;
        } catch (IOException e1) {
          e1.printStackTrace();
        }

      }
      final Long boardId = getBoardId(parameters);
      joinBoard(boardId, user);
      try {
        // Long id = (Long) board.get("id");
        response.sendRedirect("/tend/#!" + boardId);
        return null;
      } catch (IOException e) {
        e.printStackTrace();
      }
      break;
    case COLLECT:
      break;
    case CREATE_BOARD:
      break;
    case FINISH_TURN: {
      ScriptableObject board = getBoard(getBoardId(parameters));
      endTurn(board, user);

      json += "\"board\":";
      json += stringify(board);
    }
      break;
    case LIST_BOARDS:
      json = "\"boards\":[";

      HashMap<Object, HashMap<String, Object>> boards = ge.persistence
          .getAll("Board");
      for (Entry<Object, HashMap<String, Object>> board : boards
          .entrySet()) {
        String ad = ((Text) board.getValue().get("json")).getValue();
        json += ad + ",";
      }
      json = json.substring(0, json.length() - 1);
      json += "]";
      break;
    case RESET_COLLECTIONS:
      break;
    case RESET_SETTLEMENTS:
      break;
    case TRADE:
      break;
    case QUEUE_SETTLEMENT:
      ScriptableObject board = getBoard(getBoardId(parameters));
      String settlementPoint = getParameter("settlementPoint", parameters);
      String settlementName = getParameter("settlementName", parameters);
      String resources = getParameter("resources", parameters);
      queueSettlement(board, user, settlementPoint, settlementName,
          resources);
View Full Code Here

  public boolean shouldExecute( final Map currentInputs, final Log logger ) throws Exception {
    boolean shouldExecute = true;
    Context cx = ContextFactory.getGlobal().enterContext();
    try {
      ScriptableObject scriptable = new RhinoScriptable();
      // initialize the standard javascript objects
      Scriptable scope = cx.initStandardObjects( scriptable );
      ScriptableObject.defineClass( scope, JavaScriptResultSet.class );
      Object inputValue;
      IActionParameter inputParameter;
View Full Code Here

        script = buffer.toString();
        if ( ComponentBase.debug ) {
          debug( "script=" + script ); //$NON-NLS-1$
        }
        try {
          ScriptableObject scriptable = new RhinoScriptable();
          // initialize the standard javascript objects
          Scriptable scope = cx.initStandardObjects( scriptable );

          Object resultObject = executeScript( scriptable, scope, script, cx );
          if ( oldStyleOutputs ) {
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.ScriptableObject$GetterSlot

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.