fix buying customizations

# Conflicts:
#	Habitica/src/main/java/com/habitrpg/android/habitica/models/shops/ShopItem.kt
This commit is contained in:
Phillip Thelen 2022-07-18 18:53:30 +02:00
parent 2c29b38f05
commit 9edc8022ea
2 changed files with 7 additions and 4 deletions

View file

@ -41,6 +41,7 @@ open class ShopItem : RealmObject(), BaseObject {
var limitedNumberLeft: Int? = null
var unlockCondition: ShopItemUnlockCondition? = null
var path: String? = null
var unlockPath: String? = null
var isSuggested: String? = null
var pinType: String? = null
@SerializedName("klass")
@ -164,6 +165,8 @@ open class ShopItem : RealmObject(), BaseObject {
item.notes = customization.notes
item.value = customization.price ?: 0
item.path = customization.path
item.unlockPath = customization.unlockPath
item.pinType = customization.type
item.purchaseType = if (customization.type == "background") "background" else "customization"
item.imageName = customization.getImageName(userSize, hairColor)
return item
@ -173,12 +176,12 @@ open class ShopItem : RealmObject(), BaseObject {
val item = ShopItem()
var path = ""
for (customization in set.customizations) {
path = path + "," + customization.path
path = path + "," + customization.unlockPath
}
if (path.isEmpty()) {
item.path = path
item.unlockPath = path
} else {
item.path = path.substring(1)
item.unlockPath = path.substring(1)
}
item.text = set.text
item.key = set.identifier ?: ""

View file

@ -367,7 +367,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
} else if (shopItem.purchaseType == "debuffPotion") {
observable = userRepository.useSkill(shopItem.key, null).cast(Any::class.java)
} else if (shopItem.purchaseType == "customization" || shopItem.purchaseType == "background" || shopItem.purchaseType == "customizationSet") {
observable = userRepository.unlockPath(item.path ?: "", item.value).cast(Any::class.java)
observable = userRepository.unlockPath(item.unlockPath ?: "", item.value).cast(Any::class.java)
} else if (shopItem.purchaseType == "debuffPotion") {
observable = userRepository.useSkill(shopItem.key, null).cast(Any::class.java)
} else if (shopItem.purchaseType == "card") {