Add background image to quest.
This commit is contained in:
parent
331fbb87e5
commit
6a326ad1a8
12 changed files with 321 additions and 158 deletions
|
|
@ -13,6 +13,7 @@ import com.pixelized.rplexicon.utilitary.exceptions.IncompatibleSheetStructure
|
|||
import com.pixelized.rplexicon.utilitary.exceptions.ServiceNotReady
|
||||
import com.pixelized.rplexicon.utilitary.extentions.checkSheetStructure
|
||||
import com.pixelized.rplexicon.utilitary.extentions.sheet
|
||||
import com.pixelized.rplexicon.utilitary.extentions.toUriOrNull
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
|
@ -135,12 +136,6 @@ class LexiconRepository @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun String?.toUriOrNull(): Uri? = try {
|
||||
this?.takeIf { it.isNotBlank() }?.toUri()
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
}
|
||||
|
||||
private val Map<String, Int>?.name: Int get() = this?.getValue(Sheet.NAME) ?: 0
|
||||
private val Map<String, Int>?.diminutive: Int get() = this?.getValue(Sheet.DIMINUTIVE) ?: 1
|
||||
private val Map<String, Int>?.gender: Int get() = this?.getValue(Sheet.GENDER) ?: 2
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.pixelized.rplexicon.utilitary.exceptions.IncompatibleSheetStructure
|
|||
import com.pixelized.rplexicon.utilitary.exceptions.ServiceNotReady
|
||||
import com.pixelized.rplexicon.utilitary.extentions.checkSheetStructure
|
||||
import com.pixelized.rplexicon.utilitary.extentions.sheet
|
||||
import com.pixelized.rplexicon.utilitary.extentions.toUriOrNull
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.StateFlow
|
||||
|
|
@ -82,6 +83,7 @@ class QuestRepository @Inject constructor(
|
|||
Quest(
|
||||
id = index,
|
||||
title = item,
|
||||
background = questMap[item]?.mapNotNull { it.background }?.randomOrNull(),
|
||||
entries = questMap[item] ?: emptyList(),
|
||||
)
|
||||
}
|
||||
|
|
@ -96,24 +98,26 @@ class QuestRepository @Inject constructor(
|
|||
): QuestEntry? {
|
||||
val title = row?.getOrNull(sheetStructure.title) as? String
|
||||
val subtitle = row?.getOrNull(sheetStructure.subtitle) as? String?
|
||||
val complete = row?.getOrNull(sheetStructure.complete) as? Boolean? ?: false
|
||||
val complete = row?.getOrNull(sheetStructure.complete) as? String?
|
||||
val questGiver = row?.getOrNull(sheetStructure.questGiver) as? String?
|
||||
val area = row?.getOrNull(sheetStructure.area) as? String?
|
||||
val groupReward = row?.getOrNull(sheetStructure.groupReward) as? String?
|
||||
val individualReward = row?.getOrNull(sheetStructure.individualReward) as? String?
|
||||
val description = row?.getOrNull(sheetStructure.description) as? String
|
||||
val background = row?.getOrNull(sheetStructure.background) as? String?
|
||||
|
||||
return if (title?.isNotEmpty() == true && description?.isNotEmpty() == true) {
|
||||
QuestEntry(
|
||||
sheetIndex = sheetIndex,
|
||||
title = title,
|
||||
subtitle = subtitle?.takeIf { it.isNotBlank() },
|
||||
complete = complete,
|
||||
complete = complete.equals("TRUE", ignoreCase = true),
|
||||
questGiver = questGiver?.takeIf { it.isNotBlank() },
|
||||
area = area?.takeIf { it.isNotBlank() },
|
||||
groupReward = groupReward?.takeIf { it.isNotBlank() },
|
||||
individualReward = individualReward?.takeIf { it.isNotBlank() },
|
||||
description = description,
|
||||
background = background?.toUriOrNull(),
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
|
@ -128,6 +132,7 @@ class QuestRepository @Inject constructor(
|
|||
private val Map<String, Int>?.groupReward: Int get() = this?.getValue(Sheet.G_REWARD) ?: 5
|
||||
private val Map<String, Int>?.individualReward: Int get() = this?.getValue(Sheet.I_REWARD) ?: 6
|
||||
private val Map<String, Int>?.description: Int get() = this?.getValue(Sheet.DESCRIPTION) ?: 7
|
||||
private val Map<String, Int>?.background: Int get() = this?.getValue(Sheet.BACKGROUND) ?: 8
|
||||
|
||||
private object Sheet {
|
||||
const val ID = "1sDAay8DjbRYKM39MvEXWs-RuvyxjOFpOfRZLAEWjIUY"
|
||||
|
|
@ -143,6 +148,7 @@ class QuestRepository @Inject constructor(
|
|||
"Récompense de groupe",
|
||||
"Récompense individuelle",
|
||||
"Description",
|
||||
"fond"
|
||||
)
|
||||
val TITLE = COLUMNS[0]
|
||||
val SUBTITLE = COLUMNS[1]
|
||||
|
|
@ -152,5 +158,6 @@ class QuestRepository @Inject constructor(
|
|||
val G_REWARD = COLUMNS[5]
|
||||
val I_REWARD = COLUMNS[6]
|
||||
val DESCRIPTION = COLUMNS[7]
|
||||
val BACKGROUND = COLUMNS[8]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue