Skip to content

Commit

Permalink
better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Nov 29, 2024
1 parent 81b2510 commit 8df2ba9
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/inventory/transaction/InventoryTransaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,16 @@ protected function matchItems(array &$needItems, array &$haveItems) : void{
$this->computeDiff($needItems, $haveItems);

if(count($boundLockedNeedItems) > 0 || count($boundLockedHaveItems) > 0){
//first, try to balance bound locked items with items already bound to the player's inventory
//try to balance bound locked items with items already bound to the player's inventory
$this->computeDiff($boundLockedNeedItems, $boundLockedHaveItems);
//then, check if there are unbound locked items the player moved into its inventory
if(count($boundLockedHaveItems) > 0){
throw new TransactionValidationException("Player tried to remove locked items from their inventory");
}

//check if there are unbound locked items the player moved into its inventory
//this allows moving locked items from e.g. a chest -> player's inventory, but not the other way round
$this->computeDiff($boundLockedNeedItems, $haveItems);

array_push($needItems, ...$boundLockedNeedItems);
array_push($haveItems, ...$boundLockedHaveItems);
}
}

Expand Down

0 comments on commit 8df2ba9

Please sign in to comment.