Package fr.neatmonster.nocheatplus.utilities

Examples of fr.neatmonster.nocheatplus.utilities.ActionFrequency.update()


    if (freq == null){
      freq = new ActionFrequency(nBuckets, durBucket);
      entries.put(key, freq);
      return 0.0f;
    }
    freq.update(ts);
    float score = Math.min(1.0f, freq.score(factor));
    freq.add(ts, 1.0f);
    return score;
  }
 
View Full Code Here


   * Test adding 1 such that each bucket gets filled with an equal total amount.
   * @param time Point of time from which to start.
   */
  public void addFromTime(long time){
    ActionFrequency freq = new ActionFrequency(3, 333);
    freq.update(time);
    for (int i = 0; i < 999; i++){
      freq.add(time + i, 1f);
      // TODO: maybe test sums here already.
    }
    if (freq.score(1f) != 999) fail("Sum should be 999, got instead: " + freq.score(1f));
View Full Code Here

    for (int i = 0; i < 999; i++){
      freq.add(time + i, 1f);
      // TODO: maybe test sums here already.
    }
    if (freq.score(1f) != 999) fail("Sum should be 999, got instead: " + freq.score(1f));
    freq.update(time + 999);
    if (freq.score(1f) != 666f) fail("Sum should be 666, got instead: " + freq.score(1f));
    freq.update(time + 1332);
    if (freq.score(1f) != 333f) fail("Sum should be 333, got instead: " + freq.score(1f));
    freq.update(time + 1665);
    if (freq.score(1f) != 0f) fail("Sum should be 0, got instead: " + freq.score(1f));
View Full Code Here

      // TODO: maybe test sums here already.
    }
    if (freq.score(1f) != 999) fail("Sum should be 999, got instead: " + freq.score(1f));
    freq.update(time + 999);
    if (freq.score(1f) != 666f) fail("Sum should be 666, got instead: " + freq.score(1f));
    freq.update(time + 1332);
    if (freq.score(1f) != 333f) fail("Sum should be 333, got instead: " + freq.score(1f));
    freq.update(time + 1665);
    if (freq.score(1f) != 0f) fail("Sum should be 0, got instead: " + freq.score(1f));
  }
 
View Full Code Here

    if (freq.score(1f) != 999) fail("Sum should be 999, got instead: " + freq.score(1f));
    freq.update(time + 999);
    if (freq.score(1f) != 666f) fail("Sum should be 666, got instead: " + freq.score(1f));
    freq.update(time + 1332);
    if (freq.score(1f) != 333f) fail("Sum should be 333, got instead: " + freq.score(1f));
    freq.update(time + 1665);
    if (freq.score(1f) != 0f) fail("Sum should be 0, got instead: " + freq.score(1f));
  }
 
  @Test
  public void testUpdateAlternatingSignumTimes(){
View Full Code Here

  public void testUpdateAlternatingSignumTimes(){
    // Basically fails if this generates an exception.
    int sig = 1;
    ActionFrequency freq = new ActionFrequency(10, 100);
    for (int i = 0; i < 1000; i++){
      freq.update(i * sig);
      sig = sig * -1;
    }
  }

}
 
View Full Code Here

        // Skip if is too close to the startup time.
        if (now - TickTask.getTimeStart() < cc.loginsStartupDelay) return false;
        // Split into 6 buckets always.
        final long durBucket = 1000L * cc.loginsSeconds / 6;
        final ActionFrequency freq = getActionFrequency(player.getWorld().getName(), 6, durBucket, cc.loginsPerWorldCount);
        freq.update(now);
        final boolean cancel = freq.score(1f) > cc.loginsLimit; // TODO: >= ...  This will be 1 after the first login (!).
        if (!cancel) freq.add(1f);
        return cancel;
    }

View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.