|
|
|
@ -1254,6 +1254,14 @@ public class CharacterItemManager {
@@ -1254,6 +1254,14 @@ public class CharacterItemManager {
|
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
} else if (i.getItemBase().getType().equals(ItemType.RESOURCE)) { |
|
|
|
|
if(this.inventoryContainsResource(i)){ |
|
|
|
|
Item resource = getResource(i); |
|
|
|
|
if(resource != null){ |
|
|
|
|
resource.setNumOfItems(resource.getNumOfItems() + i.getNumOfItems()); |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.inventory.add(i); |
|
|
|
@ -1261,6 +1269,22 @@ public class CharacterItemManager {
@@ -1261,6 +1269,22 @@ public class CharacterItemManager {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private boolean inventoryContainsResource(Item resource) { |
|
|
|
|
for(Item i : this.inventory){ |
|
|
|
|
if(i.getItemBaseID() == resource.getItemBaseID()) |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private Item getResource(Item resource) { |
|
|
|
|
for(Item i : this.inventory){ |
|
|
|
|
if(i.getItemBaseID() == resource.getItemBaseID()) |
|
|
|
|
return i; |
|
|
|
|
} |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//called for adding gold of a specified amount
|
|
|
|
|
public synchronized boolean addItemToInventory(Item i, int amount) { |
|
|
|
|
if (i.getItemBase().getType().equals(ItemType.GOLD)) |
|
|
|
|