Ejemplo n.º 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;
  }
Ejemplo n.º 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;
  }
Ejemplo n.º 3
0
 protected static float winrate(int value) {
   return (float) ByteUtils.decodeFirst(value) / ByteUtils.decodeSecond(value);
 }
Ejemplo n.º 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);
  }
Ejemplo n.º 5
0
 private boolean rankMismatch(byte rank, long key) {
   return rank != ByteUtils.decodeByte(key, 0);
 }
Ejemplo n.º 6
0
 private boolean champMismatch(byte champId, long key) {
   return champId != ByteUtils.decodeByte(key, 1);
 }
Ejemplo n.º 7
0
 private void populate(int value, KeyValueResult result) {
   result.setGamesPlayed(ByteUtils.decodeSecond(value));
   result.setAdaptive(winrate(value));
 }