Compare commits

...

17 Commits

Author SHA1 Message Date
Kalista Payne 150c884485 fix(scoring): deduct 1 minimum when unscoring streak Daily 2026-05-06 22:07:21 -05:00
Kalista Payne 6d6a85aead fix(gp): streaks always add at least 1 2026-05-06 22:00:03 -05:00
Kalista Payne b5a81045c2 fix(lint): just why 2026-05-06 21:45:45 -05:00
Kalista Payne 03d5978163 fix(lint): krangle or no dangle 2026-05-06 21:45:45 -05:00
Kalista Payne 3550754132 fix(lint): max-len, assignment operator 2026-05-06 21:45:45 -05:00
Kalista Payne ced2f9eeac fix(tests): more accurate up/down scoring 2026-05-06 21:45:45 -05:00
Kalista Payne 6343f32f79 fix(tests): lint, expects, correct downscoring for Gold 2026-05-06 21:45:45 -05:00
Kalista Payne 2204885833 fix(test): remove dummy cases 2026-05-06 21:45:45 -05:00
Kalista Payne 225259cd51 fix(numbers): gentler damage taken 2026-05-06 21:45:45 -05:00
Kalista Payne 2a49d2e30e test(numbers): check HP loss 2026-05-06 21:45:45 -05:00
Kalista Payne 3108ae388f fix(numbers): improve fine-grainedness by letting delta be fractional 2026-05-06 21:45:45 -05:00
Kalista Payne 75b589ed56 test(numbers): spit out comparative values 2026-05-06 21:45:45 -05:00
Kalista Payne 30ee26c6ab fix(numbers): don't double round 2026-05-06 21:45:45 -05:00
Kalista Payne b9482c58d5 fix(numbers): round skills, round header Gold, correct tests 2026-05-06 21:45:45 -05:00
Kalista Payne 52606a0efd fix(numbers): integerize FCV and Rewards 2026-05-06 21:45:45 -05:00
Kalista Payne 917afd06a6 fix(numbers): actually subtract 1 MP if -1 < val < 0 2026-05-06 21:41:23 -05:00
Kalista Payne 3a5c22b381 feat(numbers!): rounding 2026-05-06 21:41:23 -05:00
17 changed files with 78 additions and 54 deletions
+3 -3
View File
@@ -274,13 +274,13 @@ describe('Group Model', () => {
expect(Group.prototype.sendChat).to.be.calledOnce;
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: {
bossDamage: '7.5',
bossDamage: '8',
quest: 'whale',
type: 'boss_damage',
user: 'Participating Member',
userDamage: '5.0',
userDamage: '5',
},
});
});
+2 -2
View File
@@ -239,14 +239,14 @@ describe('shared.ops.scoreTask', () => {
});
const firstTaskDelta = ref.afterUser.party.quest.progress.up;
expect(firstTaskDelta).to.be.greaterThan(0);
expect(ref.afterUser._tmp.quest.progressDelta).to.eql(firstTaskDelta);
expect(ref.afterUser._tmp.quest.progressDelta).to.eql(Math.ceil(firstTaskDelta));
scoreTask({
user: ref.afterUser, task: habit, direction: 'up', cron: false,
});
const secondTaskDelta = ref.afterUser.party.quest.progress.up - firstTaskDelta;
expect(secondTaskDelta).to.be.greaterThan(0);
expect(ref.afterUser._tmp.quest.progressDelta).to.eql(secondTaskDelta);
expect(ref.afterUser._tmp.quest.progressDelta).to.eql(Math.ceil(secondTaskDelta));
});
context('habits', () => {
@@ -134,10 +134,10 @@
></div>
{{
(Math.ceil(parseFloat(group.quest.progress.hp) * 100) / 100)
| localizeNumber(user.preferences.language, { toFixed:2 })
| localizeNumber(user.preferences.language, { toFixed: 0 })
}} / {{
parseFloat(questData.boss.hp)
| localizeNumber(user.preferences.language, { toFixed:2 })
| localizeNumber(user.preferences.language, { toFixed: 0 })
}}
<strong>HP</strong>
@@ -160,7 +160,7 @@
{{
(user.party.quest.progress.up || 0)
| floor(10)
| localizeNumber(user.preferences.language, { toFixed:1 })
| localizeNumber(user.preferences.language, { toFixed: 0 })
}}
{{ $t('pendingDamageLabel') }}
</span>
@@ -198,7 +198,7 @@
class="float-left"
>{{ $t('rage') }} {{
parseFloat(group.quest.progress.rage)
| localizeNumber(user.preferences.language, { toFixed: 2 })
| localizeNumber(user.preferences.language, { toFixed: 0 })
}} / {{
questData.boss.rage.value
| localizeNumber(user.preferences.language)
@@ -416,7 +416,7 @@
:aria-label="$t('gold')"
v-html="icons.gold"
></div>
<span>{{ Math.floor(user.stats.gp * 100) / 100 }}</span>
<span>{{ Math.floor(user.stats.gp) }}</span>
</div>
</div>
<div class="form-inline desktop-only">
@@ -177,13 +177,14 @@
></div>
</div>
<input
v-model="task.value"
v-model="taskValue"
class="form-control"
type="number"
required="required"
placeholder="Enter a Value"
step="0.01"
step="1"
min="0"
@blur="validateValue()"
>
</div>
</div>
@@ -1302,6 +1303,7 @@ export default {
secondLink: '<a href="/static/privacy" target="_blank">',
linkClose: '</a>',
},
taskValue: 0,
};
},
computed: {
@@ -1482,8 +1484,9 @@ export default {
if (!this.canSave) return;
if (this.newChecklistItem) this.addChecklistItem();
if (this.task.type === 'reward' && this.task.value === '') {
this.task.value = 0;
if (this.task.type === 'reward') {
this.validateValue();
this.task.value = this.taskValue;
}
if (this.purpose === 'create') {
@@ -1608,6 +1611,10 @@ export default {
this.task.tags.push(tagResult.id);
},
validateValue () {
this.taskValue = Number(this.taskValue);
this.taskValue = Math.floor(this.taskValue);
},
},
};
</script>
@@ -113,7 +113,7 @@ export default {
filters: {
statFloor (value) {
if (value < 1 && value > 0) {
return Math.ceil(value * 10) / 10;
return 1;
}
return Math.floor(value);
},
+3 -3
View File
@@ -1,15 +1,15 @@
import round from './round';
function _convertToThousand (num) {
return `${(num / (10 ** 3)).toFixed(1)}k`;
return `${(num / (10 ** 3)).toFixed(0)}k`;
}
function _convertToMillion (num) {
return `${(num / (10 ** 6)).toFixed(1)}m`;
return `${(num / (10 ** 6)).toFixed(0)}m`;
}
function _convertToBillion (num) {
return `${(num / (10 ** 9)).toFixed(1)}b`;
return `${(num / (10 ** 9)).toFixed(0)}b`;
}
export default function roundBigNumber (num) {
+1 -1
View File
@@ -43,7 +43,7 @@ export function getSign (number) {
}
export function round (number, nDigits) {
return Math.abs(number.toFixed(nDigits || 1));
return Math.abs(number.toFixed(nDigits || 0));
}
export function getXPMessage (val) {
+2 -8
View File
@@ -4,19 +4,13 @@ import {
getDropClass, getXPMessage, getSign, round,
} from '@/libs/notifications';
// See https://stackoverflow.com/questions/4187146/truncate-number-to-two-decimal-places-without-rounding
function toFixedWithoutRounding (num, fixed) {
const re = new RegExp(`^-?\\d+(?:\.\\d{0,${(fixed || -1)}})?`); // eslint-disable-line no-useless-escape
return num.toString().match(re)[0];
}
export const NotificationMixins = {
computed: {
...mapState({ notifications: 'notificationStore' }),
},
methods: {
coins (money) {
return this.round(money, 2);
return this.round(money, 0);
},
crit (val) {
const message = `${this.$t('critBonus')} ${Math.round(val)} %`;
@@ -57,7 +51,7 @@ export const NotificationMixins = {
},
mp (val) {
const cleanMp = `${val}`.replace('-', '').replace('+', '');
this.notify(`${this.sign(val)} ${toFixedWithoutRounding(cleanMp, 1)}`, 'mp', 'glyphicon glyphicon-fire', this.sign(val));
this.notify(`${this.sign(val)} ${cleanMp < 0 ? Math.floor(cleanMp) : Math.ceil(cleanMp)}`, 'mp', 'glyphicon glyphicon-fire', this.sign(val));
},
purchased (itemName) {
this.text(this.$t('purchasedItem', {
+1 -1
View File
@@ -84,7 +84,7 @@ export default {
if (quest && user.party.quest && user.party.quest.key) {
const userQuest = Content.quests[user.party.quest.key];
if (quest.progressDelta && userQuest.boss) {
this.damage(quest.progressDelta.toFixed(1));
this.damage(quest.progressDelta.toFixed(0));
} else if (quest.collection && userQuest.collect) {
user.party.quest.progress.collectedItems += 1;
this.quest('questCollection', quest.collection);
+1 -1
View File
@@ -179,7 +179,7 @@ export default {
if (questProgress > 0) {
const userQuest = quests.quests[this.user.party.quest.key];
if (userQuest.boss) {
this.damage(questProgress.toFixed(1));
this.damage(questProgress.toFixed(0));
} else if (userQuest.collection && userQuest.collect) {
this.quest('questCollection', questProgress);
}
+4 -1
View File
@@ -26,7 +26,10 @@ export default {
// @TODO: Task modal component is mutating a prop
// and that causes issues. We need to not copy the prop similar to group modals
if (this.task) this.checklist = clone(this.task.checklist);
if (this.task) {
this.checklist = clone(this.task.checklist);
this.taskValue = this.task.value;
}
},
},
};
@@ -260,6 +260,9 @@ export default {
} else if (this.restoreValues[stat] > MAX_FIELD_HARD_CAP) {
this.restoreValues[stat] = MAX_FIELD_HARD_CAP;
valid = false;
} else if (!Number.isInteger(this.restoreValues[stat])) {
this.restoreValues[stat] = Math.floor(this.restoreValues[stat]);
valid = false;
}
}
@@ -8,14 +8,14 @@ describe('round big number filter', () => {
});
test('can round thousands', () => {
expect(roundBigNumberFilter(70065)).to.equal('70.1k');
expect(roundBigNumberFilter(70065)).to.equal('70k');
});
test('can round milions', () => {
expect(roundBigNumberFilter(10000987)).to.equal('10.0m');
expect(roundBigNumberFilter(10000987)).to.equal('10m');
});
test('can round bilions', () => {
expect(roundBigNumberFilter(1000000000)).to.equal('1.0b');
expect(roundBigNumberFilter(1000000000)).to.equal('1b');
});
});
+11 -9
View File
@@ -67,7 +67,7 @@ spells.wizard = {
cast (user, target, req) {
let bonus = statsComputed(user).int * crit.crit(user, 'per');
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;
user.party.quest.progress.up += Math.ceil(statsComputed(user).int * 0.1);
updateStats(user, user.stats, req);
@@ -122,9 +122,9 @@ spells.warrior = {
notes: t('spellWarriorSmashNotes'),
cast (user, target) {
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;
user.party.quest.progress.up += diminishingReturns(bonus, 55, 70);
user.party.quest.progress.up += Math.ceil(diminishingReturns(bonus, 55, 70));
},
},
defensiveStance: { // Defensive Stance
@@ -174,7 +174,7 @@ spells.rogue = {
notes: t('spellRoguePickPocketNotes'),
cast (user, target) {
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
@@ -186,8 +186,8 @@ spells.rogue = {
cast (user, target, req) {
const _crit = crit.crit(user, 'str', 0.3);
const bonus = calculateBonus(target.value, statsComputed(user).str, _crit);
user.stats.exp += diminishingReturns(bonus, 75, 50);
user.stats.gp += diminishingReturns(bonus, 18, 75);
user.stats.exp += Math.ceil(diminishingReturns(bonus, 75, 50));
user.stats.gp += Math.ceil(diminishingReturns(bonus, 18, 75));
updateStats(user, user.stats, req);
},
},
@@ -225,7 +225,7 @@ spells.healer = {
notes: t('spellHealerHealNotes'),
cast (user, target, req) {
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;
},
},
@@ -238,7 +238,7 @@ spells.healer = {
cast (user, tasks) {
each(tasks, task => {
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,9 @@ spells.healer = {
notes: t('spellHealerHealAllNotes'),
cast (user, target) {
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;
});
},
+23 -8
View File
@@ -94,7 +94,11 @@ function _calculateReverseDelta (task, direction) {
function _gainMP (user, val) {
val *= user._tmp.crit || 1; // eslint-disable-line no-param-reassign
user.stats.mp += val;
if (val < 0) {
user.stats.mp += Math.floor(val);
} else {
user.stats.mp += Math.ceil(val);
}
if (user.stats.mp >= statsComputed(user).maxMP) user.stats.mp = statsComputed(user).maxMP;
if (user.stats.mp < 0) {
@@ -111,7 +115,11 @@ function _subtractPoints (user, task, stats, delta) {
if (conBonus < 0.1) conBonus = 0.1;
const hpMod = delta * conBonus * task.priority * 2; // constant 2 multiplier for better results
stats.hp += Math.round(hpMod * 10) / 10; // round to 1dp
if (hpMod > -1) {
stats.hp -= 1;
} else {
stats.hp += Math.ceil(hpMod); // round to 0dp
}
return stats.hp;
}
@@ -133,15 +141,18 @@ function _addPoints (user, task, stats, direction, delta) {
if (task.streak) {
const currStreak = direction === 'down' ? task.streak - 1 : task.streak;
const streakBonus = currStreak / 100 + 1; // eg, 1-day streak is 1.01, 2-day is 1.02, etc
const afterStreak = gpMod * streakBonus;
let afterStreak = gpMod * streakBonus;
if (Math.abs(afterStreak - gpMod) < 1) {
afterStreak = direction === 'down' ? gpMod - 1 : gpMod + 1; // min streak bonus of +1
}
if (currStreak > 0 && gpMod > 0) {
// keep this on-hand for later, so we can notify streak-bonus
user._tmp.streakBonus = afterStreak - gpMod;
}
stats.gp += afterStreak;
stats.gp += (direction === 'down' ? Math.floor(afterStreak) : Math.ceil(afterStreak));
} else {
stats.gp += gpMod;
stats.gp += (direction === 'down' ? Math.floor(gpMod) : Math.ceil(gpMod));
}
}
@@ -169,13 +180,17 @@ function _changeTaskValue (user, task, direction, times, cron) {
const prevProgress = user.party.quest.progress.up;
if (task.type === 'todo' || task.type === 'daily') {
user.party.quest.progress.up += nextDelta * _crit * (1 + statsComputed(user).str / 200);
user.party.quest.progress.up += Math.ceil(
nextDelta * _crit * (1 + statsComputed(user).str / 200),
);
} else if (task.type === 'habit') {
user.party.quest.progress.up += nextDelta * _crit * (0.5 + statsComputed(user).str / 400);
user.party.quest.progress.up += Math.ceil(
nextDelta * _crit * (0.5 + statsComputed(user).str / 400),
);
}
if (!user._tmp.quest) user._tmp.quest = {};
user._tmp.quest.progressDelta = user.party.quest.progress.up - prevProgress;
user._tmp.quest.progressDelta = Math.ceil(user.party.quest.progress.up - prevProgress);
}
task.value += nextDelta;
}
+4 -4
View File
@@ -1066,21 +1066,21 @@ schema.methods._processBossQuest = async function processBossQuest (options) {
type: 'boss_dont_attack',
user: user.profile.name,
quest: group.quest.key,
userDamage: progress.up.toFixed(1),
userDamage: progress.up.toFixed(0),
},
});
promises.push(groupMessage.save());
} else {
const groupMessage = await group.sendChat({
message: `\`${shared.i18n.t('chatBossDamage', {
username: user.profile.name, bossName: quest.boss.name('en'), userDamage: progress.up.toFixed(1), bossDamage: Math.abs(down).toFixed(1),
username: user.profile.name, bossName: quest.boss.name('en'), userDamage: progress.up.toFixed(0), bossDamage: Math.abs(down).toFixed(0),
}, user.preferences.language)}\``,
info: {
type: 'boss_damage',
user: user.profile.name,
quest: group.quest.key,
userDamage: progress.up.toFixed(1),
bossDamage: Math.abs(down).toFixed(1),
userDamage: progress.up.toFixed(0),
bossDamage: Math.abs(down).toFixed(0),
},
});
promises.push(groupMessage.save());