public void testMaxSizeSetAsExtras() {
    builder.withMaxSize(400, 300);

    Intent intent = builder.getIntent(activity);

    assertThat(intent.getIntExtra("max_x", 0)).isEqualTo(400);
    assertThat(intent.getIntExtra("max_y", 0)).isEqualTo(300);
  }
  public void testAspectRatioSetAsExtras() {
    builder.withAspect(16, 10);

    Intent intent = builder.getIntent(activity);

    assertThat(intent.getIntExtra("aspect_x", 0)).isEqualTo(16);
    assertThat(intent.getIntExtra("aspect_y", 0)).isEqualTo(10);
  }
  public void testFixedAspectRatioSetAsExtras() {
    builder.asSquare();

    Intent intent = builder.getIntent(activity);

    assertThat(intent.getIntExtra("aspect_x", 0)).isEqualTo(1);
    assertThat(intent.getIntExtra("aspect_y", 0)).isEqualTo(1);
  }
  public void testBuildsIntentWithMultipleOptions() {
    builder.asSquare().withMaxSize(200, 200);

    Intent intent = builder.getIntent(activity);

    assertThat(intent.getIntExtra("aspect_x", 0)).isEqualTo(1);
    assertThat(intent.getIntExtra("aspect_y", 0)).isEqualTo(1);
    assertThat(intent.getIntExtra("max_x", 0)).isEqualTo(200);
    assertThat(intent.getIntExtra("max_y", 0)).isEqualTo(200);
  }
Beispiel #5
0
 public String status() {
   return "Crop Type: "
       + cropType.getName()
       + "\nCrop in Fields: "
       + cropField
       + "\n Grow Status: "
       + cropType.getStatus()
       + "\nCrop in Storage: "
       + cropInventory;
 }
  @Override
  public void setUp() throws Exception {
    super.setUp();
    activity = mock(Activity.class);
    when(activity.getPackageName()).thenReturn("com.example");

    builder = Crop.of(Uri.parse("image:input"), Uri.parse("image:output"));
  }
Beispiel #7
0
  @Override
  public void update(Observable o, Object arg) {
    // TODO Auto-generated method stub
    Calendar c = (Calendar) o;

    // Decay Current Inventory
    cropInventory *= 1 - cropType.decayRate(c.getSeason());

    // Check New Month
    // Only Attempt to Educate on new Months
    if (c.newMonth()) {
      educate();
    }

    // Must Start Planting Crop
    if (cropField <= 0) {

      cropField = 0;
      cropType.startPlanting();
      cropField += maxCrop() * cropType.plantRate(c.getSeason()) * productivity();
    }
    // Still Need to Plant
    else if (cropField < maxCrop() && !cropType.hasGrown()) {
      cropField += maxCrop() * cropType.plantRate(c.getSeason()) * productivity();
    }
    // Need to Grow
    else if (!cropType.hasGrown()) {
      cropType.growingDay(c.getSeason());
    }
    // Need to Harvest
    else {
      double amount = (maxCrop() * cropType.harvestRate(c.getSeason()) * productivity());
      System.out.println("Amount : " + amount);
      System.out.println("Harvest Rate: " + cropType.harvestRate(c.getSeason()));
      System.out.println("Season : " + c.getSeason());
      cropField -= amount;
      cropInventory += amount;
    }
  }
  public void testOutputUriSetAsExtra() {
    Intent intent = builder.getIntent(activity);
    Uri output = intent.getParcelableExtra(MediaStore.EXTRA_OUTPUT);

    assertThat(output.toString()).isEqualTo("image:output");
  }
 public void testInputUriSetAsData() {
   ANDROID.assertThat(builder.getIntent(activity)).hasData("image:input");
 }
Beispiel #10
0
 private int maxCrop() {
   /** TODO Incorporate Technology */
   return (int) ((0.5 + fields.size()) * cropType.getDensity());
 }
  @Override
  protected void runImpl() {
    if (_items == null) return;

    L2PcInstance player = getClient().getActiveChar();
    if (player == null) return;

    L2Object manager = player.getCurrentFolkNPC();
    if (!(manager instanceof L2ManorManagerInstance)) return;

    if (!player.isInsideRadius(manager, L2Npc.INTERACTION_DISTANCE, false, false)) return;

    int castleId = ((L2ManorManagerInstance) manager).getCastle().getCastleId();

    // Calculate summary values
    int slots = 0;
    int weight = 0;

    for (Crop i : _items) {
      if (!i.getCrop()) continue;

      Item template = ItemTable.getInstance().getTemplate(i.getReward());
      weight += i.getCount() * template.getWeight();

      if (!template.isStackable()) slots += i.getCount();
      else if (player.getInventory().getItemByItemId(i.getItemId()) == null) slots++;
    }

    if (!player.getInventory().validateWeight(weight)) {
      sendPacket(SystemMessage.getSystemMessage(SystemMessageId.WEIGHT_LIMIT_EXCEEDED));
      return;
    }

    if (!player.getInventory().validateCapacity(slots)) {
      sendPacket(SystemMessage.getSystemMessage(SystemMessageId.SLOTS_FULL));
      return;
    }

    // Proceed the purchase
    for (Crop i : _items) {
      if (i.getReward() == 0) continue;

      int fee = i.getFee(castleId); // fee for selling to other manors

      int rewardPrice = ItemTable.getInstance().getTemplate(i.getReward()).getReferencePrice();
      if (rewardPrice == 0) continue;

      int rewardItemCount = i.getPrice() / rewardPrice;
      if (rewardItemCount < 1) {
        player.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.FAILED_IN_TRADING_S2_OF_CROP_S1)
                .addItemName(i.getItemId())
                .addItemNumber(i.getCount()));
        continue;
      }

      if (player.getAdena() < fee) {
        player.sendPacket(
            SystemMessage.getSystemMessage(SystemMessageId.FAILED_IN_TRADING_S2_OF_CROP_S1)
                .addItemName(i.getItemId())
                .addItemNumber(i.getCount()));
        player.sendPacket(SystemMessageId.YOU_NOT_ENOUGH_ADENA);
        continue;
      }

      // check if player have correct items count
      ItemInstance item = player.getInventory().getItemByObjectId(i.getObjectId());
      if (item == null || item.getCount() < i.getCount()) continue;

      // try modify castle crop
      if (!i.setCrop()) continue;

      if (fee > 0 && !player.reduceAdena("Manor", fee, manager, true)) continue;

      if (!player.destroyItem("Manor", i.getObjectId(), i.getCount(), manager, true)) continue;

      player.addItem("Manor", i.getReward(), rewardItemCount, manager, true);
    }
  }