mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 21:57:22 +01:00
auto revive
This commit is contained in:
@@ -23,7 +23,6 @@
|
|||||||
p.death-penalty {{ $t('deathPenaltyDetails') }}
|
p.death-penalty {{ $t('deathPenaltyDetails') }}
|
||||||
.modal-footer
|
.modal-footer
|
||||||
.col-12.text-center
|
.col-12.text-center
|
||||||
button.btn.btn-danger(@click='revive()') {{ $t('refillHealthTryAgain') }}
|
|
||||||
h4.text-center(v-html="$t('dyingOftenTips')")
|
h4.text-center(v-html="$t('dyingOftenTips')")
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -37,10 +36,8 @@
|
|||||||
</style>
|
</style>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
|
||||||
import Avatar from '../avatar';
|
import Avatar from '../avatar';
|
||||||
import { mapState } from 'client/libs/store';
|
import { mapState } from 'client/libs/store';
|
||||||
import revive from '../../../common/script/ops/revive';
|
|
||||||
import percent from '../../../common/script/libs/percent';
|
import percent from '../../../common/script/libs/percent';
|
||||||
import {maxHealth} from '../../../common/script/index';
|
import {maxHealth} from '../../../common/script/index';
|
||||||
|
|
||||||
@@ -65,11 +62,6 @@ export default {
|
|||||||
close () {
|
close () {
|
||||||
this.$root.$emit('bv::hide::modal', 'death');
|
this.$root.$emit('bv::hide::modal', 'death');
|
||||||
},
|
},
|
||||||
async revive () {
|
|
||||||
await axios.post('/api/v4/user/revive');
|
|
||||||
revive(this.user);
|
|
||||||
this.close();
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -118,6 +118,8 @@ import ultimateGear from './achievements/ultimateGear';
|
|||||||
import wonChallenge from './achievements/wonChallenge';
|
import wonChallenge from './achievements/wonChallenge';
|
||||||
import loginIncentives from './achievements/login-incentives';
|
import loginIncentives from './achievements/login-incentives';
|
||||||
|
|
||||||
|
import revive from '../../common/script/ops/revive';
|
||||||
|
|
||||||
const NOTIFICATIONS = {
|
const NOTIFICATIONS = {
|
||||||
CHALLENGE_JOINED_ACHIEVEMENT: {
|
CHALLENGE_JOINED_ACHIEVEMENT: {
|
||||||
achievement: true,
|
achievement: true,
|
||||||
@@ -218,6 +220,7 @@ export default {
|
|||||||
isRunningYesterdailies: false,
|
isRunningYesterdailies: false,
|
||||||
nextCron: null,
|
nextCron: null,
|
||||||
handledNotifications,
|
handledNotifications,
|
||||||
|
reviveRunning: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -245,8 +248,7 @@ export default {
|
|||||||
userHp (after, before) {
|
userHp (after, before) {
|
||||||
if (this.user.needsCron) return;
|
if (this.user.needsCron) return;
|
||||||
if (after <= 0) {
|
if (after <= 0) {
|
||||||
alert('userHp');
|
this.showDeathNotification();
|
||||||
this.showNotificationWithModal('DEATH');
|
|
||||||
// @TODO: {keyboard:false, backdrop:'static'}
|
// @TODO: {keyboard:false, backdrop:'static'}
|
||||||
} else if (after <= 30 && !this.user.flags.warnedLowHealth) {
|
} else if (after <= 30 && !this.user.flags.warnedLowHealth) {
|
||||||
this.$root.$emit('bv::show::modal', 'low-health');
|
this.$root.$emit('bv::show::modal', 'low-health');
|
||||||
@@ -346,6 +348,21 @@ export default {
|
|||||||
document.removeEventListener('keydown', this.checkNextCron);
|
document.removeEventListener('keydown', this.checkNextCron);
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
showDeathNotification () {
|
||||||
|
if (this.reviveRunning) return;
|
||||||
|
|
||||||
|
this.reviveRunning = true;
|
||||||
|
this.showNotificationWithModal('DEATH');
|
||||||
|
|
||||||
|
// if there is an api call still running (which removes health)
|
||||||
|
// a call to "revive" wouldn't do anything since the user is still alive on the server
|
||||||
|
// wait a second until the prior api call is done
|
||||||
|
setTimeout(async () => {
|
||||||
|
await axios.post('/api/v4/user/revive');
|
||||||
|
revive(this.user);
|
||||||
|
this.reviveRunning = false;
|
||||||
|
}, 1000);
|
||||||
|
},
|
||||||
showNotificationWithModal (type, forceToModal) {
|
showNotificationWithModal (type, forceToModal) {
|
||||||
const config = NOTIFICATIONS[type];
|
const config = NOTIFICATIONS[type];
|
||||||
|
|
||||||
@@ -380,7 +397,7 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.user.stats.hp <= 0) {
|
if (this.user.stats.hp <= 0) {
|
||||||
this.showNotificationWithModal('DEATH');
|
this.showDeathNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.questCompleted) {
|
if (this.questCompleted) {
|
||||||
|
|||||||
Reference in New Issue
Block a user