mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Oct 3 fixes (#9148)
* Only show level after yesterdailies modal * Fixed zindex * Added spcial spells to rewards column * Added single click buy for health and armoire * Prevented task scoring when casting a spell * Renamed generic purchase method * Updated nav for small screen * Hide checklist while casting
This commit is contained in:
@@ -148,14 +148,13 @@ div(v-if='user.stats.lvl > 10')
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
import isArray from 'lodash/isArray';
|
||||
import bPopover from 'bootstrap-vue/lib/directives/popover';
|
||||
|
||||
import spells from '../../../common/script/content/spells';
|
||||
|
||||
import { mapState } from 'client/libs/store';
|
||||
import notifications from 'client/mixins/notifications';
|
||||
import spellsMixin from 'client/mixins/spells';
|
||||
import Drawer from 'client/components/ui/drawer';
|
||||
import MouseMoveDirective from 'client/directives/mouseposition.directive';
|
||||
|
||||
@@ -164,7 +163,7 @@ import quests from 'common/script/content/quests';
|
||||
import { CONSTANTS, setLocalSetting, getLocalSetting } from 'client/libs/userlocalManager';
|
||||
|
||||
export default {
|
||||
mixins: [notifications],
|
||||
mixins: [notifications, spellsMixin],
|
||||
components: {
|
||||
Drawer,
|
||||
},
|
||||
@@ -245,122 +244,6 @@ export default {
|
||||
|
||||
return notes;
|
||||
},
|
||||
async castStart (spell) {
|
||||
if (this.$store.state.spellOptions.castingSpell) {
|
||||
this.castCancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.user.stats.mp < spell.mana) return this.text(this.$t('notEnoughMana'));
|
||||
|
||||
if (spell.immediateUse && this.user.stats.gp < spell.value) {
|
||||
return this.text('Not enough gold.');
|
||||
}
|
||||
|
||||
this.potionClickMode = true;
|
||||
this.applyingAction = true;
|
||||
this.$store.state.spellOptions.castingSpell = true;
|
||||
this.spell = spell;
|
||||
|
||||
if (spell.target === 'self') {
|
||||
this.castEnd(null, spell.target);
|
||||
} else if (spell.target === 'party') {
|
||||
if (!this.user.party._id) {
|
||||
let party = [this.user];
|
||||
this.castEnd(party, spell.target);
|
||||
return;
|
||||
}
|
||||
|
||||
let party = this.$store.state.party.members;
|
||||
party = isArray(party) ? party : [];
|
||||
party = party.concat(this.user);
|
||||
this.castEnd(party, spell.target);
|
||||
} else if (spell.target === 'tasks') {
|
||||
let userTasks = this.$store.state.tasks.data;
|
||||
// exclude rewards
|
||||
let tasks = userTasks.habits
|
||||
.concat(userTasks.dailys)
|
||||
.concat(userTasks.todos);
|
||||
// exclude challenge and group plan tasks
|
||||
tasks = tasks.filter((task) => {
|
||||
if (task.challenge && task.challenge.id && !task.challenge.broken) return false;
|
||||
if (task.group && task.group.id && !task.group.broken) return false;
|
||||
return true;
|
||||
});
|
||||
this.castEnd(tasks, spell.target);
|
||||
}
|
||||
},
|
||||
async castEnd (target, type) {
|
||||
if (!this.$store.state.spellOptions.castingSpell) return;
|
||||
let beforeQuestProgress = this.questProgress();
|
||||
|
||||
if (!this.applyingAction) return 'No applying action';
|
||||
|
||||
if (this.spell.target !== type) return this.text(this.$t('invalidTarget'));
|
||||
if (target && target.type && target.type === 'reward') return this.text(this.$t('invalidTarget'));
|
||||
if (target && target.challenge && target.challenge.id) return this.text(this.$t('invalidTarget'));
|
||||
if (target && target.group && target.group.id) return this.text(this.$t('invalidTarget'));
|
||||
|
||||
// @TODO: just call castCancel?
|
||||
this.$store.state.spellOptions.castingSpell = false;
|
||||
this.potionClickMode = false;
|
||||
|
||||
this.spell.cast(this.user, target);
|
||||
// User.save(); // @TODO:
|
||||
|
||||
let spell = this.spell;
|
||||
let targetId = target ? target._id : null;
|
||||
this.spell = null;
|
||||
this.applyingAction = false;
|
||||
|
||||
let spellUrl = `/api/v3/user/class/cast/${spell.key}`;
|
||||
if (targetId) spellUrl += `?targetId=${targetId}`;
|
||||
|
||||
await axios.post(spellUrl);
|
||||
let msg = this.$t('youCast', {
|
||||
spell: spell.text(),
|
||||
});
|
||||
|
||||
switch (type) {
|
||||
case 'task':
|
||||
msg = this.$t('youCastTarget', {
|
||||
spell: spell.text(),
|
||||
target: target.text,
|
||||
});
|
||||
break;
|
||||
case 'user':
|
||||
msg = this.$t('youCastTarget', {
|
||||
spell: spell.text(),
|
||||
target: target.profile.name,
|
||||
});
|
||||
break;
|
||||
case 'party':
|
||||
msg = this.$t('youCastParty', {
|
||||
spell: spell.text(),
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
this.markdown(msg); // @TODO: mardown directive?
|
||||
// @TODO:
|
||||
let questProgress = this.questProgress() - beforeQuestProgress;
|
||||
if (questProgress > 0) {
|
||||
let userQuest = this.quests[this.user.party.quest.key];
|
||||
if (userQuest.boss) {
|
||||
this.quest('questDamage', questProgress.toFixed(1));
|
||||
} else if (userQuest.collection && userQuest.collect) {
|
||||
this.quest('questCollection', questProgress);
|
||||
}
|
||||
}
|
||||
// @TOOD: User.sync();
|
||||
},
|
||||
castCancel () {
|
||||
this.potionClickMode = false;
|
||||
this.applyingAction = false;
|
||||
this.spell = null;
|
||||
document.querySelector('body').style.cursor = 'initial';
|
||||
this.$store.state.spellOptions.castingSpell = false;
|
||||
},
|
||||
questProgress () {
|
||||
let user = this.user;
|
||||
if (!user.party.quest) return 0;
|
||||
|
||||
Reference in New Issue
Block a user