Skip to content

Commit

Permalink
Optimize quest repository memory (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
wow890209 authored Oct 16, 2023
1 parent 83815d3 commit 2e18dc1
Show file tree
Hide file tree
Showing 23 changed files with 596 additions and 506 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import tw.waterballsa.utopia.utopiagamification.quest.extensions.toTaipeiLocalDa
import tw.waterballsa.utopia.utopiagamification.quest.listeners.UtopiaGamificationListener
import tw.waterballsa.utopia.utopiagamification.repositories.ActivityRepository
import tw.waterballsa.utopia.utopiagamification.repositories.PlayerRepository
import tw.waterballsa.utopia.utopiagamification.quest.service.PlayerFulfillMissionsService
import tw.waterballsa.utopia.utopiagamification.quest.usecase.PlayerFulfillMissionsUsecase
import java.time.LocalDateTime.now

private val log = KotlinLogging.logger {}
Expand All @@ -24,7 +24,7 @@ private val log = KotlinLogging.logger {}
class EventJoiningListener(
guild: Guild,
playerRepository: PlayerRepository,
private val playerFulfillMissionsService: PlayerFulfillMissionsService,
private val playerFulfillMissionsUsecase: PlayerFulfillMissionsUsecase,
private val activityRepository: ActivityRepository
) : UtopiaGamificationListener(guild, playerRepository) {

Expand All @@ -42,7 +42,7 @@ class EventJoiningListener(
channelLeft?.let {
val stayActivity = activityRepository.findAudienceStayActivity(it.id, player.id) ?: return@let
val action = stayActivity.leave(player) ?: return
playerFulfillMissionsService.execute(action, user.claimMissionRewardPresenter)
playerFulfillMissionsUsecase.execute(action, user.claimMissionRewardPresenter)
activityRepository.save(stayActivity)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,12 @@ class Mission(
state = CLAIMED
}

fun nextMission(): Mission? {
fun nextQuestId(): Int? {
if (state == IN_PROGRESS) {
return null
}
return quest.nextQuest?.let { Mission(player, it) }

return quest.nextQuestId
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
package tw.waterballsa.utopia.utopiagamification.quest.domain

private const val completeMessage = "任務完成!"

class Quest(
val id: Int,
val title: String,
val description: String,
val preCondition: PreCondition,
val roleType: RoleType,
val periodType: PeriodType,
val preCondition: PreCondition = EmptyPreCondition(),
val roleType: RoleType = RoleType.EVERYONE,
val periodType: PeriodType = PeriodType.NONE,
val criteria: Action.Criteria,
val reward: Reward,
val nextQuest: Quest? = null,
val postMessage: String
val nextQuestId: Int? = null,
val postMessage: String = completeMessage
)

class Reward(
Expand Down

This file was deleted.

Loading

0 comments on commit 2e18dc1

Please sign in to comment.