Decrease mana when removing stat points from int (#10713)

* Decrease mana when removing stat points from int

* Revert "Decrease mana when removing stat points from int"

This reverts commit 5e25e13552.

* add mana when stat updates are saved

* don't allow users to deallocate saved stat points in the ui

* use flag to determine whether to add mana points

* add test for not adding mana points when flag is set

* Revert "add test for not adding mana points when flag is set"

This reverts commit 6e8ff36a79.

* Revert "use flag to determine whether to add mana points"

This reverts commit 274e2d0d33.

* Revert "add mana when stat updates are saved"

This reverts commit 422bd49191.

* move client side stat allocation to when save is pressed

* update displayed total stats during editing

* Fix lint errors
This commit is contained in:
Kirsty
2018-10-08 21:11:26 +01:00
committed by Matteo Pagliazzi
parent 67a8eebb96
commit 464cd87736

View File

@@ -99,7 +99,7 @@
span.hint(:popover-title='$t(statInfo.title)', popover-placement='right',
:popover='$t(statInfo.popover)', popover-trigger='mouseenter')
.stat-title(:class='stat') {{ $t(statInfo.title) }}
strong.number {{ statsComputed[stat] | floorWholeNumber }}
strong.number {{totalStatPoints(stat) | floorWholeNumber}}
.col-12.col-md-6
ul.bonus-stats
li
@@ -113,7 +113,7 @@
| {{statsComputed.classBonus[stat]}}
li
strong {{$t('allocated')}}:
| {{user.stats[stat]}}
| {{totalAllocatedStats(stat)}}
li
strong {{$t('buffs')}}:
| {{user.stats.buffs[stat]}}
@@ -124,7 +124,7 @@
h3
| {{$t('statPoints')}}
.counter.badge(v-if='user.stats.points || userLevel100Plus')
| {{user.stats.points}} 
| {{pointsRemaining}} 
.col-12.col-md-6
.float-right
toggle-switch(
@@ -137,7 +137,7 @@
.box.white.row.col-12
.col-9
div(:class='stat') {{ $t(stats[stat].title) }}
.number {{ user.stats[stat] }}
.number {{totalAllocatedStats(stat)}}
.points {{$t('pts')}}
.col-3
div
@@ -157,7 +157,7 @@
import Content from '../../../common/script/content';
import { beastMasterProgress, mountMasterProgress } from '../../../common/script/count';
import autoAllocate from '../../../common/script/fns/autoAllocate';
import allocate from '../../../common/script/ops/stats/allocate';
import allocateBulk from '../../../common/script/ops/stats/allocateBulk';
import statsComputed from '../../../common/script/libs/statsComputed';
import axios from 'axios';
@@ -239,14 +239,27 @@
return this.user.stats.lvl >= 100;
},
showStatsSave () {
const statsAreBeingUpdated = Object.values(this.statUpdates).find(stat => stat > 0);
return Boolean(this.user.stats.points) || statsAreBeingUpdated;
return Boolean(this.user.stats.points);
},
pointsRemaining () {
let points = this.user.stats.points;
Object.values(this.statUpdates).forEach(value => {
points -= value;
});
return points;
},
},
methods: {
getGearTitle (key) {
return this.flatGear[key].text();
},
totalAllocatedStats (stat) {
return this.user.stats[stat] + this.statUpdates[stat];
},
totalStatPoints (stat) {
return this.statsComputed[stat] + this.statUpdates[stat];
},
totalCount (objectToCount) {
let total = size(objectToCount);
return total;
@@ -292,14 +305,12 @@
return display;
},
allocate (stat) {
allocate(this.user, {query: { stat }});
this.statUpdates[stat] += 1;
if (this.pointsRemaining === 0) return;
this.statUpdates[stat]++;
},
deallocate (stat) {
if (this.user.stats[stat] === 0) return;
this.user.stats[stat] -= 1;
this.user.stats.points += 1;
this.statUpdates[stat] -= 1;
if (this.statUpdates[stat] === 0) return;
this.statUpdates[stat]--;
},
async saveAttributes () {
this.loading = true;
@@ -309,10 +320,7 @@
if (this.statUpdates[stat] > 0) statUpdates[stat] = this.statUpdates[stat];
});
await axios.post('/api/v4/user/allocate-bulk', {
stats: statUpdates,
});
// reset statUpdates to zero before request to avoid display errors while waiting for server
this.statUpdates = {
str: 0,
int: 0,
@@ -320,6 +328,12 @@
per: 0,
};
allocateBulk(this.user, { body: { stats: statUpdates } });
await axios.post('/api/v4/user/allocate-bulk', {
stats: statUpdates,
});
this.loading = false;
},
allocateNow () {