Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 整地報酬ガチャ券受取ボタンに右クリックして1スタックだけ引き出せるようにする機能を追加 #2371

Merged
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
fd03f11
feat: 整地報酬ガチャ券受取について右クリック用の受取バッチ処理を追加
kuroma6666 Sep 1, 2024
73249fc
feat: 整地報酬ガチャ券受取ボタンの右クリック対応
kuroma6666 Sep 1, 2024
a2298a5
update: 整地報酬ガチャ券受取ボタンのガチャ券受取枚数について説明を追加
kuroma6666 Sep 1, 2024
6feb27c
chore: コメント微修正
kuroma6666 Sep 1, 2024
47dfbe2
fix: バッチ命名の修正 RightClick->OneStack
kuroma6666 Sep 1, 2024
33f852c
fix: 引数名省略
kuroma6666 Sep 1, 2024
7143d2f
chore: ボタンlore微修正
kuroma6666 Sep 1, 2024
bfafc88
fix: Batchで扱うガチャポイントの数を明確にするよう修正
kuroma6666 Sep 2, 2024
ac1ba33
fix: 整地報酬ガチャ券受取変数名について省略をしないよう修正 recv->receive
kuroma6666 Sep 2, 2024
5316bd6
fix: 引数名の省略
kuroma6666 Sep 3, 2024
bba87bd
docs: BatchSizeのコメントを変更
kuroma6666 Sep 3, 2024
7c3fa7b
add: ガチャ券へのポイント交換にて一度に得られるガチャ券の上限変数を追加
kuroma6666 Sep 3, 2024
4d6cb2a
docs: 使うバッチ名をコメントへ明記した
kuroma6666 Sep 3, 2024
2b6abc6
fix: useInBatch関数を定義し、`useInLargeBatch` と `useInSmallBatch`について書き換え
kuroma6666 Sep 3, 2024
65b83ae
fix; `BatchSize`型の定義とLarge/SmallBatchSizeを`BatchSize`型とする
kuroma6666 Sep 3, 2024
2823cb8
fix: コンパイルエラー修正
kuroma6666 Sep 3, 2024
9ca46ed
fix: コンパイルエラー修正
kuroma6666 Sep 3, 2024
fe735f9
fix: effect名の修正
kuroma6666 Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import com.github.unchama.menuinventory.router.CanOpen
import com.github.unchama.menuinventory.slot.button.action.{
ClickEventFilter,
FilteredButtonEffect,
LeftClickButtonEffect
LeftClickButtonEffect,
RightClickButtonEffect
}
import com.github.unchama.menuinventory.slot.button.{Button, RecomputedButton, action}
import com.github.unchama.seichiassist.data.descrptions.PlayerStatsLoreGenerator
Expand Down Expand Up @@ -522,6 +523,9 @@ object FirstPage extends Menu {
val effect: FilteredButtonEffect = LeftClickButtonEffect(
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
environment.gachaPointApi.receiveBatch
)
val rightEffect: FilteredButtonEffect = RightClickButtonEffect(
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
environment.gachaPointApi.receiveOneStackBatch
)

val computeItemStack: IO[ItemStack] =
environment.gachaPointApi.gachaPoint(player).read.toIO.map { point =>
Expand All @@ -534,8 +538,10 @@ object FirstPage extends Menu {

val requiredToNextTicket =
s"$RESET${AQUA}次のガチャ券まで:${point.amountUntilNextGachaTicket.amount}ブロック"
val recvGachaTicketDetail =
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
s"$RESET${GRAY}左クリックで最大9st、右クリックで最大1stのガチャ券を受け取ります"

List(gachaTicketStatus, requiredToNextTicket)
List(gachaTicketStatus, requiredToNextTicket, recvGachaTicketDetail)
}

new SkullItemStackBuilder(SkullOwners.unchama)
Expand All @@ -545,7 +551,7 @@ object FirstPage extends Menu {
}

val computeButton: IO[Button] = computeItemStack.map { itemStack =>
Button(itemStack, effect)
Button(itemStack, effect, rightEffect)
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
}

RecomputedButton(computeButton)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ trait GachaPointApi[F[_], G[_], Player] {
*/
val receiveBatch: Kleisli[F, Player, Unit]
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved

/**
* プレーヤーのガチャポイントをガチャ券に変換して一括で受け取る作用。
*/
val receiveOneStackBatch: Kleisli[F, Player, Unit]
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved

/**
* プレーヤーのガチャポイントを増やす作用。
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ object System {
.as(())
}

override val receiveOneStackBatch: Kleisli[F, Player, Unit] = Kleisli { player =>
gachaPointRepositoryControlsRepository
.lift(player)
.traverse { _.semaphore.tryOneStackBatchTransaction }
.as(())
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
}

override def addGachaPoint(point: GachaPoint): Kleisli[F, Player, Unit] =
Kleisli { player: Player =>
ContextCoercion(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class BatchUsageSemaphore[F[_]: FlatMap, G[_]: ContextCoercion[*[_], F]](
}.flatTap(grantAction.give)
}(BatchUsageSemaphore.usageInterval)

def tryOneStackBatchTransaction: F[Unit] =
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
recoveringSemaphore.tryUse {
ContextCoercion {
gachaPointRef.modify { _.useInOneStackBatch.asTuple }
}.flatTap(grantAction.give)
}(BatchUsageSemaphore.usageInterval)
}

object BatchUsageSemaphore {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.github.unchama.seichiassist.subsystems.breakcount.domain.level.Seichi
/**
* ガチャポイントとはプレーヤーが持つ「消費可能な整地経験量」である。
*
* プレーヤーは576個(= 64 * 9スタック)のバッチにてガチャポイントをガチャ券に交換できる。
* プレーヤーは576個(= 64 * 9スタック)のバッチもしくは、64個(1スタック)のバッチにてガチャポイントをガチャ券に交換できる。
*/
case class GachaPoint(exp: SeichiExpAmount) {

Expand All @@ -16,7 +16,7 @@ case class GachaPoint(exp: SeichiExpAmount) {
(exp.amount /% GachaPoint.perGachaTicket.exp.amount)._1.toBigInt

/**
* ガチャポイントをバッチでガチャ券に変換した際のポイントの変化を計算する
* ガチャポイントを576個(= 64 * 9スタック)のバッチでガチャ券に変換した際のポイントの変化を計算する
*/
lazy val useInBatch: GachaPoint.Usage = {
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
val ticketCount = availableTickets.min(GachaPoint.batchSize).toInt
Expand All @@ -27,6 +27,18 @@ case class GachaPoint(exp: SeichiExpAmount) {
GachaPoint.Usage(remaining, ticketCount)
}

/**
* ガチャポイントを64個(1スタック)のバッチでガチャ券に変換した際のポイントの変化を計算する。
*/
lazy val useInOneStackBatch: GachaPoint.Usage = {
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
val ticketCount = availableTickets.min(GachaPoint.batchSizeOneStack).toInt

val expToUse = GachaPoint.perGachaTicket.exp.amount * ticketCount
val remaining = GachaPoint.ofNonNegative(exp.amount - expToUse)

GachaPoint.Usage(remaining, ticketCount)
}

/**
* 次にガチャ券を利用できるようになるまでに必要な整地経験値量
*/
Expand Down Expand Up @@ -63,6 +75,11 @@ object GachaPoint {
* ガチャ券へのポイント交換にて一度に得られるガチャ券の上限
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved
*/
final val batchSize = 9 * 64
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved

/**
* ガチャ券へのポイント交換にて一度に得られるガチャ券の上限
*/
final val batchSizeOneStack = 64
kuroma6666 marked this conversation as resolved.
Show resolved Hide resolved

/**
* ガチャポイントの初期値
Expand Down
Loading