Package org.jpokemon.server

Examples of org.jpokemon.server.ServiceException


    try {
      pokemonIndex = request.getInt("pokemon");
    }
    catch (JSONException e) {
      throw new ServiceException("Pokemon index not provided");
    }

    try {
      pokemon = player.party().get(pokemonIndex);
    }
    catch (IllegalArgumentException e) {
      throw new ServiceException("Pokemon index " + pokemonIndex + " not found");
    }

    return pokemon;
  }
View Full Code Here


      }
    }
    catch (JSONException e) {
    }

    throw new ServiceException("Expected pokemon index");
  }
View Full Code Here

    }
  }

  @Override
  public void serve(JSONObject request, Player player) throws ServiceException {
    throw new ServiceException("Cannot serve from BuildTurnActivity");
  }
View Full Code Here

    }
    catch (JSONException e) {
      e.printStackTrace();
    }

    throw new ServiceException("targetId expected");
  }
View Full Code Here

    return this;
  }

  public void execute(Player player) throws ServiceException {
    if (!meetsRequirements(player)) {
      throw new ServiceException("Requirements not satisfied for actionset#" + id + " and " + player.toString());
    }

    for (Action action : _actions) {
      action.execute(player);
    }
View Full Code Here

  @Override
  public void execute(Player player) throws ServiceException {
    Store store = Store.get(storeId);

    if (store == null) {
      throw new ServiceException("Store undefined: " + storeId);
    }

    PlayerManager.addActivity(player, new StoreActivity(store));
  }
View Full Code Here

        moveIndex = request.getInt("moveIndex");

        PlayerManager.popActivity(player, this);
      }
      else {
        throw new ServiceException("Expected move index");
      }
    }
    catch (JSONException e) {
      throw new ServiceException("Expected move index");
    }
  }
View Full Code Here

        int change = itemChange.getInt("change");
        int denomination = itemChange.getInt("denomination");

        Inventory inventory = findInventory(itemID, denomination);

        if (inventory == null) { throw new ServiceException("Invalid sale request item:" + itemID + " denomination:" + denomination); }

        if (change > 0) {
          runningTotalCash -= change * inventory.getPrice();
        }
        else {
          runningTotalCash += change * inventory.getPurchaseprice();

          // The player does not have enough of that item to sell
          if (player.item(itemID).amount() >= -change) { throw new ServiceException("Insufficent quantity item : " + player.item(itemID).name()); }
        }
      }

      if (!(runningTotalCash >= 0)) { throw new ServiceException("Not enough cash to complete order"); }

      for (int index = 0; index < itemChanges.length(); index++) {
        JSONObject itemChange = itemChanges.getJSONObject(index);

        int itemID = itemChange.getInt("item");
View Full Code Here

    try {
      trainerData = XmlParser.parse(new File(filePath)).get(0);
    }
    catch (FileNotFoundException e) {
      throw new ServiceException("Trainer file not found: " + getData());
    }

    Trainer trainer = new Trainer(getData());
    trainer.loadXml(trainerData);
View Full Code Here

TOP

Related Classes of org.jpokemon.server.ServiceException

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.