mirror of
https://github.com/sudoxnym/habitica-android.git
synced 2026-07-14 02:01:56 +00:00
Fixes #1546
This commit is contained in:
parent
3d7a41bbaa
commit
fd8662129d
7 changed files with 39 additions and 29 deletions
|
|
@ -149,7 +149,7 @@ android {
|
|||
buildConfigField "String", "TESTING_LEVEL", "\"production\""
|
||||
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 2940
|
||||
versionCode 2943
|
||||
versionName "3.2.3"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1152,4 +1152,6 @@
|
|||
<string name="go_to_survey">Go to Survey</string>
|
||||
<string name="survey_title">Habitica player survey</string>
|
||||
<string name="survey_menu_description">Fill out this 5 minute survey to help us grow and receive an achievement!</string>
|
||||
<string name="locked_equipment_shop_dialog">You must purchase the previous items in this sequence to unlock</string>
|
||||
<string name="caused_damage">You caused damage to the boss</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -125,19 +125,20 @@ class UserRepositoryImpl(localRepository: UserLocalRepository, apiClient: ApiCli
|
|||
|
||||
override fun useSkill(key: String, target: String?, taskId: String): Flowable<SkillResponse> {
|
||||
return zipWithLiveUser(apiClient.useSkill(key, target ?: "", taskId)) { skillResponse, user ->
|
||||
mergeUser(user, skillResponse.user)
|
||||
skillResponse.user?.let { mergeUser(user, it) }
|
||||
skillResponse
|
||||
}
|
||||
}
|
||||
|
||||
override fun useSkill(key: String, target: String?): Flowable<SkillResponse> {
|
||||
return zipWithLiveUser(apiClient.useSkill(key, target ?: "")) { response, user ->
|
||||
response.hpDiff = response.user.stats?.hp ?: 0 - (user.stats?.hp ?: 0.0)
|
||||
response.expDiff = response.user.stats?.exp ?: 0 - (user.stats?.exp ?: 0.0)
|
||||
response.goldDiff = response.user.stats?.gp ?: 0 - (user.stats?.gp ?: 0.0)
|
||||
mergeUser(user, response.user)
|
||||
response
|
||||
}
|
||||
response.hpDiff = response.user?.stats?.hp ?: 0 - (user.stats?.hp ?: 0.0)
|
||||
response.expDiff = response.user?.stats?.exp ?: 0 - (user.stats?.exp ?: 0.0)
|
||||
response.goldDiff = response.user?.stats?.gp ?: 0 - (user.stats?.gp ?: 0.0)
|
||||
response.damage = (response.user?.party?.quest?.progress?.up ?: 0.0f) - (user.party?.quest?.progress?.up ?: 0.0f)
|
||||
response.user?.let { mergeUser(user, it) }
|
||||
response
|
||||
}
|
||||
}
|
||||
|
||||
override fun changeClass(): Flowable<User> = apiClient.changeClass().flatMap { retrieveUser(withTasks = false, forced = true) }
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
package com.habitrpg.android.habitica.models.responses;
|
||||
|
||||
import com.habitrpg.android.habitica.models.tasks.Task;
|
||||
import com.habitrpg.android.habitica.models.user.User;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class SkillResponse {
|
||||
|
||||
public User user;
|
||||
public List<User> partyMembers;
|
||||
public Task task;
|
||||
|
||||
public double expDiff;
|
||||
public double hpDiff;
|
||||
public double goldDiff;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
package com.habitrpg.android.habitica.models.responses
|
||||
|
||||
import com.habitrpg.android.habitica.models.tasks.Task
|
||||
import com.habitrpg.android.habitica.models.user.User
|
||||
|
||||
class SkillResponse {
|
||||
var user: User? = null
|
||||
var task: Task? = null
|
||||
var expDiff = 0.0
|
||||
var hpDiff = 0.0
|
||||
var goldDiff = 0.0
|
||||
var damage = 0.0f
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ class SkillsFragment : BaseMainFragment<FragmentSkillsBinding>() {
|
|||
}
|
||||
|
||||
private fun displaySkillResult(usedSkill: Skill?, response: SkillResponse) {
|
||||
adapter?.mana = response.user.stats?.mp ?: 0.0
|
||||
adapter?.mana = response.user?.stats?.mp ?: 0.0
|
||||
val activity = activity ?: return
|
||||
if ("special" == usedSkill?.habitClass) {
|
||||
showSnackbar(activity.snackbarContainer, context?.getString(R.string.used_skill_without_mana, usedSkill.text), HabiticaSnackbar.SnackbarDisplayType.BLUE)
|
||||
|
|
@ -123,6 +123,15 @@ class SkillsFragment : BaseMainFragment<FragmentSkillsBinding>() {
|
|||
HabiticaSnackbar.SnackbarDisplayType.BLUE)
|
||||
}
|
||||
}
|
||||
if (response.damage > 0) {
|
||||
context?.let {
|
||||
showSnackbar(activity.snackbarContainer, null,
|
||||
context?.getString(R.string.caused_damage),
|
||||
BitmapDrawable(resources, HabiticaIconsHelper.imageOfDamage()),
|
||||
ContextCompat.getColor(it, R.color.green_10), "+" + response.damage,
|
||||
HabiticaSnackbar.SnackbarDisplayType.SUCCESS)
|
||||
}
|
||||
}
|
||||
compositeSubscription.add(userRepository.retrieveUser(false).subscribe({ }, RxErrorHandler.handleEmptyError()))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.habitrpg.android.habitica.ui.views.shops
|
|||
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.util.Log
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
|
|
@ -170,6 +171,7 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
|
||||
@OptIn(ExperimentalTime::class)
|
||||
private fun setLimitedTextView() {
|
||||
if (user == null) return
|
||||
if (shopItem.habitClass != null && shopItem.habitClass != "special" && user?.stats?.habitClass != shopItem.habitClass) {
|
||||
limitedTextView.text = context.getString(R.string.class_equipment_shop_dialog)
|
||||
limitedTextView.visibility = View.VISIBLE
|
||||
|
|
@ -193,9 +195,10 @@ class PurchaseDialog(context: Context, component: UserComponent?, val item: Shop
|
|||
buyLabel.text = context.getString(R.string.locked)
|
||||
limitedTextView.visibility = View.GONE
|
||||
if (shopItem.isTypeGear && shopItem.key.last().toString().toIntOrNull() != null) {
|
||||
val previousKey = "${shopItem.key.dropLast(1)}${shopItem.key.last().toString().toIntOrNull()}"
|
||||
if (user?.items?.gear?.owned?.find { it.key == previousKey} == null) {
|
||||
val previousKey = "${shopItem.key.dropLast(1)}${(shopItem.key.last().toString().toIntOrNull() ?: 1) - 1}"
|
||||
if (user?.items?.gear?.owned?.find { it.key == previousKey}?.owned != true) {
|
||||
limitedTextView.visibility = View.VISIBLE
|
||||
limitedTextView.text = context.getString(R.string.locked_equipment_shop_dialog)
|
||||
limitedTextView.background = ContextCompat.getColor(context, R.color.offset_background).toDrawable()
|
||||
limitedTextView.setTextColor(ContextCompat.getColor(context, R.color.text_secondary))
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue