-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2370 from kuroma6666/feat-digging-stop-mana-fully…
…-consumed feat: マナが無くなったら掘れなくするパッシブスキルを追加
- Loading branch information
Showing
12 changed files
with
325 additions
and
13 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
src/main/resources/db/migration/V1.19.0__Create_break_suppression_preference_table.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
USE seichiassist; | ||
|
||
CREATE TABLE player_break_suppression_preference( | ||
uuid CHAR(36) NOT NULL, | ||
do_break_suppression_due_to_mana BOOL NOT NULL DEFAULT FALSE, | ||
PRIMARY KEY (uuid), | ||
CONSTRAINT fk_player_break_suppression_preference_uuid FOREIGN KEY (uuid) REFERENCES playerdata(uuid) | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...ma/seichiassist/subsystems/breaksuppressionpreference/BreakSuppressionPreferenceAPI.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package com.github.unchama.seichiassist.subsystems.breaksuppressionpreference | ||
|
||
import cats.data.Kleisli | ||
|
||
trait BreakSuppressionPreferenceAPI[F[_], Player] { | ||
|
||
/** | ||
* @return 破壊抑制の設定をトグルする作用 | ||
*/ | ||
def toggleBreakSuppression: Kleisli[F, Player, Unit] | ||
|
||
/** | ||
* @return 現在の破壊抑制の設定を取得する作用 | ||
*/ | ||
def isBreakSuppressionEnabled(player: Player): F[Boolean] | ||
|
||
} | ||
|
||
object BreakSkillTriggerConfigAPI { | ||
|
||
def apply[F[_], Player]( | ||
implicit ev: BreakSuppressionPreferenceAPI[F, Player] | ||
): BreakSuppressionPreferenceAPI[F, Player] = ev | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
.../scala/com/github/unchama/seichiassist/subsystems/breaksuppressionpreference/System.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.github.unchama.seichiassist.subsystems.breaksuppressionpreference | ||
|
||
import cats.data.Kleisli | ||
import cats.effect.SyncEffect | ||
import com.github.unchama.datarepository.bukkit.player.BukkitRepositoryControls | ||
import com.github.unchama.generic.ContextCoercion | ||
import com.github.unchama.seichiassist.meta.subsystem.Subsystem | ||
import com.github.unchama.seichiassist.subsystems.breaksuppressionpreference.application.repository.BreakSuppressionPreferenceRepositoryDefinition | ||
import com.github.unchama.seichiassist.subsystems.breaksuppressionpreference.domain.BreakSuppressionPreferencePersistence | ||
import com.github.unchama.seichiassist.subsystems.breaksuppressionpreference.persistence.JdbcBreakSuppressionPreferencePersistence | ||
import org.bukkit.entity.Player | ||
|
||
trait System[F[_], Player] extends Subsystem[F] { | ||
val api: BreakSuppressionPreferenceAPI[F, Player] | ||
} | ||
|
||
object System { | ||
|
||
import cats.implicits._ | ||
|
||
def wired[F[_], G[_]: SyncEffect: ContextCoercion[*[_], F]]: G[System[F, Player]] = { | ||
implicit val breakSuppressionPreferencePersistence | ||
: BreakSuppressionPreferencePersistence[G] = | ||
new JdbcBreakSuppressionPreferencePersistence[G] | ||
|
||
for { | ||
breakSuppressionPreferenceRepositoryControls <- BukkitRepositoryControls.createHandles( | ||
BreakSuppressionPreferenceRepositoryDefinition.withContext[G, Player] | ||
) | ||
} yield { | ||
val breakSuppressionPreferenceRepository = | ||
breakSuppressionPreferenceRepositoryControls.repository | ||
|
||
new System[F, Player] { | ||
override val api: BreakSuppressionPreferenceAPI[F, Player] = | ||
new BreakSuppressionPreferenceAPI[F, Player] { | ||
override def toggleBreakSuppression: Kleisli[F, Player, Unit] = | ||
Kleisli { player => | ||
ContextCoercion( | ||
breakSuppressionPreferenceRepository(player) | ||
.update(_.toggleBreakSuppression()) | ||
) | ||
} | ||
|
||
override def isBreakSuppressionEnabled(player: Player): F[Boolean] = | ||
ContextCoercion( | ||
breakSuppressionPreferenceRepository(player).get.map(_.doBreakSuppression) | ||
) | ||
} | ||
|
||
override val managedRepositoryControls: Seq[BukkitRepositoryControls[F, _]] = Seq( | ||
breakSuppressionPreferenceRepositoryControls.coerceFinalizationContextTo[F] | ||
) | ||
} | ||
} | ||
} | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...eaksuppressionpreference/application/BreakSuppressionPreferenceRepositoryDefinition.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.github.unchama.seichiassist.subsystems.breaksuppressionpreference.application.repository | ||
|
||
import cats.effect.Sync | ||
import cats.effect.concurrent.Ref | ||
import com.github.unchama.datarepository.definitions.RefDictBackedRepositoryDefinition | ||
import com.github.unchama.datarepository.template.RepositoryDefinition | ||
import com.github.unchama.seichiassist.subsystems.breaksuppressionpreference.domain.{ | ||
BreakSuppressionPreference, | ||
BreakSuppressionPreferencePersistence | ||
} | ||
|
||
object BreakSuppressionPreferenceRepositoryDefinition { | ||
|
||
def withContext[F[_]: Sync, Player]( | ||
implicit persistence: BreakSuppressionPreferencePersistence[F] | ||
): RepositoryDefinition[F, Player, Ref[F, BreakSuppressionPreference]] = | ||
RefDictBackedRepositoryDefinition | ||
.usingUuidRefDict[F, Player, BreakSuppressionPreference](persistence)( | ||
BreakSuppressionPreference.initial | ||
) | ||
.toRefRepository | ||
|
||
} |
Oops, something went wrong.