Package com.wot.shared

Examples of com.wot.shared.AllStatistics


            double totalExpSpot = 0;
            double totalExpDef = 0;
            //int totalExpXp = 0;
            double totalExpWr = 0;
            //
            AllStatistics allStatistics = dataPlayerInfos.getStatistics().getAllStatistics();
           
            int ActualFrag = allStatistics.getFrags();
           
            int ActualDmg = allStatistics.getDamage_dealt() ;
            int ActualSpot = allStatistics.getSpotted() ;
            int ActualDef = allStatistics.getDropped_capture_points() ;
            double ActualWr = Double.valueOf(allStatistics.getWins())/ Double.valueOf(allStatistics.getBattles());
            //
            double rFrag = 0 ;
            double rDmg = 0 ;
            double rSpot = 0 ;
            double rDef = 0 ;
            double rWr = 0;
            //
            double  rFragC = 0 ;
            double rDmgC = 0 ;
            double rSpotC = 0 ;
            double rDefC = 0 ;
            double rWrC = 0;
            //
            double wn8 = 0;
            //---calculate WN8 -----
            for (DataPlayerTankRatings dataPlayerTankRatings : listPlayerTanksRatings) {
              try {
                int tankId= dataPlayerTankRatings.getTank_id();
                int tankBattles =0 ;
               
                  tankBattles = dataPlayerTankRatings.getStatistics().getBattles();
               
                //int wins = dataPlayerTankRatings.getStatistics().getAll().getWins();
                //
                //log.warning("tankId :" + tankId );
                if (tankEncyclopedia.getData().get(String.valueOf(tankId)) == null ) {
                  log.severe ("tankEncyclopedia.getData().get(tankId) is null ");
                  continue;
                }
                else {
                  int levelTank = tankEncyclopedia.getData().get(String.valueOf(tankId)).getLevel();
                  //
                  nbBattles = nbBattles + tankBattles;
                  levelByBattles =levelByBattles + levelTank * tankBattles;
                }
   
                //for each tank do sum of frag, dmg,  spot def, xp, wr
                //In wnEfficientyTank we have the expected values for each tank
                //
                //            for (DataWnEfficientyTank dataWnEfficientyTank : wnEfficientyTank.getData()) {
                //              //dataWnEfficientyTank.
                //             
                //            }
                //for each tank do the sum of frag, dmg,  spot def, xp, wr
                DataWnEfficientyTank dataWnEfficientyTank = hMapWnEfficientyTankHashMap.get(String.valueOf(tankId));
                if (dataWnEfficientyTank != null) {
                  // takes the counts of tanks played on account, and multiplies them by the expected stats to get the account total expected values.
                  totalExpFrag = totalExpFrag + Double.valueOf(dataWnEfficientyTank.getExpFrag()) * tankBattles;
                  totalExpDmg = totalExpDmg + Double.valueOf(dataWnEfficientyTank.getExpDamage()) * tankBattles;
                  totalExpSpot = totalExpSpot + Double.valueOf(dataWnEfficientyTank.getExpSpot()) * tankBattles;
                  totalExpDef = totalExpDef + Double.valueOf(dataWnEfficientyTank.getExpDef()) * tankBattles;
                  totalExpWr = totalExpWr + Double.valueOf(dataWnEfficientyTank.getExpWinRate()) * tankBattles;
                }
             
             
             
                //
                /*
                Very Bad  below 500  below 300
                Bad  500 - 699  300 - 599
                Below Average  700 - 899  600 - 899
                Average  900 - 1099  900 - 1249
                Good  1100 - 1349  1250 - 1599
                Very Good  1350 - 1499  1600 - 1899
                Great  1500 - 1699  1900 - 2349
                Unicum  1700 - 1999  2350 - 2899
                Super Unicum  2000 and above  2900 and above
                */
               
              }catch (Exception e) {
                break ;
             
               
            }//for
           
            //Then the actual account totals (your total dmg, frags, spots, def, win-rate) are divided by the total expected values to give the ratios.
            rFrag = ActualFrag /totalExpFrag ;
            rDmg = ActualDmg /totalExpDmg ;
            rSpot = ActualSpot / totalExpSpot;
            rDef = ActualDef / totalExpDef;
            rWr = ActualWr*100*allStatistics.getBattles() / totalExpWr;//0.50 * 100 = 50
           
            //Step 2 ---
            // sets the zero point for the ratios. See the assumptions section for more info on why this happen.
            //min and max are functions to ensure the ratios stay within bounds. The constants are in the format of
            //(rSTAT � constant) / (1 � constant)
            /*
             *  rWINc    = max(0,                     (rWIN    - 0.71) / (1 - 0.71) )
              rDAMAGEc = max(0,                     (rDAMAGE - 0.22) / (1 - 0.22) )
              rFRAGc   = max(0, min(rDAMAGEc + 0.2, (rFRAG   - 0.12) / (1 - 0.12)))
              rSPOTc   = max(0, min(rDAMAGEc + 0.1, (rSPOT   - 0.38) / (1 - 0.38)))
              rDEFc    = max(0, min(rDAMAGEc + 0.1, (rDEF    - 0.10) / (1 - 0.10)))
             */
           
            rWrC    =   Math.max(0,                     (rWr    - 0.71) / (1 - 0.71) );
            rDmgC =  Math.max(0,                     (rDmg - 0.22) / (1 - 0.22) );
            rFragC   =  Math.max(0, Math.min(rDmgC + 0.2, (rFrag   - 0.12) / (1 - 0.12)));
            rSpotC   =  Math.max(0, Math.min(rDmgC + 0.1, (rSpot   - 0.38) / (1 - 0.38)));
            rDefC    =  Math.max(0, Math.min(rDmgC + 0.1, (rDef    - 0.10) / (1 - 0.10)));
            //
            //Step 3
            //WN8 = 980*rDAMAGEc + 210*rDAMAGEc*rFRAGc + 155*rFRAGc*rSPOTc + 75*rDEFc*rFRAGc + 145*MIN(1.8,rWINc)
            wn8 =   980*rDmgC    + 210*rDmgC*rFragC    + 155*rFragC*rSpotC + 75*rDefC*rFragC + 145*Math.min(1.8,rWrC);
            //
            //
           
            averageLevelTank = levelByBattles/nbBattles;
            //AllStatistics myDataCommunityAccountRatings = dataPlayerInfos.getStatistics().getAllStatistics();
           
            // set wn8
            allStatistics.setWn8(wn8);
           
            //average level tank
            allStatistics.setAverageLevelTankCalc(averageLevelTank);
            //
           
            //== Ratio capture points calculated ================
            int ctfPoints = allStatistics.getCapture_points();
            Double ctfPointsCal = (double) ((double)ctfPoints/(double)allStatistics.getBattles());// 1,28 :1 = 1.28
           
            //on ne conserve que 2 digits après la virgule
            //ctfPointsCal = ctfPointsCal * 100; //ex : 1,2827
            int intCtfPointsCal = (int) (ctfPointsCal * 100); //ex intCtfPointsCal : 128,27 ctfPointsCal = 1.28
           
            ctfPointsCal = (double)intCtfPointsCal / 100 ; //ex ctfPointsCal : 1,28 intCtfPointsCal = 128
            allStatistics.setRatioCtfPoints(ctfPointsCal);
            //======================================================
           
           
            //== Ratio DMG points calculated ================
            int points = allStatistics.getDamage_dealt();
            Double pointsCal = (double) ((double)points/(double)allStatistics.getBattles());// 1,28 :1 = 1.28
           
            //on ne conserve que 2 digits après la virgule
            //ctfPointsCal = ctfPointsCal * 100; //ex : 1,2827
            int intPointsCal = (int) (pointsCal * 100); //ex intCtfPointsCal : 128,27 ctfPointsCal = 1.28
           
            pointsCal = (double)intPointsCal / 100 ; //ex ctfPointsCal : 1,28 intCtfPointsCal = 128
            allStatistics.setRatioDamagePoints(pointsCal);
            //======================================================
           

            //== Ratio Destroyed points calculated ================
            points = allStatistics.getFrags();
            pointsCal = (double) ((double)points/(double)allStatistics.getBattles());// 1,28 :1 = 1.28
           
            //on ne conserve que 2 digits après la virgule
            //ctfPointsCal = ctfPointsCal * 100; //ex : 1,2827
            intPointsCal = (int) (pointsCal * 100); //ex intCtfPointsCal : 128,27 ctfPointsCal = 1.28
           
            pointsCal = (double)intPointsCal / 100 ; //ex ctfPointsCal : 1,28 intCtfPointsCal = 128
            allStatistics.setRatioDestroyedPoints(pointsCal);
            //======================================================

           
            //== Ratio Detected points calculated ================
            points = allStatistics.getSpotted();
            pointsCal = (double) ((double)points/(double)allStatistics.getBattles());// 1,28 :1 = 1.28
           
            //on ne conserve que 2 digits après la virgule
            //ctfPointsCal = ctfPointsCal * 100; //ex : 1,2827
            intPointsCal = (int) (pointsCal * 100); //ex intCtfPointsCal : 128,27 ctfPointsCal = 1.28
           
            pointsCal = (double)intPointsCal / 100 ; //ex ctfPointsCal : 1,28 intCtfPointsCal = 128
            allStatistics.setRatioDetectedPoints(pointsCal);
            //======================================================

           
            //== Ratio Dropped capture points calculated ================
            points = allStatistics.getDropped_capture_points();
            pointsCal = (double) ((double)points/(double)allStatistics.getBattles());// 1,28 :1 = 1.28
           
            //on ne conserve que 2 digits après la virgule
            //ctfPointsCal = ctfPointsCal * 100; //ex : 1,2827
            intPointsCal = (int) (pointsCal * 100); //ex intCtfPointsCal : 128,27 ctfPointsCal = 1.28
           
            pointsCal = (double)intPointsCal / 100 ; //ex ctfPointsCal : 1,28 intCtfPointsCal = 128
            allStatistics.setRatioDroppedCtfPoints(pointsCal);
            //======================================================
           
            //=== Battle_avg_performance win/batttles ====
            //avg perf : ratio wins/battles
            Double perf =  new Double(allStatistics.getWins())/ new Double(allStatistics.getBattles());
            allStatistics.setBattle_avg_performanceCalc(perf);
            //=============================================
           
            if (true){
              //pm = PMF.get().getPersistenceManager();
                  try {
View Full Code Here


   
    //  build return object
    DataPlayerInfos myDataPlayerInfos = new DataPlayerInfos();
    //
    Statistics statistics = new Statistics();
    AllStatistics allStatistics = new AllStatistics();
    myDataPlayerInfos.setStatistics(statistics);
    myDataPlayerInfos.getStatistics().setAllStatistics(allStatistics);
   
    if(data.getStats().getBattle_avg_performanceCalc() != null)
      myDataPlayerInfos.getStatistics().getAllStatistics().setBattle_avg_performanceCalc(data.getStats().getBattle_avg_performanceCalc());
View Full Code Here

TOP

Related Classes of com.wot.shared.AllStatistics

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.