mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Keys kennel fixes (#9848)
* Show keys to pets immediately * Ensured keys to pets dissapear after use * Added resdirect to stable after purchase * Added mount check and updated keys to mounts and to both * Added api calls * Added check for beastmaster progress * Added mount check for release mounts. Added pets and mount check to release both * Added actions * Added catch to common tests * Added beast count and reload * Removed extra console log
This commit is contained in:
committed by
Sabe Jones
parent
7cff331800
commit
9c9b67aa9d
@@ -41,6 +41,22 @@ describe('shared.ops.releaseBoth', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns an error when user does not have all pets', (done) => {
|
||||||
|
const petKeys = Object.keys(user.items.pets);
|
||||||
|
delete user.items.pets[petKeys[0]];
|
||||||
|
|
||||||
|
const mountKeys = Object.keys(user.items.mounts);
|
||||||
|
delete user.items.mounts[mountKeys[0]];
|
||||||
|
|
||||||
|
try {
|
||||||
|
releaseBoth(user);
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||||
|
expect(err.message).to.equal(i18n.t('notEnoughPetsMounts'));
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('grants triad bingo with gems', () => {
|
it('grants triad bingo with gems', () => {
|
||||||
let message = releaseBoth(user)[1];
|
let message = releaseBoth(user)[1];
|
||||||
|
|
||||||
@@ -79,26 +95,33 @@ describe('shared.ops.releaseBoth', () => {
|
|||||||
it('does not increment beastMasterCount if any pet is level 0 (released)', () => {
|
it('does not increment beastMasterCount if any pet is level 0 (released)', () => {
|
||||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||||
user.items.pets[animal] = 0;
|
user.items.pets[animal] = 0;
|
||||||
|
try {
|
||||||
releaseBoth(user);
|
releaseBoth(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not increment beastMasterCount if any pet is missing (null)', () => {
|
it('does not increment beastMasterCount if any pet is missing (null)', () => {
|
||||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||||
user.items.pets[animal] = null;
|
user.items.pets[animal] = null;
|
||||||
releaseBoth(user);
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
releaseBoth(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not increment beastMasterCount if any pet is missing (undefined)', () => {
|
it('does not increment beastMasterCount if any pet is missing (undefined)', () => {
|
||||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||||
delete user.items.pets[animal];
|
delete user.items.pets[animal];
|
||||||
releaseBoth(user);
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
releaseBoth(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('releases mounts', () => {
|
it('releases mounts', () => {
|
||||||
@@ -112,18 +135,22 @@ describe('shared.ops.releaseBoth', () => {
|
|||||||
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||||
user.items.mounts[animal] = null;
|
user.items.mounts[animal] = null;
|
||||||
|
|
||||||
|
try {
|
||||||
releaseBoth(user);
|
releaseBoth(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.mountMasterCount).to.equal(mountMasterCountBeforeRelease);
|
expect(user.achievements.mountMasterCount).to.equal(mountMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not increase mountMasterCount achievement if mount is missing (undefined)', () => {
|
it('does not increase mountMasterCount achievement if mount is missing (undefined)', () => {
|
||||||
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||||
delete user.items.mounts[animal];
|
delete user.items.mounts[animal];
|
||||||
|
|
||||||
|
try {
|
||||||
releaseBoth(user);
|
releaseBoth(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.mountMasterCount).to.equal(mountMasterCountBeforeRelease);
|
expect(user.achievements.mountMasterCount).to.equal(mountMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('removes drop currentPet', () => {
|
it('removes drop currentPet', () => {
|
||||||
|
|||||||
@@ -35,6 +35,19 @@ describe('shared.ops.releaseMounts', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns an error when user does not have all pets', (done) => {
|
||||||
|
const mountsKeys = Object.keys(user.items.mounts);
|
||||||
|
delete user.items.mounts[mountsKeys[0]];
|
||||||
|
|
||||||
|
try {
|
||||||
|
releaseMounts(user);
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||||
|
expect(err.message).to.equal(i18n.t('notEnoughMounts'));
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('releases mounts', () => {
|
it('releases mounts', () => {
|
||||||
let message = releaseMounts(user)[1];
|
let message = releaseMounts(user)[1];
|
||||||
|
|
||||||
@@ -71,18 +84,22 @@ describe('shared.ops.releaseMounts', () => {
|
|||||||
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||||
user.items.mounts[animal] = null;
|
user.items.mounts[animal] = null;
|
||||||
|
|
||||||
|
try {
|
||||||
releaseMounts(user);
|
releaseMounts(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.mountMasterCount).to.equal(mountMasterCountBeforeRelease);
|
expect(user.achievements.mountMasterCount).to.equal(mountMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not increase mountMasterCount achievement if mount is missing (undefined)', () => {
|
it('does not increase mountMasterCount achievement if mount is missing (undefined)', () => {
|
||||||
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
let mountMasterCountBeforeRelease = user.achievements.mountMasterCount;
|
||||||
delete user.items.mounts[animal];
|
delete user.items.mounts[animal];
|
||||||
|
|
||||||
|
try {
|
||||||
releaseMounts(user);
|
releaseMounts(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.mountMasterCount).to.equal(mountMasterCountBeforeRelease);
|
expect(user.achievements.mountMasterCount).to.equal(mountMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('subtracts gems from balance', () => {
|
it('subtracts gems from balance', () => {
|
||||||
|
|||||||
@@ -35,6 +35,19 @@ describe('shared.ops.releasePets', () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('returns an error when user does not have all pets', (done) => {
|
||||||
|
const petKeys = Object.keys(user.items.pets);
|
||||||
|
delete user.items.pets[petKeys[0]];
|
||||||
|
|
||||||
|
try {
|
||||||
|
releasePets(user);
|
||||||
|
} catch (err) {
|
||||||
|
expect(err).to.be.an.instanceof(NotAuthorized);
|
||||||
|
expect(err.message).to.equal(i18n.t('notEnoughPets'));
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
it('releases pets', () => {
|
it('releases pets', () => {
|
||||||
let message = releasePets(user)[1];
|
let message = releasePets(user)[1];
|
||||||
|
|
||||||
@@ -75,27 +88,35 @@ describe('shared.ops.releasePets', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('does not increment beastMasterCount if any pet is level 0 (released)', () => {
|
it('does not increment beastMasterCount if any pet is level 0 (released)', () => {
|
||||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
const beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||||
|
|
||||||
user.items.pets[animal] = 0;
|
user.items.pets[animal] = 0;
|
||||||
releasePets(user);
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
releasePets(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not increment beastMasterCount if any pet is missing (null)', () => {
|
it('does not increment beastMasterCount if any pet is missing (null)', () => {
|
||||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||||
user.items.pets[animal] = null;
|
user.items.pets[animal] = null;
|
||||||
releasePets(user);
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
releasePets(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('does not increment beastMasterCount if any pet is missing (undefined)', () => {
|
it('does not increment beastMasterCount if any pet is missing (undefined)', () => {
|
||||||
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
let beastMasterCountBeforeRelease = user.achievements.beastMasterCount;
|
||||||
delete user.items.pets[animal];
|
delete user.items.pets[animal];
|
||||||
releasePets(user);
|
|
||||||
|
|
||||||
|
try {
|
||||||
|
releasePets(user);
|
||||||
|
} catch (e) {
|
||||||
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
expect(user.achievements.beastMasterCount).to.equal(beastMasterCountBeforeRelease);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -963,25 +963,21 @@
|
|||||||
this.$root.$emit('bv::show::modal', 'hatching-modal');
|
this.$root.$emit('bv::show::modal', 'hatching-modal');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async feedAction (petKey, foodKey) {
|
async feedAction (petKey, foodKey) {
|
||||||
let result = await this.$store.dispatch('common:feed', {pet: petKey, food: foodKey});
|
const result = await this.$store.dispatch('common:feed', {pet: petKey, food: foodKey});
|
||||||
|
|
||||||
if (result.message) {
|
if (result.message) {
|
||||||
this.text(result.message);
|
this.text(result.message);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
closeHatchPetDialog () {
|
closeHatchPetDialog () {
|
||||||
this.$root.$emit('bv::hide::modal', 'hatching-modal');
|
this.$root.$emit('bv::hide::modal', 'hatching-modal');
|
||||||
},
|
},
|
||||||
|
|
||||||
resetHatchablePet ($event) {
|
resetHatchablePet ($event) {
|
||||||
if (!$event) {
|
if (!$event) {
|
||||||
this.hatchablePet = null;
|
this.hatchablePet = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
onFoodClicked ($event, food) {
|
onFoodClicked ($event, food) {
|
||||||
if (this.currentDraggingFood === null || this.currentDraggingFood !== food) {
|
if (this.currentDraggingFood === null || this.currentDraggingFood !== food) {
|
||||||
this.currentDraggingFood = food;
|
this.currentDraggingFood = food;
|
||||||
@@ -995,7 +991,6 @@
|
|||||||
this.foodClickMode = false;
|
this.foodClickMode = false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
mouseMoved ($event) {
|
mouseMoved ($event) {
|
||||||
if (this.foodClickMode) {
|
if (this.foodClickMode) {
|
||||||
this.$refs.clickFoodInfo.style.left = `${$event.x - 70}px`;
|
this.$refs.clickFoodInfo.style.left = `${$event.x - 70}px`;
|
||||||
|
|||||||
@@ -51,6 +51,9 @@
|
|||||||
span(:class="{'notEnough': notEnoughCurrency}")
|
span(:class="{'notEnough': notEnoughCurrency}")
|
||||||
span.svg-icon.inline.icon-32(aria-hidden="true", v-html="icons[getPriceClass()]")
|
span.svg-icon.inline.icon-32(aria-hidden="true", v-html="icons[getPriceClass()]")
|
||||||
span.cost(:class="getPriceClass()") {{ item.value }}
|
span.cost(:class="getPriceClass()") {{ item.value }}
|
||||||
|
div(v-else)
|
||||||
|
span.svg-icon.inline.icon-32(aria-hidden="true", v-html="icons[getPriceClass()]")
|
||||||
|
span.cost(:class="getPriceClass()") {{ item.value }}
|
||||||
|
|
||||||
.gems-left(v-if='item.key === "gem"')
|
.gems-left(v-if='item.key === "gem"')
|
||||||
strong(v-if='gemsLeft > 0') {{ gemsLeft }} {{ $t('gemsRemaining') }}
|
strong(v-if='gemsLeft > 0') {{ gemsLeft }} {{ $t('gemsRemaining') }}
|
||||||
|
|||||||
@@ -163,7 +163,7 @@
|
|||||||
)
|
)
|
||||||
span.svg-icon.inline.icon-12.color(v-html="icons.pin")
|
span.svg-icon.inline.icon-12.color(v-html="icons.pin")
|
||||||
|
|
||||||
//keys-to-kennel(v-if='category.identifier === "special"')
|
keys-to-kennel(v-if='category.identifier === "special"')
|
||||||
|
|
||||||
div.fill-height
|
div.fill-height
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
:emptyItem="false",
|
:emptyItem="false",
|
||||||
popoverPosition="'top'",
|
popoverPosition="'top'",
|
||||||
@click="releasePets()",
|
@click="releasePets()",
|
||||||
v-if='this.user.achievements.beastMaster'
|
v-if='userHasAllPets'
|
||||||
)
|
)
|
||||||
shopItem(
|
shopItem(
|
||||||
:key="keysToMounts.key",
|
:key="keysToMounts.key",
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
:emptyItem="false",
|
:emptyItem="false",
|
||||||
popoverPosition="'top'",
|
popoverPosition="'top'",
|
||||||
@click="releaseMounts()",
|
@click="releaseMounts()",
|
||||||
v-if='this.user.achievements.mountMaster'
|
v-if='userHasAllMounts'
|
||||||
)
|
)
|
||||||
shopItem(
|
shopItem(
|
||||||
:key="keysToBoth.key",
|
:key="keysToBoth.key",
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
:emptyItem="false",
|
:emptyItem="false",
|
||||||
popoverPosition="'top'",
|
popoverPosition="'top'",
|
||||||
@click="releaseBoth()",
|
@click="releaseBoth()",
|
||||||
v-if='this.user.achievements.mountMaster'
|
v-if='userHasAllPets && userHasAllMounts'
|
||||||
)
|
)
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -61,9 +61,7 @@
|
|||||||
import { mapState } from 'client/libs/store';
|
import { mapState } from 'client/libs/store';
|
||||||
import ShopItem from '../shopItem';
|
import ShopItem from '../shopItem';
|
||||||
|
|
||||||
import releasePets from 'common/script/ops/releasePets';
|
import count from 'common/script/count';
|
||||||
import releaseMounts from 'common/script/ops/releaseMounts';
|
|
||||||
import releaseBoth from 'common/script/ops/releaseBoth';
|
|
||||||
|
|
||||||
import notifications from 'client/mixins/notifications';
|
import notifications from 'client/mixins/notifications';
|
||||||
|
|
||||||
@@ -88,11 +86,14 @@ export default {
|
|||||||
buy: () => {
|
buy: () => {
|
||||||
if (!confirm(this.$t('releasePetsConfirm'))) return;
|
if (!confirm(this.$t('releasePetsConfirm'))) return;
|
||||||
try {
|
try {
|
||||||
releasePets(this.user);
|
this.$store.dispatch('shops:releasePets', {user: this.user});
|
||||||
|
this.text(this.$t('releasePetsSuccess'));
|
||||||
|
// this.$router.push({name: 'stable'});
|
||||||
|
// Reload because achievement is set in user.save instead of common
|
||||||
|
window.location.reload(true);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(err.message);
|
alert(err.message);
|
||||||
}
|
}
|
||||||
this.text(this.$t('releasePetsSuccess'));
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
keysToMounts: {
|
keysToMounts: {
|
||||||
@@ -108,11 +109,14 @@ export default {
|
|||||||
buy: () => {
|
buy: () => {
|
||||||
if (!confirm(this.$t('releaseMountsConfirm'))) return;
|
if (!confirm(this.$t('releaseMountsConfirm'))) return;
|
||||||
try {
|
try {
|
||||||
releaseMounts(this.user);
|
this.$store.dispatch('shops:releaseMounts', {user: this.user});
|
||||||
|
this.text(this.$t('releaseMountsSuccess'));
|
||||||
|
// this.$router.push({name: 'stable'});
|
||||||
|
// Reload because achievement is set in user.save instead of common
|
||||||
|
window.location.reload(true);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(err.message);
|
alert(err.message);
|
||||||
}
|
}
|
||||||
this.text(this.$t('releaseMountsSuccess'));
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
keysToBoth: {
|
keysToBoth: {
|
||||||
@@ -128,17 +132,26 @@ export default {
|
|||||||
buy: () => {
|
buy: () => {
|
||||||
if (!confirm(this.$t('releaseBothConfirm'))) return;
|
if (!confirm(this.$t('releaseBothConfirm'))) return;
|
||||||
try {
|
try {
|
||||||
releaseBoth(this.user);
|
this.$store.dispatch('shops:releaseBoth', {user: this.user});
|
||||||
|
this.text(this.$t('releaseBothSuccess'));
|
||||||
|
// this.$router.push({name: 'stable'});
|
||||||
|
// Reload because achievement is set in user.save instead of common
|
||||||
|
window.location.reload(true);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert(err.message);
|
alert(err.message);
|
||||||
}
|
}
|
||||||
this.text(this.$t('releaseBothSuccess'));
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({user: 'user.data'}),
|
...mapState({user: 'user.data'}),
|
||||||
|
userHasAllPets () {
|
||||||
|
return count.beastCount(this.user.items.pets) === 90;
|
||||||
|
},
|
||||||
|
userHasAllMounts () {
|
||||||
|
return count.mountMasterProgress(this.user.items.mounts) === 90;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
releasePets () {
|
releasePets () {
|
||||||
|
|||||||
@@ -26,8 +26,8 @@ export function hatch (store, params) {
|
|||||||
export async function feed (store, params) {
|
export async function feed (store, params) {
|
||||||
const user = store.state.user.data;
|
const user = store.state.user.data;
|
||||||
feedOp(user, {params});
|
feedOp(user, {params});
|
||||||
let response = await axios
|
|
||||||
.post(`/api/v3/user/feed/${params.pet}/${params.food}`);
|
|
||||||
|
|
||||||
|
const response = await axios
|
||||||
|
.post(`/api/v3/user/feed/${params.pet}/${params.food}`);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ import hourglassPurchaseOp from 'common/script/ops/buy/hourglassPurchase';
|
|||||||
import sellOp from 'common/script/ops/sell';
|
import sellOp from 'common/script/ops/sell';
|
||||||
import unlockOp from 'common/script/ops/unlock';
|
import unlockOp from 'common/script/ops/unlock';
|
||||||
import rerollOp from 'common/script/ops/reroll';
|
import rerollOp from 'common/script/ops/reroll';
|
||||||
|
import releasePetsOp from 'common/script/ops/releasePets';
|
||||||
|
import releaseMountsOp from 'common/script/ops/releaseMounts';
|
||||||
|
import releaseBothOp from 'common/script/ops/releaseBoth';
|
||||||
|
|
||||||
import { getDropClass } from 'client/libs/notifications';
|
import { getDropClass } from 'client/libs/notifications';
|
||||||
|
|
||||||
// @TODO: Purchase means gems and buy means gold. That wording is misused below, but we should also change
|
// @TODO: Purchase means gems and buy means gold. That wording is misused below, but we should also change
|
||||||
@@ -176,3 +180,18 @@ export function sellItems (store, params) {
|
|||||||
sellOp(user, {params, query: {amount: params.amount}});
|
sellOp(user, {params, query: {amount: params.amount}});
|
||||||
axios.post(`/api/v3/user/sell/${params.type}/${params.key}?amount=${params.amount}`);
|
axios.post(`/api/v3/user/sell/${params.type}/${params.key}?amount=${params.amount}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function releasePets (store, params) {
|
||||||
|
releasePetsOp(params.user);
|
||||||
|
axios.post('/api/v3/user/release-pets');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function releaseMounts (store, params) {
|
||||||
|
releaseMountsOp(params.user);
|
||||||
|
axios.post('/api/v3/user/release-mounts');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function releaseBoth (store, params) {
|
||||||
|
releaseBothOp(params.user);
|
||||||
|
axios.post('/api/v3/user/release-both');
|
||||||
|
}
|
||||||
|
|||||||
@@ -138,5 +138,8 @@
|
|||||||
"dragThisPotion": "Drag this <%= potionName %> to an Egg and hatch a new pet!",
|
"dragThisPotion": "Drag this <%= potionName %> to an Egg and hatch a new pet!",
|
||||||
"clickOnEggToHatch": "Click on an Egg to use your <%= potionName %> hatching potion and hatch a new pet!",
|
"clickOnEggToHatch": "Click on an Egg to use your <%= potionName %> hatching potion and hatch a new pet!",
|
||||||
"hatchDialogText": "Pour your <%= potionName %> hatching potion on your <%= eggName %> egg, and it will hatch into a <%= petName %>.",
|
"hatchDialogText": "Pour your <%= potionName %> hatching potion on your <%= eggName %> egg, and it will hatch into a <%= petName %>.",
|
||||||
"clickOnPotionToHatch": "Click on a hatching potion to use it on your <%= eggName %> and hatch a new pet!"
|
"clickOnPotionToHatch": "Click on a hatching potion to use it on your <%= eggName %> and hatch a new pet!",
|
||||||
|
"notEnoughPets": "You have not collected enough pets",
|
||||||
|
"notEnoughMounts": "You have not collected enough mounts",
|
||||||
|
"notEnoughPetsMounts": "You have not collected enough pets and mounts"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,16 @@ function beastMasterProgress (pets = {}) {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function beastCount (pets = {}) {
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
each(DROP_ANIMALS, (animal) => {
|
||||||
|
if (pets[animal] > 0) count++;
|
||||||
|
});
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
function dropPetsCurrentlyOwned (pets = {}) {
|
function dropPetsCurrentlyOwned (pets = {}) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
||||||
@@ -67,6 +77,7 @@ function questsOfCategory (userQuests = {}, category) {
|
|||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
beastMasterProgress,
|
beastMasterProgress,
|
||||||
|
beastCount,
|
||||||
dropPetsCurrentlyOwned,
|
dropPetsCurrentlyOwned,
|
||||||
mountMasterProgress,
|
mountMasterProgress,
|
||||||
remainingGearInSet,
|
remainingGearInSet,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
|
import {beastMasterProgress, mountMasterProgress} from '../count';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import {
|
import {
|
||||||
NotAuthorized,
|
NotAuthorized,
|
||||||
@@ -13,6 +14,10 @@ module.exports = function releaseBoth (user, req = {}, analytics) {
|
|||||||
throw new NotAuthorized(i18n.t('notEnoughGems', req.language));
|
throw new NotAuthorized(i18n.t('notEnoughGems', req.language));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (beastMasterProgress(user.items.pets) !== 90 || mountMasterProgress(user.items.mounts) !== 90) {
|
||||||
|
throw new NotAuthorized(i18n.t('notEnoughPetsMounts', req.language));
|
||||||
|
}
|
||||||
|
|
||||||
let giveTriadBingo = true;
|
let giveTriadBingo = true;
|
||||||
let giveBeastMasterAchievement = true;
|
let giveBeastMasterAchievement = true;
|
||||||
let giveMountMasterAchievement = true;
|
let giveMountMasterAchievement = true;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
|
import {mountMasterProgress} from '../count';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import {
|
import {
|
||||||
NotAuthorized,
|
NotAuthorized,
|
||||||
@@ -9,6 +10,10 @@ module.exports = function releaseMounts (user, req = {}, analytics) {
|
|||||||
throw new NotAuthorized(i18n.t('notEnoughGems', req.language));
|
throw new NotAuthorized(i18n.t('notEnoughGems', req.language));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mountMasterProgress(user.items.mounts) !== 90) {
|
||||||
|
throw new NotAuthorized(i18n.t('notEnoughMounts', req.language));
|
||||||
|
}
|
||||||
|
|
||||||
user.balance -= 1;
|
user.balance -= 1;
|
||||||
|
|
||||||
let giveMountMasterAchievement = true;
|
let giveMountMasterAchievement = true;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import content from '../content/index';
|
import content from '../content/index';
|
||||||
|
import {beastMasterProgress} from '../count';
|
||||||
import i18n from '../i18n';
|
import i18n from '../i18n';
|
||||||
import {
|
import {
|
||||||
NotAuthorized,
|
NotAuthorized,
|
||||||
@@ -9,6 +10,10 @@ module.exports = function releasePets (user, req = {}, analytics) {
|
|||||||
throw new NotAuthorized(i18n.t('notEnoughGems', req.language));
|
throw new NotAuthorized(i18n.t('notEnoughGems', req.language));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (beastMasterProgress(user.items.pets) !== 90) {
|
||||||
|
throw new NotAuthorized(i18n.t('notEnoughPets', req.language));
|
||||||
|
}
|
||||||
|
|
||||||
user.balance -= 1;
|
user.balance -= 1;
|
||||||
|
|
||||||
let giveBeastMasterAchievement = true;
|
let giveBeastMasterAchievement = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user