Package com.l2jfrozen.gameserver.templates

Examples of com.l2jfrozen.gameserver.templates.StatsSet


      while(rset.next())
      {
        int charObjId = rset.getInt("char_obj_id");

        StatsSet sevenDat = new StatsSet();
        sevenDat.set("char_obj_id", charObjId);
        sevenDat.set("cabal", rset.getString("cabal"));
        sevenDat.set("seal", rset.getInt("seal"));
        sevenDat.set("red_stones", rset.getInt("red_stones"));
        sevenDat.set("green_stones", rset.getInt("green_stones"));
        sevenDat.set("blue_stones", rset.getInt("blue_stones"));
        sevenDat.set("ancient_adena_amount", rset.getDouble("ancient_adena_amount"));
        sevenDat.set("contribution_score", rset.getDouble("contribution_score"));

        if(Config.DEBUG)
        {
          _log.info("SevenSigns: Loaded data from DB for char ID " + charObjId + " (" + sevenDat.getString("cabal") + ")");
        }

        _signsPlayerData.put(charObjId, sevenDat);
      }
View Full Code Here


  public int setPlayerInfo(L2PcInstance player, int chosenCabal, int chosenSeal)
  {
    int charObjId = player.getObjectId();
    Connection con = null;
    PreparedStatement statement = null;
    StatsSet currPlayerData = getPlayerData(player);

    if(currPlayerData != null)
    {
      // If the seal validation period has passed,
      // cabal information was removed and so "re-register" player
      currPlayerData.set("cabal", getCabalShortName(chosenCabal));
      currPlayerData.set("seal", chosenSeal);

      _signsPlayerData.put(charObjId, currPlayerData);
    }
    else
    {
      currPlayerData = new StatsSet();
      currPlayerData.set("char_obj_id", charObjId);
      currPlayerData.set("cabal", getCabalShortName(chosenCabal));
      currPlayerData.set("seal", chosenSeal);
      currPlayerData.set("red_stones", 0);
      currPlayerData.set("green_stones", 0);
      currPlayerData.set("blue_stones", 0);
      currPlayerData.set("ancient_adena_amount", 0);
      currPlayerData.set("contribution_score", 0);

      _signsPlayerData.put(charObjId, currPlayerData);

      // Update data in database, as we have a new player signing up.
      try
      {
        con = L2DatabaseFactory.getInstance().getConnection(false);
        statement = con.prepareStatement("INSERT INTO seven_signs (char_obj_id, cabal, seal) VALUES (?,?,?)");
        statement.setInt(1, charObjId);
        statement.setString(2, getCabalShortName(chosenCabal));
        statement.setInt(3, chosenSeal);
        statement.execute();

        statement.close();
       

        if(Config.DEBUG)
        {
          _log.info("SevenSigns: Inserted data in DB for char ID " + currPlayerData.getInteger("char_obj_id") + " (" + currPlayerData.getString("cabal") + ")");
        }
      }
      catch(SQLException e)
      {
        if(Config.ENABLE_ALL_EXCEPTIONS)
          e.printStackTrace();
       
        _log.severe("SevenSigns: Failed to save data: " + e);
      }
      finally
      {
        CloseUtil.close(con);
        con = null;
      }
    }

    // Increasing Seal total score for the player chosen Seal.
    if(currPlayerData.getString("cabal") == "dawn")
    {
      _signsDawnSealTotals.put(chosenSeal, _signsDawnSealTotals.get(chosenSeal) + 1);
    }
    else
    {
View Full Code Here

   * @param removeReward the remove reward
   * @return int rewardAmount
   */
  public int getAncientAdenaReward(L2PcInstance player, boolean removeReward)
  {
    StatsSet currPlayer = getPlayerData(player);
    int rewardAmount = currPlayer.getInteger("ancient_adena_amount");

    currPlayer.set("red_stones", 0);
    currPlayer.set("green_stones", 0);
    currPlayer.set("blue_stones", 0);
    currPlayer.set("ancient_adena_amount", 0);

    if(removeReward)
    {
      _signsPlayerData.put(player.getObjectId(), currPlayer);
      saveSevenSignsData(player, true);
View Full Code Here

   * @param redCount the red count
   * @return int contribScore
   */
  public int addPlayerStoneContrib(L2PcInstance player, int blueCount, int greenCount, int redCount)
  {
    StatsSet currPlayer = getPlayerData(player);

    int contribScore = calcContributionScore(blueCount, greenCount, redCount);
    int totalAncientAdena = currPlayer.getInteger("ancient_adena_amount") + calcAncientAdenaReward(blueCount, greenCount, redCount);
    int totalContribScore = currPlayer.getInteger("contribution_score") + contribScore;

    if(totalContribScore > Config.ALT_MAXIMUM_PLAYER_CONTRIB)
      return -1;

    currPlayer.set("red_stones", currPlayer.getInteger("red_stones") + redCount);
    currPlayer.set("green_stones", currPlayer.getInteger("green_stones") + greenCount);
    currPlayer.set("blue_stones", currPlayer.getInteger("blue_stones") + blueCount);
    currPlayer.set("ancient_adena_amount", totalAncientAdena);
    currPlayer.set("contribution_score", totalContribScore);
    _signsPlayerData.put(player.getObjectId(), currPlayer);

    currPlayer = null;

    switch(getPlayerCabal(player))
View Full Code Here

   */
  protected void teleLosingCabalFromDungeons(String compWinner)
  {
    for(L2PcInstance onlinePlayer : L2World.getInstance().getAllPlayers())
    {
      StatsSet currPlayer = getPlayerData(onlinePlayer);

      if(isSealValidationPeriod() || isCompResultsPeriod())
      {
        if(!onlinePlayer.isGM() && onlinePlayer.isIn7sDungeon() && !currPlayer.getString("cabal").equals(compWinner))
        {
          onlinePlayer.teleToLocation(MapRegionTable.TeleportWhereType.Town);
          onlinePlayer.setIsIn7sDungeon(false);
          onlinePlayer.sendMessage("You have been teleported to the nearest town due to the beginning of the Seal Validation period.");
        }
      }
      else
      {
        if(!onlinePlayer.isGM() && onlinePlayer.isIn7sDungeon() && !currPlayer.getString("cabal").equals(""))
        {
          onlinePlayer.teleToLocation(MapRegionTable.TeleportWhereType.Town);
          onlinePlayer.setIsIn7sDungeon(false);
          onlinePlayer.sendMessage("You have been teleported to the nearest town because you have not signed for any cabal.");
        }
View Full Code Here

              {           
                L2MonsterInstance boss_instance = null;
               
                if (boss_template.type.equals("L2RaidBoss"))
                {           
                  StatsSet actual_boss_stat = RaidBossSpawnManager.getInstance().getStatsSet(boss_id);
                  if (actual_boss_stat != null)
                  {               
                    // alive = actual_boss_stat.getLong("respawnTime") == 0;
                    boss_instance = RaidBossSpawnManager.getInstance().getBoss(boss_id);               
                  }           
                }
                else if (boss_template.type.equals("L2GrandBoss"))
                {           
                  StatsSet actual_boss_stat = GrandBossManager.getInstance().getStatsSet(boss_id);
                  if (actual_boss_stat != null)
                  {               
                    // alive = actual_boss_stat.getLong("respawn_time") == 0;
                    boss_instance = GrandBossManager.getInstance().getBoss(boss_id);               
                  }
View Full Code Here

                  {
                    L2MonsterInstance boss_instance = null;
                   
                    if (boss_template.type.equals("L2RaidBoss"))
                    {
                      StatsSet actual_boss_stat = RaidBossSpawnManager.getInstance().getStatsSet(boss_id);
                      if (actual_boss_stat != null)
                      {
                        // alive = actual_boss_stat.getLong("respawnTime") == 0;
                        boss_instance = RaidBossSpawnManager.getInstance().getBoss(boss_id);
                      }
                    }
                    else if (boss_template.type.equals("L2GrandBoss"))
                    {
                      StatsSet actual_boss_stat = GrandBossManager.getInstance().getStatsSet(boss_id);
                      if (actual_boss_stat != null)
                      {
                        // alive = actual_boss_stat.getLong("respawn_time") == 0;
                        boss_instance = GrandBossManager.getInstance().getBoss(boss_id);
                      }
View Full Code Here

        _gpreward = Config.ALT_OLY_CLASSED_RITEM_C;
        classed = "yes";
        break;
    }

    StatsSet playerOneStat = Olympiad.getNobleStats(_playerOne.getObjectId());
    StatsSet playerTwoStat = Olympiad.getNobleStats(_playerTwo.getObjectId());
   
    int playerOnePlayed = playerOneStat.getInteger(COMP_DONE);
    int playerTwoPlayed = playerTwoStat.getInteger(COMP_DONE);
    int playerOneWon = playerOneStat.getInteger(COMP_WON);
    int playerTwoWon = playerTwoStat.getInteger(COMP_WON);
    int playerOneLost = playerOneStat.getInteger(COMP_LOST);
    int playerTwoLost = playerTwoStat.getInteger(COMP_LOST);
    int playerOneDrawn = playerOneStat.getInteger(COMP_DRAWN);
    int playerTwoDrawn = playerTwoStat.getInteger(COMP_DRAWN);
   
    int playerOnePoints = playerOneStat.getInteger(POINTS);
    int playerTwoPoints = playerTwoStat.getInteger(POINTS);
    int pointDiff = Math.min(playerOnePoints, playerTwoPoints) / _div;

    // Check for if a player defaulted before battle started
    if (_playerOneDefaulted || _playerTwoDefaulted)
    {
      if (_playerOneDefaulted)
      {
        int lostPoints = playerOnePoints / 3;
        playerOneStat.set(POINTS, playerOnePoints - lostPoints);
        Olympiad.updateNobleStats(_playerOne.getObjectId(), playerOneStat);
        SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
        sm.addString(_playerOneName);
        sm.addNumber(lostPoints);
        broadcastMessage(sm, false);

        if (Config.DEBUG)
          _log.info("Olympia Result: " + _playerOneName + " lost " + lostPoints + " points for defaulting");
       
        Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,_playerOneName+" default",lostPoints,classed);
      }
      if (_playerTwoDefaulted)
      {
        int lostPoints = playerTwoPoints / 3;
        playerTwoStat.set(POINTS, playerTwoPoints - lostPoints);
        Olympiad.updateNobleStats(_playerTwo.getObjectId(), playerTwoStat);
        SystemMessage sm = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
        sm.addString(_playerTwoName);
        sm.addNumber(lostPoints);
        broadcastMessage(sm, false);

        if (Config.DEBUG)
          _log.info("Olympia Result: " + _playerTwoName + " lost " + lostPoints + " points for defaulting");
       
        Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,_playerTwoName+" default",lostPoints,classed);
      }
      return;
    }
   
    // Create results for players if a player crashed
    if (_pOneCrash || _pTwoCrash)
    {
      if (_pOneCrash && !_pTwoCrash)
      {
        try
        {
          playerOneStat.set(POINTS, playerOnePoints - pointDiff);
          playerOneStat.set(COMP_LOST, playerOneLost + 1);
         
          if (Config.DEBUG)
            _log.info("Olympia Result: " + _playerOneName + " vs " + _playerTwoName + " ... "
                    + _playerOneName + " lost " + pointDiff + " points for crash");
         
          Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,_playerOneName+" crash",pointDiff,classed);
         
          playerTwoStat.set(POINTS, playerTwoPoints + pointDiff);
          playerTwoStat.set(COMP_WON, playerTwoWon + 1);
         
          if (Config.DEBUG)
            _log.info("Olympia Result: " + _playerOneName + " vs " + _playerTwoName + " ... "
                    + _playerTwoName + " Win " + pointDiff + " points");
         
          _sm = new SystemMessage(SystemMessageId.S1_HAS_WON_THE_GAME);
          _sm2 = new SystemMessage(SystemMessageId.S1_HAS_GAINED_S2_OLYMPIAD_POINTS);
          _sm.addString(_playerTwoName);
          broadcastMessage(_sm, true);
          _sm2.addString(_playerTwoName);
          _sm2.addNumber(pointDiff);
          broadcastMessage(_sm2, false);
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
       
      }
      else if (_pTwoCrash && !_pOneCrash)
      {
        try
        {
          playerTwoStat.set(POINTS, playerTwoPoints - pointDiff);
          playerTwoStat.set(COMP_LOST, playerTwoLost + 1);
         
          if (Config.DEBUG)
            _log.info("Olympia Result: " + _playerTwoName + " vs " + _playerOneName + " ... "
                + _playerTwoName + " lost " + pointDiff + " points for crash");
         
          Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,_playerTwoName+" crash",pointDiff,classed);
         
          playerOneStat.set(POINTS, playerOnePoints + pointDiff);
          playerOneStat.set(COMP_WON, playerOneWon + 1);
         
          if (Config.DEBUG)
            _log.info("Olympia Result: " + _playerTwoName + " vs " + _playerOneName + " ... "
                    + _playerOneName + " Win " + pointDiff + " points");
         
          _sm = new SystemMessage(SystemMessageId.S1_HAS_WON_THE_GAME);
          _sm2 = new SystemMessage(SystemMessageId.S1_HAS_GAINED_S2_OLYMPIAD_POINTS);
          _sm.addString(_playerOneName);
          broadcastMessage(_sm, true);
          _sm2.addString(_playerOneName);
          _sm2.addNumber(pointDiff);
          broadcastMessage(_sm2, false);
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
      else if (_pOneCrash && _pTwoCrash)
      {
        try
        {
          playerOneStat.set(POINTS, playerOnePoints - pointDiff);
          playerOneStat.set(COMP_LOST, playerOneLost + 1);
         
          playerTwoStat.set(POINTS, playerTwoPoints - pointDiff);
          playerTwoStat.set(COMP_LOST, playerTwoLost + 1);
         
          if (Config.DEBUG)
            _log.info("Olympia Result: " + _playerOneName + " vs " + _playerTwoName + " ... "
                + " both lost " + pointDiff + " points for crash");
         
          Olympiad.logResult(_playerOneName,_playerTwoName,0D,0D,0,0,"both crash",pointDiff,classed);
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
      playerOneStat.set(COMP_DONE, playerOnePlayed + 1);
      playerTwoStat.set(COMP_DONE, playerTwoPlayed + 1);
     
      Olympiad.updateNobleStats(_playerOne.getObjectId(), playerOneStat);
      Olympiad.updateNobleStats(_playerTwo.getObjectId(), playerTwoStat);
     
      return;
    }
   
    double playerOneHp = 0;
    if (!_playerOne.isDead())
    {
      playerOneHp = _playerOne.getCurrentHp() + _playerOne.getCurrentCp();
    }
   
    double playerTwoHp = 0;
    if (!_playerTwo.isDead())
    {
      playerTwoHp = _playerTwo.getCurrentHp() + _playerTwo.getCurrentCp();
    }
   
    _sm = new SystemMessage(SystemMessageId.S1_HAS_WON_THE_GAME);
    _sm2 = new SystemMessage(SystemMessageId.S1_HAS_GAINED_S2_OLYMPIAD_POINTS);
    _sm3 = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
   
    String result = "";
   
    String winner = "draw";
   
    if (_playerOne == null && _playerTwo == null)
    {
      playerOneStat.set(COMP_DRAWN, playerOneDrawn + 1);
      playerTwoStat.set(COMP_DRAWN, playerTwoDrawn + 1);
      result = " tie";
      _sm = new SystemMessage(SystemMessageId.THE_GAME_ENDED_IN_A_TIE);
      broadcastMessage(_sm, true);
    }
    else if (_playerTwo == null
            || _playerTwo.isOnline() == 0
            || (playerTwoHp == 0 && playerOneHp != 0)
            || (_damageP1 > _damageP2 && playerTwoHp != 0 && playerOneHp != 0))
    {
      playerOneStat.set(POINTS, playerOnePoints + pointDiff);
      playerTwoStat.set(POINTS, playerTwoPoints - pointDiff);
      playerOneStat.set(COMP_WON, playerOneWon + 1);
      playerTwoStat.set(COMP_LOST, playerTwoLost + 1);
     
      _sm.addString(_playerOneName);
      broadcastMessage(_sm, true);
      _sm2.addString(_playerOneName);
      _sm2.addNumber(pointDiff);
      broadcastMessage(_sm2, false);
      _sm3.addString(_playerTwoName);
      _sm3.addNumber(pointDiff);
      broadcastMessage(_sm3, false);
      winner = _playerOneName + " won";
     
      try
      {
        result = " (" + playerOneHp + "hp vs " + playerTwoHp + "hp - "
                + _damageP1 + "dmg vs " + _damageP2 + "dmg) "
                + _playerOneName + " win " + pointDiff + " points";
        L2ItemInstance item = _playerOne.getInventory().addItem("Olympiad", Config.ALT_OLY_BATTLE_REWARD_ITEM, _gpreward, _playerOne, null);
        InventoryUpdate iu = new InventoryUpdate();
        iu.addModifiedItem(item);
        _playerOne.sendPacket(iu);
       
        SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
        sm.addItemName(item.getItemId());
        sm.addNumber(_gpreward);
        _playerOne.sendPacket(sm);
      }
      catch (Exception e)
      {
      }
    }
    else if (_playerOne == null
            || _playerOne.isOnline() == 0
            || (playerOneHp == 0 && playerTwoHp != 0)
            || (_damageP2 > _damageP1 && playerOneHp != 0 && playerTwoHp != 0))
    {
      playerTwoStat.set(POINTS, playerTwoPoints + pointDiff);
      playerOneStat.set(POINTS, playerOnePoints - pointDiff);
      playerTwoStat.set(COMP_WON, playerTwoWon + 1);
      playerOneStat.set(COMP_LOST, playerOneLost + 1);
     
      _sm.addString(_playerTwoName);
      broadcastMessage(_sm, true);
      _sm2.addString(_playerTwoName);
      _sm2.addNumber(pointDiff);
      broadcastMessage(_sm2, false);
      _sm3.addString(_playerOneName);
      _sm3.addNumber(pointDiff);
      broadcastMessage(_sm3, false);
      winner = _playerTwoName + " won";
     
      try
      {
        result = " (" + playerOneHp + "hp vs " + playerTwoHp + "hp - "
                + _damageP1 + "dmg vs " + _damageP2 + "dmg) "
                + _playerTwoName + " win " + pointDiff + " points";
        L2ItemInstance item = _playerTwo.getInventory().addItem("Olympiad", Config.ALT_OLY_BATTLE_REWARD_ITEM, _gpreward, _playerTwo, null);
        InventoryUpdate iu = new InventoryUpdate();
        iu.addModifiedItem(item);
        _playerTwo.sendPacket(iu);
       
        SystemMessage sm = new SystemMessage(SystemMessageId.EARNED_S2_S1_S);
        sm.addItemName(item.getItemId());
        sm.addNumber(_gpreward);
        _playerTwo.sendPacket(sm);
      }
      catch (Exception e)
      {
      }
    }
    else
    {
      result = " tie";
      _sm = new SystemMessage(SystemMessageId.THE_GAME_ENDED_IN_A_TIE);
      broadcastMessage(_sm, true);
      int pointOneDiff = playerOnePoints / 5;
       int pointTwoDiff = playerTwoPoints / 5;
       playerOneStat.set(POINTS, playerOnePoints - pointOneDiff);
       playerTwoStat.set(POINTS, playerTwoPoints - pointTwoDiff);
       playerOneStat.set(COMP_DRAWN, playerOneDrawn + 1);
      playerTwoStat.set(COMP_DRAWN, playerTwoDrawn + 1);
      _sm2 = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
       _sm2.addString(_playerOneName);
       _sm2.addNumber(pointOneDiff);
       broadcastMessage(_sm2, false);
       _sm3 = new SystemMessage(SystemMessageId.S1_HAS_LOST_S2_OLYMPIAD_POINTS);
       _sm3.addString(_playerTwoName);
       _sm3.addNumber(pointTwoDiff);
       broadcastMessage(_sm3, false);
    }
   
    if (Config.DEBUG)
      _log.info("Olympia Result: " + _playerOneName + " vs " + _playerTwoName + " ... " + result);
   
    playerOneStat.set(COMP_DONE, playerOnePlayed + 1);
    playerTwoStat.set(COMP_DONE, playerTwoPlayed + 1);
   
    Olympiad.updateNobleStats(_playerOne.getObjectId(), playerOneStat);
    Olympiad.updateNobleStats(_playerTwo.getObjectId(), playerTwoStat);
   
    Olympiad.logResult(_playerOneName, _playerTwoName, playerOneHp, playerTwoHp, _damageP1, _damageP2, winner, pointDiff, classed);
View Full Code Here

    writeH(0x23);
    writeD(_heroList.size());
   
    for(Integer heroId : _heroList.keySet())
    {
            StatsSet hero = _heroList.get(heroId);
      writeS(hero.getString(Olympiad.CHAR_NAME));
      writeD(hero.getInteger(Olympiad.CLASS_ID));
      writeS(hero.getString(Hero.CLAN_NAME, ""));
      writeD(hero.getInteger(Hero.CLAN_CREST, 0));
      writeS(hero.getString(Hero.ALLY_NAME, ""));
      writeD(hero.getInteger(Hero.ALLY_CREST, 0));
      writeD(hero.getInteger(Hero.COUNT));
    }
   
  }
View Full Code Here

      return false;
    }
   
    if (!_nobles.containsKey(noble.getObjectId()))
    {
      StatsSet statDat = new StatsSet();
      statDat.set(CLASS_ID, noble.getClassId().getId());
      statDat.set(CHAR_NAME, noble.getName());
      statDat.set(POINTS, DEFAULT_POINTS);
      statDat.set(COMP_DONE, 0);
      statDat.set(COMP_WON, 0);
      statDat.set(COMP_LOST, 0);
      statDat.set(COMP_DRAWN, 0);
      statDat.set("to_save", true);
     
      _nobles.put(noble.getObjectId(), statDat);
    }
   
    if (classBased && getNoblePoints(noble.getObjectId()) < 3)
View Full Code Here

TOP

Related Classes of com.l2jfrozen.gameserver.templates.StatsSet

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.