mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
fix(numbers): round skills, round header Gold, correct tests
This commit is contained in:
@@ -274,13 +274,13 @@ describe('Group Model', () => {
|
|||||||
|
|
||||||
expect(Group.prototype.sendChat).to.be.calledOnce;
|
expect(Group.prototype.sendChat).to.be.calledOnce;
|
||||||
expect(Group.prototype.sendChat).to.be.calledWith({
|
expect(Group.prototype.sendChat).to.be.calledWith({
|
||||||
message: '`Participating Member attacks Wailing Whale for 5.0 damage. Wailing Whale attacks party for 7.5 damage.`',
|
message: '`Participating Member attacks Wailing Whale for 5 damage. Wailing Whale attacks party for 8 damage.`',
|
||||||
info: {
|
info: {
|
||||||
bossDamage: '7.5',
|
bossDamage: '8',
|
||||||
quest: 'whale',
|
quest: 'whale',
|
||||||
type: 'boss_damage',
|
type: 'boss_damage',
|
||||||
user: 'Participating Member',
|
user: 'Participating Member',
|
||||||
userDamage: '5.0',
|
userDamage: '5',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -416,7 +416,7 @@
|
|||||||
:aria-label="$t('gold')"
|
:aria-label="$t('gold')"
|
||||||
v-html="icons.gold"
|
v-html="icons.gold"
|
||||||
></div>
|
></div>
|
||||||
<span>{{ Math.floor(user.stats.gp * 100) / 100 }}</span>
|
<span>{{ Math.floor(user.stats.gp) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-inline desktop-only">
|
<div class="form-inline desktop-only">
|
||||||
|
|||||||
@@ -1030,7 +1030,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import isNumber from 'lodash/isNumber';
|
|
||||||
import Datepicker from '@/components/ui/datepicker';
|
import Datepicker from '@/components/ui/datepicker';
|
||||||
import toggleCheckbox from '@/components/ui/toggleCheckbox';
|
import toggleCheckbox from '@/components/ui/toggleCheckbox';
|
||||||
import markdownDirective from '@/directives/markdown';
|
import markdownDirective from '@/directives/markdown';
|
||||||
|
|||||||
@@ -8,14 +8,14 @@ describe('round big number filter', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test('can round thousands', () => {
|
test('can round thousands', () => {
|
||||||
expect(roundBigNumberFilter(70065)).to.equal('70.1k');
|
expect(roundBigNumberFilter(70065)).to.equal('70k');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can round milions', () => {
|
test('can round milions', () => {
|
||||||
expect(roundBigNumberFilter(10000987)).to.equal('10.0m');
|
expect(roundBigNumberFilter(10000987)).to.equal('10m');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('can round bilions', () => {
|
test('can round bilions', () => {
|
||||||
expect(roundBigNumberFilter(1000000000)).to.equal('1.0b');
|
expect(roundBigNumberFilter(1000000000)).to.equal('1b');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ spells.wizard = {
|
|||||||
cast (user, target, req) {
|
cast (user, target, req) {
|
||||||
let bonus = statsComputed(user).int * crit.crit(user, 'per');
|
let bonus = statsComputed(user).int * crit.crit(user, 'per');
|
||||||
bonus *= Math.ceil((target.value < 0 ? 1 : target.value + 1) * 0.075);
|
bonus *= Math.ceil((target.value < 0 ? 1 : target.value + 1) * 0.075);
|
||||||
user.stats.exp += diminishingReturns(bonus, 75);
|
user.stats.exp += Math.ceil(diminishingReturns(bonus, 75));
|
||||||
if (!user.party.quest.progress.up) user.party.quest.progress.up = 0;
|
if (!user.party.quest.progress.up) user.party.quest.progress.up = 0;
|
||||||
user.party.quest.progress.up += Math.ceil(statsComputed(user).int * 0.1);
|
user.party.quest.progress.up += Math.ceil(statsComputed(user).int * 0.1);
|
||||||
updateStats(user, user.stats, req);
|
updateStats(user, user.stats, req);
|
||||||
@@ -122,9 +122,9 @@ spells.warrior = {
|
|||||||
notes: t('spellWarriorSmashNotes'),
|
notes: t('spellWarriorSmashNotes'),
|
||||||
cast (user, target) {
|
cast (user, target) {
|
||||||
const bonus = statsComputed(user).str * crit.crit(user, 'con');
|
const bonus = statsComputed(user).str * crit.crit(user, 'con');
|
||||||
target.value += diminishingReturns(bonus, 2.5, 35);
|
target.value += Math.ceil(diminishingReturns(bonus, 2.5, 35));
|
||||||
if (!user.party.quest.progress.up) user.party.quest.progress.up = 0;
|
if (!user.party.quest.progress.up) user.party.quest.progress.up = 0;
|
||||||
user.party.quest.progress.up += diminishingReturns(bonus, 55, 70);
|
user.party.quest.progress.up += Math.ceil(diminishingReturns(bonus, 55, 70));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
defensiveStance: { // Defensive Stance
|
defensiveStance: { // Defensive Stance
|
||||||
@@ -174,7 +174,7 @@ spells.rogue = {
|
|||||||
notes: t('spellRoguePickPocketNotes'),
|
notes: t('spellRoguePickPocketNotes'),
|
||||||
cast (user, target) {
|
cast (user, target) {
|
||||||
const bonus = calculateBonus(target.value, statsComputed(user).per);
|
const bonus = calculateBonus(target.value, statsComputed(user).per);
|
||||||
user.stats.gp += diminishingReturns(bonus, 25, 75);
|
user.stats.gp += Math.ceil(diminishingReturns(bonus, 25, 75));
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
backStab: { // Backstab
|
backStab: { // Backstab
|
||||||
@@ -186,8 +186,8 @@ spells.rogue = {
|
|||||||
cast (user, target, req) {
|
cast (user, target, req) {
|
||||||
const _crit = crit.crit(user, 'str', 0.3);
|
const _crit = crit.crit(user, 'str', 0.3);
|
||||||
const bonus = calculateBonus(target.value, statsComputed(user).str, _crit);
|
const bonus = calculateBonus(target.value, statsComputed(user).str, _crit);
|
||||||
user.stats.exp += diminishingReturns(bonus, 75, 50);
|
user.stats.exp += Math.ceil(diminishingReturns(bonus, 75, 50));
|
||||||
user.stats.gp += diminishingReturns(bonus, 18, 75);
|
user.stats.gp += Math.ceil(diminishingReturns(bonus, 18, 75));
|
||||||
updateStats(user, user.stats, req);
|
updateStats(user, user.stats, req);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -225,7 +225,7 @@ spells.healer = {
|
|||||||
notes: t('spellHealerHealNotes'),
|
notes: t('spellHealerHealNotes'),
|
||||||
cast (user, target, req) {
|
cast (user, target, req) {
|
||||||
if (user.stats.hp >= 50) throw new NotAuthorized(t('messageHealthAlreadyMax')(req.language));
|
if (user.stats.hp >= 50) throw new NotAuthorized(t('messageHealthAlreadyMax')(req.language));
|
||||||
user.stats.hp += (statsComputed(user).con + statsComputed(user).int + 5) * 0.075;
|
user.stats.hp += Math.ceil((statsComputed(user).con + statsComputed(user).int + 5) * 0.075);
|
||||||
if (user.stats.hp > 50) user.stats.hp = 50;
|
if (user.stats.hp > 50) user.stats.hp = 50;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -238,7 +238,7 @@ spells.healer = {
|
|||||||
cast (user, tasks) {
|
cast (user, tasks) {
|
||||||
each(tasks, task => {
|
each(tasks, task => {
|
||||||
if (task.type !== 'reward') {
|
if (task.type !== 'reward') {
|
||||||
task.value += 4 * (statsComputed(user).int / (statsComputed(user).int + 40));
|
task.value += Math.ceil(4 * (statsComputed(user).int / (statsComputed(user).int + 40)));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@@ -263,7 +263,7 @@ spells.healer = {
|
|||||||
notes: t('spellHealerHealAllNotes'),
|
notes: t('spellHealerHealAllNotes'),
|
||||||
cast (user, target) {
|
cast (user, target) {
|
||||||
each(target, member => {
|
each(target, member => {
|
||||||
member.stats.hp += (statsComputed(user).con + statsComputed(user).int + 5) * 0.04;
|
member.stats.hp += Math.ceil((statsComputed(user).con + statsComputed(user).int + 5) * 0.04);
|
||||||
if (member.stats.hp > 50) member.stats.hp = 50;
|
if (member.stats.hp > 50) member.stats.hp = 50;
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ function _calculateDelta (task, direction, cron) {
|
|||||||
nextDelta *= 1 + reduce(task.checklist, (m, i) => m + (i.completed ? 1 : 0), 0);
|
nextDelta *= 1 + reduce(task.checklist, (m, i) => m + (i.completed ? 1 : 0), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (nextDelta < 0) {
|
if (nextDelta > -1 && nextDelta < 0) {
|
||||||
return Math.floor(nextDelta);
|
return Math.floor(nextDelta);
|
||||||
}
|
}
|
||||||
return Math.ceil(nextDelta);
|
return Math.ceil(nextDelta);
|
||||||
|
|||||||
Reference in New Issue
Block a user