/** * Removes an item from this player's bag * * @param number * @param quantity */ public void removeItem(int number, int quantity) { for (int i = 0; i < m_items.size(); i++) { if (m_items.get(i) != null && m_items.get(i).getNumber() == number) { if (m_items.get(i).getQuantity() - quantity > 0) { m_items.get(i).setQuantity(m_items.get(i).getQuantity() - quantity); if (GameClient.getInstance().getUi().getBag() != null) GameClient.getInstance().getUi().getBag().removeItem(number, false); } else { m_items.remove(i); if (GameClient.getInstance().getUi().getBag() != null) GameClient.getInstance().getUi().getBag().removeItem(number, true); } return; } } }
/** * Adds an item to this player's bag (automatically handles if its in the bag already) * * @param number * @param quantity */ public void addItem(int number, int quantity) { boolean exists = false; for (int i = 0; i < m_items.size(); i++) { if (m_items.get(i) != null && m_items.get(i).getNumber() == number) { m_items.get(i).setQuantity(m_items.get(i).getQuantity() + quantity); exists = true; if (GameClient.getInstance().getUi().getBag() != null) GameClient.getInstance().getUi().getBag().addItem(number, false); } } if (!exists) { m_items.add(new PlayerItem(number, quantity)); if (GameClient.getInstance().getUi().getBag() != null) GameClient.getInstance().getUi().getBag().addItem(number, true); } }
/** * Swaps two pokemon * * @param Poke1 * @param Poke2 */ public void swapPokemon(int Poke1, int Poke2) { OurPokemon temp1 = m_pokemon[Poke1]; m_pokemon[Poke1] = m_pokemon[Poke2]; m_pokemon[Poke2] = temp1; GameClient.getInstance().getUi().refreshParty(); }