From 4449ff4294bd2057806b43c14ca9aad8136a7093 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Wed, 28 Jun 2023 23:33:03 +0900 Subject: [PATCH 1/3] =?UTF-8?q?fix:=20=E3=82=AC=E3=83=81=E3=83=A3=E6=99=AF?= =?UTF-8?q?=E5=93=81=E3=81=AE=E4=BF=9D=E5=AD=98=E3=82=B3=E3=83=9E=E3=83=B3?= =?UTF-8?q?=E3=83=89=E3=81=A7=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88=E7=94=A8?= =?UTF-8?q?=E3=81=AE=E3=82=AC=E3=83=81=E3=83=A3=E6=99=AF=E5=93=81=E3=81=8C?= =?UTF-8?q?=E4=BF=9D=E5=AD=98=E3=81=A7=E3=81=8D=E3=81=A6=E3=81=84=E3=81=AA?= =?UTF-8?q?=E3=81=8B=E3=81=A3=E3=81=9F=E4=B8=8D=E5=85=B7=E5=90=88=E3=82=92?= =?UTF-8?q?=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seichiassist/subsystems/gacha/bukkit/GachaCommand.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gacha/bukkit/GachaCommand.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gacha/bukkit/GachaCommand.scala index d5f3180580..77f3b17c5b 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gacha/bukkit/GachaCommand.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gacha/bukkit/GachaCommand.scala @@ -379,7 +379,7 @@ class GachaCommand[ .beginConfiguration() .execution { _ => val eff = for { - gachaPrizes <- gachaPrizeAPI.listOfNow + gachaPrizes <- gachaPrizeAPI.allGachaPrizeList _ <- gachaPrizeAPI.replace(gachaPrizes) } yield MessageEffect("ガチャデータをmysqlに保存しました。") From 4bd31126678ddc3343fa75243e1d23df421bbeac Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:14:43 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20add=E3=82=B3=E3=83=9E=E3=83=B3?= =?UTF-8?q?=E3=83=89=E3=81=A7=E8=87=AA=E5=8B=95=E7=9A=84=E3=81=AB=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E3=81=99=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../subsystems/gachaprize/System.scala | 1 + .../domain/GachaPrizeListPersistence.scala | 5 +++++ .../JdbcGachaPrizeListPersistence.scala | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala index c8998691f2..86246bfcbb 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala @@ -100,6 +100,7 @@ object System { ) +: prizes } newGachaPrizes <- allGachaPrizesListReference.get + _ <- _gachaPersistence.addGachaPrize(newGachaPrizes.head) _ <- _gachaPersistence .addMineStackGachaObject( newGachaPrizes.head.id, diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/GachaPrizeListPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/GachaPrizeListPersistence.scala index ed92b13e6f..e74e0f0653 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/GachaPrizeListPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/domain/GachaPrizeListPersistence.scala @@ -12,6 +12,11 @@ trait GachaPrizeListPersistence[F[_], ItemStack] { */ def list: F[Vector[GachaPrize[ItemStack]]] + /** + * @return ガチャアイテムを追加する作用 + */ + def addGachaPrize(gachaPrize: GachaPrize[ItemStack]): F[Unit] + /** * @return ガチャリストを更新する作用 */ diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/infrastructure/JdbcGachaPrizeListPersistence.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/infrastructure/JdbcGachaPrizeListPersistence.scala index 2c842c86cd..5dc90cc445 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/infrastructure/JdbcGachaPrizeListPersistence.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/infrastructure/JdbcGachaPrizeListPersistence.scala @@ -47,6 +47,20 @@ class JdbcGachaPrizeListPersistence[F[_]: Sync, ItemStack: Cloneable]( } } + override def addGachaPrize(gachaPrize: GachaPrize[ItemStack]): F[Unit] = Sync[F].delay { + DB.localTx { implicit session => + val eventId = gachaPrize.gachaEventName.flatMap { eventName => + sql"SELECT id FROM gacha_events WHERE event_name = ${eventName.name}" + .map(_.int("id")) + .single() + .apply() + } + + sql"INSERT INTO gachadata VALUES (${gachaPrize.id.id}, ${gachaPrize.probability.value}, ${serializeAndDeserialize + .serialize(gachaPrize.itemStack)}, $eventId)".execute().apply() + } + } + override def set(gachaPrizesList: Vector[GachaPrize[ItemStack]]): F[Unit] = { Sync[F].delay { DB.localTx { implicit session => From 8ea9c600a50e42bac20abd299cf9832a73bdf477 Mon Sep 17 00:00:00 2001 From: rito528 <39003544+rito528@users.noreply.github.com> Date: Thu, 29 Jun 2023 20:25:04 +0900 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20=E3=82=A4=E3=83=99=E3=83=B3=E3=83=88?= =?UTF-8?q?=E4=B8=AD=E3=81=AE=E3=82=AC=E3=83=81=E3=83=A3=E3=83=AA=E3=82=B9?= =?UTF-8?q?=E3=83=88=E3=81=AB=E3=82=A8=E3=83=B3=E3=83=81=E3=83=A3=E3=83=B3?= =?UTF-8?q?=E3=83=88=E7=93=B6=E3=82=92=E5=90=AB=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../unchama/seichiassist/subsystems/gachaprize/System.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala index 86246bfcbb..d55099b213 100644 --- a/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala +++ b/src/main/scala/com/github/unchama/seichiassist/subsystems/gachaprize/System.scala @@ -115,7 +115,7 @@ object System { } yield { createdEvents.find(_.isHolding) match { case Some(value) => - prizes.filter(_.gachaEventName.contains(value.eventName)) + prizes.filter(_.gachaEventName.contains(value.eventName)) :+ expBottle case None => prizes.filter(_.gachaEventName.isEmpty) }