private void plot(Graphics2D g, Material material, Shape shape, boolean subdued) {
    final Stroke savedStroke = g.getStroke();
    g.setStroke(plotStroke);
    double yTensile = Inventory.tensileStrength(material, shape);
    final int iy = yPlotAreaBottom - (int) Math.round((yTensile / yMax) * heightPlotArea);
    g.setColor(subdued ? subduedBlue : Color.BLUE);
    g.drawLine(xPlotAreaLeft, iy, xPlotAreaRight, iy);

    final int nPlotPoints = 32;
    double yCompressive = Inventory.compressiveStrength(material, shape, 0.0);
    int iy0 = yPlotAreaBottom - (int) Math.round((yCompressive / yMax) * heightPlotArea);
    int ix0 = xPlotAreaLeft;
    g.setColor(subdued ? subduedRed : Color.RED);
    for (int i = 1; i <= nPlotPoints; i++) {
      double t = (double) i / nPlotPoints;
      double x = t * xMax;
      int ix1 = xPlotAreaLeft + (int) Math.round(t * widthPlotArea);
      yCompressive = Inventory.compressiveStrength(material, shape, x);
      int iy1 = yPlotAreaBottom - (int) Math.round((yCompressive / yMax) * heightPlotArea);
      g.drawLine(ix0, iy0, ix1, iy1);
      ix0 = ix1;
      iy0 = iy1;
    }
    g.setStroke(savedStroke);
    g.setColor(Color.BLACK);
  }
Example #2
0
  public void addItem(float x, float y) throws SlickException {
    int j = random.nextInt(2);
    switch (j) {
      case 0:
        HealthPack HP = new HealthPack(20);
        items.addHealthPack(HP);
        HP.initItem();
        HP.setPosition((int) x, (int) y);
        break;
      case 1:
        int k = random.nextInt(10) + 1;
        if (k < 7) {
          Weapon gun = new Weapon(150, 1000, -10, "Gun");
          items.addWeapon(gun);
          gun.initItem();
          gun.setPosition((int) x, (int) y);

        } else if (k >= 7) {
          Weapon shotGun = new Weapon(70, 1500, -30, "Shotgun");
          items.addWeapon(shotGun);
          shotGun.initItem();
          shotGun.setPosition((int) x, (int) y);
        }
        break;
    }
  }
  // As an owner, I want the entry of an item to have minimal required
  // navigation in the user interface. It must be easy to describe an item.
  public void testGetCategory() {
    ArrayList<GCard> gcards = new ArrayList<GCard>();
    Inventory inv = new Inventory();
    GCard gcard =
        new GCard("Starbucks", 20, 1, 4, "Food & Drink", True, "Will get you half a coffee");
    inv.addCard(gcard);
    GCard gcard2 = new GCard("Cineplex", 50, 75, 5, "Entertainment", False, "I might keep these");
    inv.addCard(gcard2);
    GCard gcard3 =
        new GCard(
            "Subway",
            25,
            1,
            2,
            "Food & Drink",
            True,
            "Wonderful hexcrements ;) (hex increments ~ incrments of 6)");
    inv.addCard(gcard3);

    ArrayList<GCard> outlist = new ArrayList<GCard>();
    for (int i = 0; i < gcards.size(); ++i) {
      if (gcards.get(i).getCategory() == "Food & Drink") {
        outlist.add(gcards.get(i));
      }
    }
    assertTrue(outlist.size() == 2);
  }
Example #4
0
 @Test
 public void executeRemoveItemRemovesItem() {
   Item item = getRegularItem();
   inventory.executeAddItem(InventorySlot.ARMOR, item);
   inventory.executeRemoveItem(item);
   assertTrue(inventory.isEmpty(InventorySlot.ARMOR));
 }
 public void testHasCard() {
   Inventory inv = new Inventory();
   Tweet gcard =
       new GCard("Starbucks", 20, 1, 4, "Food & Drink", True, "Will get you half a coffee");
   inv.addCard(gcard);
   assertTrue(inv.hasCard(gcard));
 }
Example #6
0
 @Test
 public void hasItemFindsItem() {
   Item item = getRegularItem();
   assertFalse(inventory.hasItem(item));
   inventory.executeAddItem(InventorySlot.ARMOR, item);
   assertTrue(inventory.hasItem(item));
 }
  public static void main(String[] args) {
    // Set up Rick's guitar inventory
    Inventory inventory = new Inventory();
    initializeInventory(inventory);

    Guitar whatErinLikes =
        new Guitar("", 0, "fender", "Stratocastor", "electric", "Alder", "Alder");
    Guitar guitar = inventory.search(whatErinLikes);
    if (guitar != null) {
      System.out.println(
          "Erin, you might like this "
              + guitar.getBuilder()
              + " "
              + guitar.getModel()
              + " "
              + guitar.getType()
              + " guitar:\n   "
              + guitar.getBackWood()
              + " back and sides,\n   "
              + guitar.getTopWood()
              + " top.\nYou can have it for only $"
              + guitar.getPrice()
              + "!");
    } else {
      System.out.println("Sorry, Erin, we have nothing for you.");
    }
  }
Example #8
0
  int querySkuDetails(Inventory inv, List<String> moreSkus) throws RemoteException, JSONException {
    ArrayList<String> skuList = new ArrayList<String>();
    skuList.addAll(inv.getAllOwnedSkus(ITEM_TYPE_INAPP));
    if (moreSkus != null) skuList.addAll(moreSkus);

    if (skuList.size() == 0) {
      return BILLING_RESPONSE_RESULT_OK;
    }

    Bundle querySkus = new Bundle();
    querySkus.putStringArrayList(GET_SKU_DETAILS_ITEM_LIST, skuList);
    Bundle skuDetails = connection.getSkuDetails(querySkus);

    if (!skuDetails.containsKey(RESPONSE_GET_SKU_DETAILS_LIST)) {
      int response = getResponseCodeFromBundle(skuDetails);
      if (response != BILLING_RESPONSE_RESULT_OK) {
        return response;
      } else {
        return HELPER_BAD_RESPONSE;
      }
    }

    ArrayList<String> responseList = skuDetails.getStringArrayList(RESPONSE_GET_SKU_DETAILS_LIST);

    for (String thisResponse : responseList) {
      SkuDetails d = new SkuDetails(thisResponse);
      inv.addSkuDetails(d);
    }
    return BILLING_RESPONSE_RESULT_OK;
  }
Example #9
0
  public void a(lg paramlf) {
    // hMod: Check if we can open this
    Inventory inv = null;
    String name = paramlf.b();
    if (paramlf instanceof jb) {
      inv = new Chest((jb) paramlf);
      if ((Boolean) etc.getLoader().callHook(PluginLoader.Hook.OPEN_INVENTORY, getPlayer(), inv)) {
        return;
      }
    } else if (paramlf instanceof av) {
      inv = new DoubleChest((av) paramlf);
      if ((Boolean) etc.getLoader().callHook(PluginLoader.Hook.OPEN_INVENTORY, getPlayer(), inv)) {
        return;
      }
    }

    if (inv != null) {
      name = inv.getName();
    }
    this.lastOpenedInventory = inv;
    R();
    this.a.b(new ih(this.bH, 0, name, paramlf.a()));
    this.ap = new bx(this.an, paramlf);
    this.ap.f = this.bH;
    // hMod: Make sure this gets cast correctly, or mutant puppies will spawn and eat your items.
    this.ap.a((ec) this);
  }
Example #10
0
 @Test
 public void shouldInitialiseEmptyRepository() throws Exception {
   Inventory inventory = new Inventory();
   assertThat(inventory.getAllPurchases()).isEmpty();
   assertThat(inventory.getSkuDetails()).isEmpty();
   assertThat(inventory.getAllOwnedSkus()).isEmpty();
 }
Example #11
0
 public void addItem(Item item) {
   if (item.getClass() == Weapon.class) {
     items.addWeapon((Weapon) item);
   } else if (item.getClass() == Weapon.class) {
     items.addHealthPack((HealthPack) item);
   }
 }
Example #12
0
  @Test
  public void failedTransaction2() throws ExecutionException, InterruptedException {
    Stage stage = createStage();
    Bank bank = Actor.getReference(Bank.class, "jimmy");
    Inventory inventory = Actor.getReference(Inventory.class, "jimmy");
    Store store = Actor.getReference(Store.class, "all");
    bank.increment(15).join();

    fakeSync.put("proceed", "ok");

    // this item is invalid but the bank balance is decreased first.
    store.buyItem(bank, inventory, "candy", 10).join();
    store.buyItem(bank, inventory, "chocolate", 1).join();
    try {
      store.buyItem(bank, inventory, "ice cream", 50).join();
      fail("expecting an exception");
    } catch (CompletionException ex) {
      System.out.println(ex.getCause().getMessage());
    }

    // the bank credits must be restored.
    eventually(() -> assertEquals((Integer) 4, bank.getBalance().join()));
    // no items were given
    eventually(() -> assertEquals(2, inventory.getItems().join().size()));
    dumpMessages();
  }
Example #13
0
  @Before
  public void setUp() throws Exception {
    mazer = new Enemy(06, "Mazer Rackham", 70, 15, 10, w5, 10, hitOutput, tauntEnrage);
    cadet = new Enemy(11, "Cadet", 30, 10, 110, w5, 10, hitOutput, tauntHide);
    bullies =
        new Enemy(01, "Jerry and two of his cohorts", 50, 19, 10, w5, 10, hitOutput, tauntFlee);
    peter = new Enemy(02, "Peter", 40, 10, 10, w5, 10, hitOutput, tauntHide);
    //		dissenter = new Enemy(03, "Dissenter", 40, 12, 10, cBandAid, 10,
    //				hitOutput, tauntStandard);
    //		droid = new Enemy(04, "Hand-to-Hand Combat Droid", 50, 10, 10,
    //				cMorphine, 10, hitOutput, tauntConcentration);
    //		bonzo = new Enemy(05, "Bonzo and two of his buddies", 55, 25, 10,
    //				cBandAid, 10, hitOutput, tauntFlee);
    //		hyrum = new Enemy(07, "Colonel Hyrum Graff", 55, 12, 12, wLaserPistol, 10,
    //				hitOutput, tauntStandard);
    //		vader = new Enemy(08, "Darth Vader", 65, 12, 15, wLightSaber, 20,
    //				hitOutput, tauntStandard);
    //		queen = new Enemy(09, "Formic Queen", 70, 12, 15, cQueenEggs, 20,
    //				hitOutput, tauntWait);
    //		bugs = new Enemy(10, "Bugs", 35, 12, 10, cStimpak, 6, hitOutput, tauntStandard);

    // weapons
    /*		w1 = new Weapon("Weapon 1", "First weapon.", false, 10);
    		w2 = new Weapon("Weapon 2", "Second weapon.", false, 20);
    		w3 = new Weapon("Weapon 3", "Third weapon.", false, 30);
    		w4 = new Weapon("Weapon 4", "Fourth weapon.", false, 40);
    		w5 = new Weapon("Weapon 5", "Fifth weapon.", false, 50);
    */
    // accessories
    a1 = new Accessory("Accessory 1", "First accessory.", false, 1, 1, 1);
    a2 = new Accessory("Accessory 2", "Second accessory.", false, 2, 2, 2);
    a3 = new Accessory("Accessory 3", "Third accessory.", false, 3, 3, 3);
    a4 = new Accessory("Accessory 4", "Fourth accessory.", false, 4, 4, 4);
    a5 = new Accessory("Accessory 5", "Fifth accessory.", false, 5, 5, 5);

    // consumables
    c1 = new Consumable("Consumable 1", "First consumable.", false, 1);
    c2 = new Consumable("Consumable 2", "Second consumable.", false, 2);
    c3 = new Consumable("Consumable 3", "Third consumable.", false, 3);
    c4 = new Consumable("Consumable 4", "Fourth consumable.", false, 4);
    c5 = new Consumable("Consumable 5", "Fifth consumable.", false, 5);
    cNull = new Consumable(null, null, false, 100);

    // key items
    k1 = new Oxygen("O2 Test Key Item 1", "First test key item.", true, false);
    k2 = new Oxygen("O2 Test Key Item 2", "Second test key item.", true, false);
    k3 = new Oxygen("O2 Test Key Item 3", "Third test key item.", true, false);

    // set up test player 1
    inv = new Inventory();
    player = new Player("Test Player", 7, 65, 65, 20, 8, 10, false, false, false, false, inv);
    inv.setOwner(player);

    // set up test player 2
    invNotFound = new Inventory(null, null, null, null, 0);
    playerInvNotFound =
        new Player("Test Player 2", 0, 0, 0, 0, 0, 0, false, false, false, false, invNotFound);
    invNotFound.setOwner(playerInvNotFound);
  }
Example #14
0
  public List<String> getSamples() {
    List<String> samples = new ArrayList<String>();
    for (Inventory inventory : inventories) {
      samples.addAll(Arrays.asList(inventory.getSamples()));
    }

    return samples;
  }
Example #15
0
 @Test
 public void providesSlotLocation() {
   Item item = getRegularItem();
   inventory.executeAddItem(InventorySlot.HEAD, item);
   ItemLocation loc = inventory.getSlotLocation(InventorySlot.HEAD);
   assertNotNull(loc);
   assertSame(item, loc.get());
 }
Example #16
0
 @Test
 public void testAddSkuDetails() throws Exception {
   Inventory inventory = new Inventory();
   SkuDetails details = mock(SkuDetails.class);
   when(details.getSku()).thenReturn("sku1");
   inventory.addSkuDetails(details);
   assertThat(inventory.getSkuDetails()).hasSize(1);
 }
Example #17
0
 /** Verify that the room has the specified item */
 public Item checkItem(String itemName) {
   for (int x = 0; x < items.size(); x++) {
     if (items.get(x).getName().equals(itemName)) {
       return items.get(x);
     }
   }
   return null;
 }
 public PendingStack pending(ItemStack template, boolean creative) {
   if (_pending != null) return null;
   if (creative && !_inventory.allowed(template)) return null;
   if (!creative && !_inventory.has(template)) return null;
   template = template.copy();
   template.stackSize = 1;
   return _pending = new PendingStack(template);
 }
Example #19
0
 @Test
 public void testGetPurchase() throws Exception {
   Inventory inventory = new Inventory();
   Purchase p = mock(Purchase.class);
   when(p.getSku()).thenReturn("sku1");
   inventory.addPurchase(p);
   assertThat(inventory.getPurchase("sku1")).isSameAs(p);
 }
Example #20
0
 // As an owner, I want to view my inventory's details
 public void testGetCount() {
   Inventory inv = new Inventory();
   GCard gcard =
       new GCard("Starbucks", 20, 1, 4, "Food & Drink", True, "Will get you half a coffee");
   inv.addCard(gcard);
   int count = inv.getCount();
   assertTrue(count == 1);
 }
Example #21
0
 // As an owner, I want to remove an item
 // As an owner, I want to delete inventory items
 public void testDelete() {
   Inventory inv = new Inventory();
   GCard gcard =
       new GCard("Starbucks", 20, 1, 4, "Food & Drink", True, "Will get you half a coffee");
   inv.addCard(gcard);
   inv.removeCard(gcard);
   assertFalse(inv.hasCard(gcard));
 }
Example #22
0
  /** **************************Request*********************************************** */
  private void r_submitActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_r_submitActionPerformed

    String result = "";

    if (!invalid(r_empID.getText()) && Integer.parseInt(r_qty.getText()) > 0) {
      if (!(result = Inventory.searchItem(r_itemID.getText())).toLowerCase().contains("not found")
          && Inventory.getQty(r_itemID.getText())
              > Integer.parseInt(r_qty.getText())) // //if item found
      {
        r_msg.setForeground(Color.blue);
        r_msg.setText("Request sent");

        try {
          ////// used to extract item name
          // int i=result.indexOf(" ");
          // int j=result.indexOf("\n");

          String[] seg = result.split("\t");

          if (r_itemName.getText().equals(seg[1])) {
            boolean appr = false;

            if (approvedBox.isSelected()) {
              appr = true;
            }

            new Employee(r_empID.getText())
                .RequestForItem(
                    new ItemInfo(
                        r_itemID.getText(),
                        r_itemName.getText(),
                        Integer.parseInt(r_qty.getText()),
                        Integer.parseInt(r_len.getText())),
                    appr);
          } else {
            throw new IOException();
          }
        } catch (IOException io) {
          io.printStackTrace();

          r_msg.setForeground(Color.red);
          r_msg.setText("Request error (invalid item name)");
        } catch (Exception e) {
          e.printStackTrace();

          r_msg.setForeground(Color.red);
          r_msg.setText("Request error");
        }
      } else {
        r_msg.setForeground(Color.red);
        r_msg.setText("Request error (item not found/invalid duration/other)");
      }
    } else {
      r_msg.setForeground(Color.red);
      r_msg.setText("invalid employee ID");
    }
  } // GEN-LAST:event_r_submitActionPerformed
 @Override
 public void itemsChanged(Inventory inventory) {
   if (inventory.isEmpty()) {
     // TODO: consider how this interacts with the 'type'?
     player.send(new InterfaceResetItemsMessage(id, child));
   } else {
     Item[] items = inventory.toArray();
     player.send(new InterfaceItemsMessage(id, child, type, items));
   }
 }
Example #24
0
 @Test
 public void locationOfItemFindsItem() {
   Item item = getRegularItem();
   inventory.executeAddItem(InventorySlot.HEAD, item);
   ItemLocation loc = inventory.getLocationOf(item);
   assertNotNull(loc);
   assertSame(item, loc.get());
   assertEquals(InventorySlot.HEAD.ordinal(), loc.getIndex());
   assertSame(inventory, loc.getCylinder());
 }
Example #25
0
 public Inventory getInventoryByGermplasmId(String germplasmId) {
   List<Inventory> inventories = getInventories();
   for (Inventory inventory : inventories) {
     if (germplasmId.equals(inventory.getGermplasmId())) {
       return inventory;
     }
   }
   throw new RuntimeException(
       "Inventory not found for germplasm " + germplasmId + " in project " + getProjectId());
 }
Example #26
0
  public void applyInventory(final BattlePlayer p) {
    Inventory i = p.getInventory();

    ItemStack HEALTH_POTION = new ItemStack(Material.POTION, 1, (short) 16373);
    ItemStack IRON_SWORD = new ItemStack(Material.IRON_SWORD, 1);
    ItemStack BOW = new ItemStack(Material.BOW, 1);
    ItemStack IRON_PICKAXE = new ItemStack(Material.IRON_PICKAXE, 1);
    ItemStack STONE_AXE = new ItemStack(Material.STONE_AXE, 1);
    ItemStack LEATHER_CHESTPLATE = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
    ItemStack LEATHER_BOOTS = new ItemStack(Material.LEATHER_BOOTS, 1);
    ItemStack LEATHER_HELMET = new ItemStack(Material.LEATHER_HELMET, 1);
    ItemStack LEATHER_PANTS = new ItemStack(Material.LEATHER_LEGGINGS, 1);
    ItemStack COOKED_PORKCHOP = new ItemStack(Material.COOKED_BEEF, 4);
    ItemStack BIRCH_LOG = new ItemStack(Material.LOG, 64);
    ItemStack ARROW = new ItemStack(Material.ARROW, 64);

    InvUtils.colourArmourAccordingToTeam(
        p, new ItemStack[] {LEATHER_HELMET, LEATHER_CHESTPLATE, LEATHER_BOOTS, LEATHER_PANTS});

    p.getInventory().setBoots(LEATHER_BOOTS);
    p.getInventory().setLeggings(LEATHER_PANTS);
    p.getInventory().setChestplate(LEATHER_CHESTPLATE);
    p.getInventory().setHelmet(LEATHER_HELMET);

    i.setItem(0, IRON_SWORD);
    i.setItem(1, BOW);
    i.setItem(5, HEALTH_POTION);
    i.setItem(2, IRON_PICKAXE);
    i.setItem(3, STONE_AXE);
    i.setItem(5, COOKED_PORKCHOP);
    i.setItem(6, BIRCH_LOG);
    i.setItem(11, ARROW);
  }
Example #27
0
 // As an owner, I want to view my inventory
 // As an owner, I want to view each of my inventory items.
 public void testGetCards() {
   Inventory inv = new Inventory();
   GCard gcard =
       new GCard("Starbucks", 20, 1, 4, "Food & Drink", True, "Will get you half a coffee");
   inv.addCard(gcard);
   GCard gcard2 =
       new GCard("Starbucks", 20, 1, 4, "Food & Drink", True, "Will get you half a coffee");
   inv.addCard(gcard2);
   ArrayList<GCard> gcards2 = inv.getCards();
   assertTrue((gcards2.get(0) == gcard) && (gcards2.get(1) == gcard2));
 }
Example #28
0
 /**
  * Checks if the player is standning on an item.
  *
  * @param x & @param y The position of the player.
  * @return The Item the player is standing on.
  */
 public Item standOnItem(float x, float y) {
   for (Item i : items.getItems()) {
     int[] j = i.getPos();
     if ((j[0] <= x + 5) && (j[0] >= x - 5) && (j[1] <= y + 5) && (j[1] >= y - 5)) {
       items.removeItem(i);
       Game.lootName = i.getName();
       return i;
     }
   }
   return null;
 }
Example #29
0
  /**
   * Set the contents of an ItemArray.
   *
   * @param itemArray
   * @param contents
   */
  public static void setContents(Inventory itemArray, Item[] contents) {
    int size = itemArray.getContentsSize();

    for (int i = 0; i < size; i++) {
      if (contents[i] == null) {
        itemArray.removeItem(i);
      } else {
        itemArray.setSlot(contents[i], i);
      }
    }
  }
Example #30
0
 private boolean hasSingleSelectionInventory() {
   for (Inventory inventory : getInventories()) {
     if (inventory.isSingleSelection()) {
       setProjectError(
           "Project \""
               + getProjectId()
               + "\" has inventory that contains Single Selection , this is not supported\n");
       return true;
     }
   }
   return false;
 }