Skip to content

Commit

Permalink
Merge pull request #1582 from rito528/refactorVote
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective authored Feb 21, 2023
2 parents 92824ce + 5f29ce1 commit ec2de65
Show file tree
Hide file tree
Showing 79 changed files with 2,740 additions and 1,312 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
USE seichiassist;

-- 型を変えるので一度内容をリセットする
UPDATE playerdata SET newVotingFairyTime = NULL;
ALTER TABLE playerdata MODIFY newVotingFairyTime DATETIME;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
USE seichiassist;

ALTER TABLE playerdata ADD is_fairy_speech_play_sound BOOLEAN DEFAULT TRUE AFTER toggleVotingFairy;
36 changes: 36 additions & 0 deletions src/main/resources/db/migration/V1.16.2__Move_vote_column.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
USE seichiassist;

CREATE TABLE IF NOT EXISTS vote(
uuid CHAR(36) NOT NULL PRIMARY KEY,
vote_number INT NOT NULL,
chain_vote_number INT NOT NULL,
effect_point INT NOT NULL,
given_effect_point INT NOT NULL,
last_vote DATETIME NOT NULL
);

INSERT INTO
vote(
uuid,
vote_number,
chain_vote_number,
effect_point,
given_effect_point,
last_vote
)
SELECT
uuid,
p_vote,
chainvote,
effectpoint,
p_givenvote,
CONVERT(lastvote, DATE)
FROM
playerdata;

ALTER TABLE
playerdata DROP IF EXISTS p_vote,
DROP IF EXISTS chainvote,
DROP IF EXISTS effectpoint,
DROP IF EXISTS p_givenvote,
DROP IF EXISTS lastvote;
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
USE seichiassist;

CREATE TABLE vote_fairy(
uuid CHAR(36) NOT NULL PRIMARY KEY,
apple_open_state INT NOT NULL DEFAULT 1,
fairy_summon_cost INT NOT NULL DEFAULT 1,
is_fairy_using BOOLEAN NOT NULL DEFAULT false,
fairy_recovery_mana_value INT NOT NULL DEFAULT 0,
fairy_end_time DATETIME DEFAULT NULL,
given_apple_amount BIGINT NOT NULL DEFAULT 0,
is_play_fairy_speech_sound BOOLEAN NOT NULL DEFAULT true
);

INSERT INTO
vote_fairy(
uuid,
apple_open_state,
fairy_summon_cost,
is_fairy_using,
fairy_recovery_mana_value,
fairy_end_time,
given_apple_amount,
is_play_fairy_speech_sound
)
SELECT
uuid,
toggleGiveApple,
toggleVotingFairy,
canVotingFairyUse,
VotingFairyRecoveryValue,
newVotingFairyTime,
p_apple,
is_fairy_speech_play_sound
FROM
playerdata;

ALTER TABLE playerdata
DROP IF EXISTS toggleGiveApple,
DROP IF EXISTS toggleVotingFairy,
DROP IF EXISTS canVotingFairyUse,
DROP IF EXISTS VotingFairyRecoveryValue,
DROP IF EXISTS newVotingFairyTime,
DROP IF EXISTS p_apple,
DROP IF EXISTS is_fairy_speech_play_sound
11 changes: 0 additions & 11 deletions src/main/scala/com/github/unchama/seichiassist/AntiTypesafe.java

This file was deleted.

38 changes: 23 additions & 15 deletions src/main/scala/com/github/unchama/seichiassist/SeichiAssist.scala
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import com.github.unchama.seichiassist.concurrent.PluginExecutionContexts.{
asyncShift,
onMainThread
}
import com.github.unchama.seichiassist.data.RankData
import com.github.unchama.seichiassist.data.player.PlayerData
import com.github.unchama.seichiassist.database.DatabaseGateway
import com.github.unchama.seichiassist.domain.actions.{
Expand Down Expand Up @@ -85,6 +84,8 @@ import com.github.unchama.seichiassist.subsystems.minestack.bukkit.MineStackComm
import com.github.unchama.seichiassist.subsystems.present.infrastructure.GlobalPlayerAccessor
import com.github.unchama.seichiassist.subsystems.seasonalevents.api.SeasonalEventsAPI
import com.github.unchama.seichiassist.subsystems.sharedinventory.SharedInventoryAPI
import com.github.unchama.seichiassist.subsystems.vote.VoteAPI
import com.github.unchama.seichiassist.subsystems.vote.subsystems.fairy.FairyAPI
import com.github.unchama.seichiassist.subsystems.tradesystems.subsystems.gttosiina.GtToSiinaAPI
import com.github.unchama.seichiassist.task.PlayerDataSaveTask
import com.github.unchama.seichiassist.task.global._
Expand Down Expand Up @@ -451,6 +452,23 @@ class SeichiAssist extends JavaPlugin() {
subsystems.idletime.subsystems.awayscreenname.System.wired[IO].unsafeRunSync()
}

// TODO: これはprivateであるべきだが、Achievementシステムが再実装されるまでやむを得ずpublicにする
lazy val voteSystem: subsystems.vote.System[IO, Player] = {
implicit val breakCountAPI: BreakCountAPI[IO, SyncIO, Player] = breakCountSystem.api

subsystems.vote.System.wired[IO, SyncIO]
}

private lazy val fairySystem: subsystems.vote.subsystems.fairy.System[IO, SyncIO, Player] = {
import PluginExecutionContexts.{asyncShift, sleepAndRoutineContext}
implicit val concurrentEffect: ConcurrentEffect[IO] = IO.ioConcurrentEffect(asyncShift)
implicit val breakCountAPI: BreakCountAPI[IO, SyncIO, Player] = breakCountSystem.api
implicit val voteAPI: VoteAPI[IO, Player] = voteSystem.api
implicit val manaApi: ManaApi[IO, SyncIO, Player] = manaSystem.manaApi

subsystems.vote.subsystems.fairy.System.wired.unsafeRunSync()
}

/* TODO: mineStackSystemは本来privateであるべきだが、mineStackにアイテムを格納するAPIが現状の
BreakUtilの実装から呼び出されている都合上やむを得ずpublicになっている。*/
lazy val mineStackSystem: subsystems.minestack.System[IO, Player, ItemStack] =
Expand All @@ -476,6 +494,8 @@ class SeichiAssist extends JavaPlugin() {
homeSystem,
presentSystem,
anywhereEnderSystem,
voteSystem,
fairySystem,
gachaPrizeSystem,
idleTimeSystem,
awayScreenNameSystem,
Expand Down Expand Up @@ -638,6 +658,8 @@ class SeichiAssist extends JavaPlugin() {
anywhereEnderSystem.accessApi
implicit val sharedInventoryAPI: SharedInventoryAPI[IO, Player] =
sharedInventorySystem.api
implicit val voteAPI: VoteAPI[IO, Player] = voteSystem.api
implicit val fairyAPI: FairyAPI[IO, SyncIO, Player] = fairySystem.api
implicit val donateAPI: DonatePremiumPointAPI[IO] = donateSystem.api
implicit val gachaTicketAPI: GachaTicketAPI[IO] =
gachaTicketSystem.api
Expand All @@ -662,7 +684,6 @@ class SeichiAssist extends JavaPlugin() {

// コマンドの登録
Map(
"vote" -> VoteCommand.executor,
"map" -> MapCommand.executor,
"ef" -> new EffectCommand(fastDiggingEffectSystem.settingsApi).executor,
"seichiassist" -> SeichiAssistCommand.executor,
Expand All @@ -679,7 +700,6 @@ class SeichiAssist extends JavaPlugin() {
case (commandName, executor) => getCommand(commandName).setExecutor(executor)
}

import menuRouter.canOpenAchievementMenu
import menuRouter.ioCanOpenNickNameMenu
// リスナーの登録
val listeners = Seq(
Expand Down Expand Up @@ -710,11 +730,6 @@ class SeichiAssist extends JavaPlugin() {
getServer.getPluginManager.registerEvents(_, this)
}

// ランキングリストを最新情報に更新する
if (!SeichiAssist.databaseGateway.playerDataManipulator.successRankingUpdate()) {
throw new RuntimeException("ランキングデータの作成に失敗しました。サーバーを停止します…")
}

startRepeatedJobs()

// サブシステムのリポジトリのバックアップ処理を走らせる
Expand Down Expand Up @@ -869,12 +884,6 @@ class SeichiAssist extends JavaPlugin() {
object SeichiAssist {
// Playerdataに依存するデータリスト
val playermap: mutable.HashMap[UUID, PlayerData] = mutable.HashMap()
// プレイ時間ランキング表示用データリスト
val ranklist_playtick: mutable.ArrayBuffer[RankData] = mutable.ArrayBuffer()
// 投票ポイント表示用データリスト
val ranklist_p_vote: mutable.ArrayBuffer[RankData] = mutable.ArrayBuffer()
// マナ妖精表示用のデータリスト
val ranklist_p_apple: mutable.ArrayBuffer[RankData] = mutable.ArrayBuffer()

var instance: SeichiAssist = _
// デバッグフラグ(デバッグモード使用時はここで変更するのではなくconfig.ymlの設定値を変更すること!)
Expand All @@ -883,7 +892,6 @@ object SeichiAssist {
// TODO staticであるべきではない
var databaseGateway: DatabaseGateway = _
var seichiAssistConfig: Config = _
var allplayergiveapplelong = 0L

object Scopes {
implicit val globalChatInterceptionScope: InterceptionScope[UUID, String] = {
Expand Down

This file was deleted.

Loading

0 comments on commit ec2de65

Please sign in to comment.