Пример #1
0
  @RequestMapping(value = "/combat/pve/Attack", method = RequestMethod.POST)
  public @ResponseBody CombatObject increaseAttack(@RequestBody CombatObject data) {
    data = CombatLogic.playerAttack(data);

    if (data.getThePlayer().getCurrentHealth() > 0 && data.getTheEnemy().getHealth() <= 0) {
      data = CombatLogic.survivingPlayer(data);
    } else {
      data = CombatLogic.enemyAttack(data);
    }

    if (data.getThePlayer().getCurrentHealth() <= 0) {
      data = CombatLogic.dieingPlayer(data);
    }

    try {
      Connection connection = DatabaseUrl.extract().getConnection();
      Statement stmtUser = connection.createStatement();
      stmtUser.execute(
          "UPDATE Characters SET currenthealth = '"
              + data.getThePlayer().getCurrentHealth()
              + "'  WHERE characterid = '"
              + data.getThePlayer().getCharacterID()
              + "'");
      stmtUser.execute(
          "UPDATE Characters SET zeni = '"
              + data.getThePlayer().getMoney()
              + "'  WHERE characterid = '"
              + data.getThePlayer().getCharacterID()
              + "'");
    } catch (Exception e) {
      System.out.println(e);
    }

    return data;
  }
Пример #2
0
  @RequestMapping(value = "/combat/pve/Heal", method = RequestMethod.POST)
  public @ResponseBody CombatObject increaseHealth(@RequestBody CombatObject data) {
    data = CombatLogic.healPlayer(data);

    if (data.getThePlayer().getCurrentHealth() > 0 && data.getTheEnemy().getHealth() <= 0) {
      data = CombatLogic.survivingPlayer(data);
    } else {
      data = CombatLogic.enemyAttack(data);
    }

    if (data.getThePlayer().getCurrentHealth() <= 0) {
      data = CombatLogic.dieingPlayer(data);
    }

    try {
      Connection connection = DatabaseUrl.extract().getConnection();
      Statement stmtUser = connection.createStatement();
      // Table that relates characters to users:		usercharacters
      // Columns:		characterid		chactername		health		attack		healingitems	zeni
      // DataTypes:	int				string			int			int			int				int
      // ResultSet character = stmtUser.executeQuery("SELECT health FROM Characters WHERE
      // characterid = '" + data.getThePlayer().getCharacterID() + "'");
      stmtUser.execute(
          "UPDATE Characters SET currenthealth = '"
              + data.getThePlayer().getCurrentHealth()
              + "'  WHERE characterid = '"
              + data.getThePlayer().getCharacterID()
              + "'");
      stmtUser.execute(
          "UPDATE Characters SET healthitems = '"
              + data.getThePlayer().getHealItems()
              + "'  WHERE characterid = '"
              + data.getThePlayer().getCharacterID()
              + "'");
      stmtUser.execute(
          "UPDATE Characters SET zeni = '"
              + data.getThePlayer().getMoney()
              + "'  WHERE characterid = '"
              + data.getThePlayer().getCharacterID()
              + "'");
      // while(character.next())
      // {
      // int health = character.getInt(1);
      // }
    } catch (Exception e) {
      System.out.println(e);
    }

    return data;
  }