From b9cbe6b13930462532f5d817c97b713090043181 Mon Sep 17 00:00:00 2001 From: Rayfish <32227259+JackFisherUCLan@users.noreply.github.com> Date: Mon, 3 Jun 2019 12:49:13 +0100 Subject: [PATCH 1/2] Check if ItemContainer contains all items from IntArray Very small addition, lets you pass an IntArray of item IDs, will return true if container contains all items, false if not. --- .../gg/rsmod/game/model/container/ItemContainer.kt | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/game/src/main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt b/game/src/main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt index 98e15aae7b..b4523646dc 100644 --- a/game/src/main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt +++ b/game/src/main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt @@ -52,6 +52,18 @@ class ItemContainer(val definitions: DefinitionSet, val key: ContainerKey) : Ite */ fun contains(item: Int): Boolean = items.any { it?.id == item } + /** + * Check if the container contains all [Item]s in + */ + fun contains(itemArray: IntArray): Boolean { + itemArray.forEach { item -> + if (!items.any { it?.id == item }) { + return false + } + } + return true + } + /** * Checks if the container has an [Item] which has the same [Item.id] as * [item] or any of the values (if any) in [others]. From eb85e62edaa7a6bad2bcecabf0d724dc0cf4f6f1 Mon Sep 17 00:00:00 2001 From: Rayfish <32227259+JackFisherUCLan@users.noreply.github.com> Date: Mon, 3 Jun 2019 12:52:04 +0100 Subject: [PATCH 2/2] Update ItemContainer.kt --- .../main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/src/main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt b/game/src/main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt index b4523646dc..a5f06f8f67 100644 --- a/game/src/main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt +++ b/game/src/main/kotlin/gg/rsmod/game/model/container/ItemContainer.kt @@ -53,7 +53,7 @@ class ItemContainer(val definitions: DefinitionSet, val key: ContainerKey) : Ite fun contains(item: Int): Boolean = items.any { it?.id == item } /** - * Check if the container contains all [Item]s in + * Check if the container contains all [Item]s in [itemArray]. */ fun contains(itemArray: IntArray): Boolean { itemArray.forEach { item ->