예제 #1
0
  private KeyValueResult satisfies(long key, int itemCount, byte[] items) {
    int count = 0;

    for (int itemIndex = 0; itemIndex < items.length; itemIndex++) {
      byte item = items[itemIndex];
      boolean found = false;
      for (int i = 0; i < 6; i++) {
        byte itemFound = ByteUtils.decodeByte(key, 2 + i);
        if (itemFound == Constants.ANY_ITEM_INDEX) {
          continue;
        }

        if (itemIndex == 0 && count++ > itemCount) {
          return null;
        }

        if (itemFound == item) {
          found = true;
        }
      }

      if (!found) {
        return null;
      }
    }

    if (count != itemCount) {
      return null;
    }

    KeyValueResult result = new KeyValueResult();
    ByteUtils.decode(key, result.key);
    return result;
  }
예제 #2
0
  private KeyValueResult satisfies(long key, int itemCount) {
    int count = 0;

    for (int i = 0; i < 6; i++) {
      byte itemFound = ByteUtils.decodeByte(key, 2 + i);
      if (itemFound == Constants.ANY_ITEM_INDEX) {
        continue;
      }

      if (count++ > itemCount) {
        return null;
      }
    }

    if (count != itemCount) {
      return null;
    }

    KeyValueResult result = new KeyValueResult();
    ByteUtils.decode(key, result.key);
    return result;
  }
예제 #3
0
 protected static float winrate(int value) {
   return (float) ByteUtils.decodeFirst(value) / ByteUtils.decodeSecond(value);
 }
예제 #4
0
  private int getValue(byte rank, byte champId, byte[] items) {
    long key =
        ByteUtils.encode(rank, champId, items[0], items[1], items[2], items[3], items[4], items[5]);

    return stats.get(key, Integer.MAX_VALUE);
  }
예제 #5
0
 private boolean rankMismatch(byte rank, long key) {
   return rank != ByteUtils.decodeByte(key, 0);
 }
예제 #6
0
 private boolean champMismatch(byte champId, long key) {
   return champId != ByteUtils.decodeByte(key, 1);
 }
예제 #7
0
 private void populate(int value, KeyValueResult result) {
   result.setGamesPlayed(ByteUtils.decodeSecond(value));
   result.setAdaptive(winrate(value));
 }