Example #1
0
  public void moveKinah(Player player, Storage source, int splitAmount) {
    if (source.getKinahItem().getItemCount() < splitAmount) return;

    switch (source.getStorageType()) {
      case 0:
        {
          Storage destination = player.getStorage(StorageType.ACCOUNT_WAREHOUSE.getId());
          int chksum =
              (source.getKinahItem().getItemCount() - splitAmount)
                  + (destination.getKinahItem().getItemCount() + splitAmount);

          if (chksum
              != source.getKinahItem().getItemCount() + destination.getKinahItem().getItemCount())
            return;

          source.decreaseKinah(splitAmount);
          destination.increaseKinah(splitAmount);
          break;
        }

      case 2:
        {
          Storage destination = player.getStorage(StorageType.CUBE.getId());
          int chksum =
              (source.getKinahItem().getItemCount() - splitAmount)
                  + (destination.getKinahItem().getItemCount() + splitAmount);

          if (chksum
              != source.getKinahItem().getItemCount() + destination.getKinahItem().getItemCount())
            return;

          source.decreaseKinah(splitAmount);
          destination.increaseKinah(splitAmount);
          break;
        }
      default:
        break;
    }
  }