From 9dcad34fc0abded07645f4e9871563d4c1821c81 Mon Sep 17 00:00:00 2001 From: Michael Chekin Date: Sun, 19 Dec 2021 14:42:52 +0100 Subject: [PATCH] Enforce sell-only stores: does not allow selling to sell-only stores (character stores) --- app/Modules/Trade/Domain/Store.php | 5 + .../Domain/Store/StoreDoesNotBuyItems.php | 11 + app/Modules/Trade/Domain/StoreType.php | 5 +- resources/js/components/StoreManagement.vue | 767 +++++++++--------- resources/js/components/StoreTrade.vue | 696 ++++++++-------- 5 files changed, 756 insertions(+), 728 deletions(-) create mode 100644 app/Modules/Trade/Domain/Store/StoreDoesNotBuyItems.php diff --git a/app/Modules/Trade/Domain/Store.php b/app/Modules/Trade/Domain/Store.php index 2a743bc0..cd0490c0 100644 --- a/app/Modules/Trade/Domain/Store.php +++ b/app/Modules/Trade/Domain/Store.php @@ -12,6 +12,7 @@ use App\Modules\Generic\Domain\Container\ContainerSlotOutOfRangeException; use App\Modules\Generic\Domain\Container\ItemNotInContainer; use App\Modules\Generic\Domain\Container\NotEnoughSpaceInContainerException; +use App\Modules\Trade\Domain\Store\StoreDoesNotBuyItems; use Illuminate\Support\Collection; class Store @@ -145,6 +146,10 @@ public function putMoneyIn(Money $money): void public function takeMoneyOut(Money $money): Money { + if ($this->type->isSellOnly()) { + throw new StoreDoesNotBuyItems('Store does not buy items'); + } + $this->money = $this->money->remove($money); return $money; diff --git a/app/Modules/Trade/Domain/Store/StoreDoesNotBuyItems.php b/app/Modules/Trade/Domain/Store/StoreDoesNotBuyItems.php new file mode 100644 index 00000000..0a47c7df --- /dev/null +++ b/app/Modules/Trade/Domain/Store/StoreDoesNotBuyItems.php @@ -0,0 +1,11 @@ +type; } - public function equals(ItemType $type): bool + public function isSellOnly(): bool { - return $this->type === $type->toString(); + return $this->type === self::SELL_ONLY; } } diff --git a/resources/js/components/StoreManagement.vue b/resources/js/components/StoreManagement.vue index 17c5656c..786fbd25 100644 --- a/resources/js/components/StoreManagement.vue +++ b/resources/js/components/StoreManagement.vue @@ -1,146 +1,147 @@ diff --git a/resources/js/components/StoreTrade.vue b/resources/js/components/StoreTrade.vue index d2edf259..e4c98819 100644 --- a/resources/js/components/StoreTrade.vue +++ b/resources/js/components/StoreTrade.vue @@ -1,438 +1,450 @@