Skip to content

Commit 329d306

Browse files
committed
Prevent quantity from going to zero
1 parent 561ef83 commit 329d306

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/character/trappings/detail/QuantityBar.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fun QuantityBar(
4141
value = quantity,
4242
onIncrement = { onQuantityChange(trapping.quantity + 1) },
4343
onDecrement = {
44-
if (quantity > 0) {
44+
if (quantity > 1) {
4545
onQuantityChange(quantity - 1)
4646
}
4747
}

common/src/commonMain/kotlin/cz/frantisekmasa/wfrp_master/common/core/domain/trappings/InventoryItem.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ data class InventoryItem(
2525
@Contextual val containerId: InventoryItemId? = null,
2626
val trappingType: TrappingType? = null,
2727
) : CharacterItem<InventoryItem, Nothing> {
28+
29+
init {
30+
require(quantity > 0) { "Quantity must be greater than 0" }
31+
}
32+
2833
companion object {
2934
const val NAME_MAX_LENGTH = 50
3035
const val DESCRIPTION_MAX_LENGTH = 200

0 commit comments

Comments
 (0)