Skip to content

Commit

Permalink
faint and armoire improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
phillipthelen committed Jul 22, 2024
1 parent 415c634 commit 6984a28
Show file tree
Hide file tree
Showing 10 changed files with 226 additions and 228 deletions.
302 changes: 152 additions & 150 deletions Habitica/res/layout/activity_death.xml

Large diffs are not rendered by default.

36 changes: 0 additions & 36 deletions Habitica/res/layout/dialog_faint.xml

This file was deleted.

2 changes: 1 addition & 1 deletion Habitica/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
<string name="onwards">Onwards!</string>

<string name="faint_subtitle">Don\'t despair!</string>
<string name="faint_penalty_body">You lost a Level, your Gold, and a piece of Equipment, but you can get them all back with hard work! Good luck—you\'ll do great.</string>
<string name="faint_header">You ran out of Health!</string>
<string name="faint_button">Refill Health &amp; Try Again</string>

Expand Down Expand Up @@ -1274,6 +1273,7 @@
<string name="death_description">But you can get them all back with hard work! Good luck—you’ll do great.</string>
<string name="faint_broken_equipment">Broken equipment can be repurchased \nfrom Rewards</string>
<string name="faint_loss_description"><![CDATA[You’ll drop to level <b>%d</b>, lose <b>%d</b> Gold, and break <b>a piece of gear</b>… You can earn them all back with hard work!]]></string>
<string name="faint_loss_description_alt"><![CDATA[You’ll drop to level <b>%d</b>, lose <b>%d</b> Gold, and your Experience… You can earn them all back with hard work!]]></string>
<string name="account_reset">Account Reset</string>
<string name="avatar_skin_customization">Avatar Skin Customization</string>
<string name="avatar_shirt_customization">Avatar Shirt Customization</string>
Expand Down
14 changes: 9 additions & 5 deletions Habitica/res/values/values.xml
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,15 @@

<string-array name="server_urls">
<item>https://habitica.com</item>
<item>https://habitrpg-staging.herokuapp.com</item>
<item>https://habitrpg-beta.herokuapp.com</item>
<item>https://habitrpg-gamma.herokuapp.com</item>
<item>https://habitrpg-delta.herokuapp.com</item>
<item>https://habitica-subs.herokuapp.com</item>
<item>https://staging.habitica.com</item>
<item>https://bat.habitica.com</item>
<item>https://frog.habitica.com</item>
<item>https://llama.habitica.com</item>
<item>https://monkey.habitica.com</item>
<item>https://seal.habitica.com</item>
<item>https://shrimp.habitica.com</item>
<item>https://star.habitica.com</item>
<item>https://turtle.habitica.com</item>
</string-array>

<string-array name="task_list_modes">
Expand Down
4 changes: 4 additions & 0 deletions Habitica/res/xml/remote_config_defaults.xml
Original file line number Diff line number Diff line change
Expand Up @@ -145,5 +145,9 @@
<key>enableCustomizationShop</key>
<value>false</value>
</entry>
<entry>
<key>showAltDeathText</key>
<value>false</value>
</entry>
</defaultsMap>
<!-- END xml_defaults -->
Original file line number Diff line number Diff line change
Expand Up @@ -192,4 +192,8 @@ class AppConfigManager(contentRepository: ContentRepository) :
fun enableCustomizationShop(): Boolean {
return remoteConfig.getBoolean("enableCustomizationShop")
}

fun showAltDeathText(): Boolean {
return remoteConfig.getBoolean("showAltDeathText")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,15 +150,17 @@ class ArmoireActivity : BaseActivity() {
}

if (appConfigManager.enableArmoireSubs()) {
userViewModel.user.observe(this) {
if (it?.isSubscribed == true && binding.openArmoireSubscriberWrapper.visibility != View.INVISIBLE) {
binding.openArmoireSubscriberWrapper.visibility = View.VISIBLE
binding.unsubbedWrapper.visibility = View.GONE
binding.dropRateButton.visibility = View.VISIBLE
} else if (it?.isSubscribed == false) {
binding.openArmoireSubscriberWrapper.visibility = View.GONE
binding.unsubbedWrapper.visibility = View.VISIBLE
binding.dropRateButton.visibility = View.GONE
if (!hasUsedExtraArmoire) {
userViewModel.user.observe(this) {
if (it?.isSubscribed == true && binding.openArmoireSubscriberWrapper.visibility != View.INVISIBLE) {
binding.openArmoireSubscriberWrapper.visibility = View.VISIBLE
binding.unsubbedWrapper.visibility = View.GONE
binding.dropRateButton.visibility = View.VISIBLE
} else if (it?.isSubscribed == false) {
binding.openArmoireSubscriberWrapper.visibility = View.GONE
binding.unsubbedWrapper.visibility = View.VISIBLE
binding.dropRateButton.visibility = View.GONE
}
}
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.core.content.edit
import androidx.core.view.isVisible
import androidx.lifecycle.lifecycleScope
import com.habitrpg.android.habitica.HabiticaBaseApplication
import com.habitrpg.android.habitica.R
Expand Down Expand Up @@ -84,10 +85,19 @@ class DeathActivity : BaseActivity(), SnackbarActivity {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

val stringId = if (appConfigManager.showAltDeathText()) {
R.string.faint_loss_description_alt
} else {
R.string.faint_loss_description
}

binding.brokenEquipmentDescription.isVisible = !appConfigManager.showAltDeathText()

userViewModel.user.observeOnce(this) { user ->
binding.lossDescription.text =
getString(
R.string.faint_loss_description,
stringId,
(user?.stats?.lvl ?: 2).toInt() - 1,
user?.stats?.gp?.toInt(),
).fromHtml()
Expand Down Expand Up @@ -197,30 +207,7 @@ class DeathActivity : BaseActivity(), SnackbarActivity {
.height(60.dp)
.clickable {
isUsingBenefit = true
Analytics.sendEvent(
"second chance perk",
EventCategory.BEHAVIOUR,
HitType.EVENT,
)
sharedPreferences.edit {
putLong("last_sub_revive", Date().time)
}
lifecycleScope.launch(ExceptionHandler.coroutine()) {
userRepository.updateUser("stats.hp", 1)
MainScope().launchCatching {
delay(1000)
(HabiticaBaseApplication.getInstance(this@DeathActivity)?.currentActivity?.get() as? SnackbarActivity)?.let { activity ->
HabiticaSnackbar.showSnackbar(
activity.snackbarContainer(),
getString(R.string.subscriber_benefit_success_faint),
HabiticaSnackbar.SnackbarDisplayType.SUBSCRIBER_BENEFIT,
isSubscriberBenefit = true,
duration = 2500,
)
}
}
finish()
}
useSubBenefit()
},
) {
Text(
Expand Down Expand Up @@ -257,6 +244,33 @@ class DeathActivity : BaseActivity(), SnackbarActivity {
startAnimating()
}

private fun useSubBenefit() {
Analytics.sendEvent(
"second chance perk",
EventCategory.BEHAVIOUR,
HitType.EVENT,
)
sharedPreferences.edit {
putLong("last_sub_revive", Date().time)
}
lifecycleScope.launch(ExceptionHandler.coroutine()) {
userRepository.updateUser("stats.hp", 1)
MainScope().launchCatching {
delay(1000)
(HabiticaBaseApplication.getInstance(this@DeathActivity)?.currentActivity?.get() as? SnackbarActivity)?.let { activity ->
HabiticaSnackbar.showSnackbar(
activity.snackbarContainer(),
getString(R.string.subscriber_benefit_success_faint),
HabiticaSnackbar.SnackbarDisplayType.SUBSCRIBER_BENEFIT,
isSubscriberBenefit = true,
duration = 2500,
)
}
}
finish()
}
}

private fun startAnimating() {
binding.ghostView.startAnimation(Animations.bobbingAnimation())
binding.heartView.post {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.flow.filterNotNull
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.flow.take
import kotlinx.coroutines.launch
import javax.inject.Inject

Expand Down Expand Up @@ -63,6 +65,8 @@ class SkillMemberActivity : BaseActivity() {
userRepository.getUser()
.map { it?.party?.id }
.filterNotNull()
.take(1)
.onEach { socialRepository.getPartyMembers(it) }
.flatMapLatest { socialRepository.getPartyMembers(it) }
.collect { viewAdapter?.data = it }
}
Expand Down
4 changes: 2 additions & 2 deletions version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
NAME=4.4.2
CODE=8021
NAME=4.5.0
CODE=8021

0 comments on commit 6984a28

Please sign in to comment.