mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-05-20 12:49:02 +00:00
update owned count when user receives a drop. Fixes #1271
This commit is contained in:
parent
68cd8829ba
commit
76358a0f82
2 changed files with 19 additions and 1 deletions
|
|
@ -155,7 +155,7 @@ android {
|
|||
multiDexEnabled true
|
||||
resConfigs "en", "bg", "de", "en-rGB", "es", "fr", "hr-rHR", "in", "it", "iw", "ja", "ko", "lt", "nl", "pl", "pt-rBR", "pt-rPT", "ru", "tr", "zh", "zh-rTW"
|
||||
|
||||
versionCode 2392
|
||||
versionCode 2394
|
||||
versionName "2.5"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.habitrpg.android.habitica.models.responses.TaskDirection
|
|||
import com.habitrpg.android.habitica.models.responses.TaskDirectionData
|
||||
import com.habitrpg.android.habitica.models.responses.TaskScoringResult
|
||||
import com.habitrpg.android.habitica.models.tasks.*
|
||||
import com.habitrpg.android.habitica.models.user.OwnedItem
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
import io.reactivex.Flowable
|
||||
import io.reactivex.Maybe
|
||||
|
|
@ -137,6 +138,23 @@ class TaskRepositoryImpl(localRepository: TaskLocalRepository, apiClient: ApiCli
|
|||
}
|
||||
}
|
||||
}
|
||||
res._tmp?.drop?.key?.let { key ->
|
||||
val type = when(res._tmp?.drop?.type?.toLowerCase(Locale.US)) {
|
||||
"hatchingPotion" -> "hatchingPotions"
|
||||
"egg" -> "eggs"
|
||||
else -> res._tmp?.drop?.type?.toLowerCase(Locale.US)
|
||||
}
|
||||
var item = it.where(OwnedItem::class.java).equalTo("itemType", type).equalTo("key", key).findFirst()
|
||||
if (item == null) {
|
||||
item = OwnedItem()
|
||||
item.key = key
|
||||
item.itemType = type
|
||||
item.userID = user.id
|
||||
}
|
||||
item.numberOwned += 1
|
||||
it.insertOrUpdate(item)
|
||||
}
|
||||
|
||||
val stats = bgUser.stats
|
||||
stats?.hp = res.hp
|
||||
stats?.exp = res.exp
|
||||
|
|
|
|||
Loading…
Reference in a new issue