Compare commits

..

12 Commits

Author SHA1 Message Date
SabreCat 8558dcc3a8 4.276.2 2023-07-18 10:34:02 -05:00
SabreCat f8a8b61726 Merge branch 'phillip/chat-skill-merge' into release 2023-07-18 10:33:55 -05:00
SabreCat 067a1de49e fix(lint): newlines, console 2023-07-18 10:20:58 -05:00
SabreCat 65ef3bfeca fix(migration): casing 2023-07-18 10:04:56 -05:00
SabreCat af04657856 feat(event): Summer Splash Orcas 2023-07-18 09:12:28 -05:00
SabreCat 259f7ef588 fix(chat): add default to switch block 2023-07-11 18:25:59 -05:00
SabreCat 106a0c9ed8 fix(chat): collapse repetitive spells for real now 2023-07-11 17:01:17 -05:00
Phillip Thelen 74ba5c0b27 bring merging to MVP 2023-07-11 15:10:50 +02:00
SabreCat bb54a6532d fix(chat): correct bad length check 2023-07-10 15:37:46 -05:00
SabreCat 3c36c59bb3 Merge branch 'develop' into phillip/chat-skill-merge 2023-07-10 15:12:12 -05:00
SabreCat 2308961de6 fix(lint): address fatal errors 2023-07-10 15:11:22 -05:00
Phillip Thelen 2d71a902f1 Merge skill casting messages together 2023-07-10 16:27:31 +02:00
8 changed files with 156 additions and 4 deletions
@@ -0,0 +1,79 @@
/* eslint-disable no-console */
const MIGRATION_NAME = '20230718_summer_splash_orcas';
import { model as User } from '../../../website/server/models/user';
const progressCount = 1000;
let count = 0;
async function updateUser (user) {
count++;
const set = { migration: MIGRATION_NAME };
const push = {};
if (user && user.items && user.items.pets && typeof user.items.pets['Orca-Base'] !== 'undefined') {
return;
} else if (user && user.items && user.items.mounts && typeof user.items.mounts['Orca-Base'] !== 'undefined') {
set['items.pets.Orca-Base'] = 5;
push.notifications = {
type: 'ITEM_RECEIVED',
data: {
icon: 'notif_orca_pet',
title: 'Orcas for Summer Splash!',
text: 'To celebrate Summer Splash, we\'ve given you an Orca Pet!',
destination: 'stable',
},
seen: false,
};
} else {
set['items.mounts.Orca-Base'] = true;
push.notifications = {
type: 'ITEM_RECEIVED',
data: {
icon: 'notif_orca_mount',
title: 'Orcas for Summer Splash!',
text: 'To celebrate Summer Splash, we\'ve given you an Orca Mount!',
destination: 'stable',
},
seen: false,
};
}
if (count % progressCount === 0) console.warn(`${count} ${user._id}`);
return await user.updateOne({ $set: set, $push: push }).exec();
}
export default async function processUsers () {
let query = {
migration: {$ne: MIGRATION_NAME},
'auth.timestamps.loggedin': {$gt: new Date('2023-06-18')},
};
const fields = {
_id: 1,
items: 1,
};
while (true) { // eslint-disable-line no-constant-condition
const users = await User // eslint-disable-line no-await-in-loop
.find(query)
.limit(250)
.sort({_id: 1})
.select(fields)
.exec();
if (users.length === 0) {
console.warn('All appropriate users found and modified.');
console.warn(`\n${count} users processed\n`);
break;
} else {
query._id = {
$gt: users[users.length - 1],
};
}
await Promise.all(users.map(updateUser)); // eslint-disable-line no-await-in-loop
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "habitica",
"version": "4.276.1",
"version": "4.276.2",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "habitica",
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "4.276.1",
"version": "4.276.2",
"main": "./website/server/index.js",
"dependencies": {
"@babel/core": "^7.22.5",
@@ -35848,6 +35848,16 @@
width: 20px;
height: 24px;
}
.notif_orca_mount {
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/notif_orca_mount.png');
width: 28px;
height: 28px;
}
.notif_orca_pet {
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/notif_orca_pet.png');
width: 28px;
height: 28px;
}
.npc_bailey {
background-image: url('https://habitica-assets.s3.amazonaws.com/mobileApp/images/npc_bailey.png');
width: 60px;
+2
View File
@@ -150,6 +150,8 @@
"youCastParty": "You cast <%= spell %> for the party.",
"chatCastSpellParty": "<%= username %> casts <%= spell %> for the party.",
"chatCastSpellUser": "<%= username %> casts <%= spell %> on <%= target %>.",
"chatCastSpellPartyTimes": "<%= username %> casts <%= spell %> for the party <%= times %> times.",
"chatCastSpellUserTimes": "<%= username %> casts <%= spell %> on <%= target %> <%= times %> times.",
"critBonus": "Critical Hit! Bonus: ",
"gainedGold": "You gained some Gold",
"gainedMana": "You gained some Mana",
+16
View File
@@ -85,6 +85,19 @@ export function translateMessage (lang, info) {
msg = shared.i18n.t('chatCastSpellUser', { username: info.user, spell: spells[info.class][info.spell].text(lang), target: info.target }, lang);
break;
case 'spell_cast_party_multi':
msg = shared.i18n.t('chatCastSpellPartyTimes', { username: info.user, spell: spells[info.class][info.spell].text(lang), times: info.times }, lang);
break;
case 'spell_cast_user_multi':
msg = shared.i18n.t('chatCastSpellUserTimes', {
username: info.user,
spell: spells[info.class][info.spell].text(lang),
target: info.target,
times: info.times,
}, lang);
break;
case 'quest_cancel':
msg = shared.i18n.t('chatQuestCancelled', { username: info.user, questName: questScrolls[info.quest].text(lang) }, lang);
break;
@@ -112,6 +125,9 @@ export function translateMessage (lang, info) {
case 'claim_task':
msg = shared.i18n.t('userIsClamingTask', { username: info.user, task: info.task }, lang);
break;
default:
msg = 'Error translating party chat. Unknown message type.';
}
if (!msg.includes('`')) {
+46 -1
View File
@@ -1,4 +1,5 @@
import { model as User } from '../models/user';
import { chatModel as Chat } from '../models/message';
import * as Tasks from '../models/task';
import {
NotFound,
@@ -241,7 +242,49 @@ async function castSpell (req, res, { isV3 = false }) {
});
if (party && !spell.silent) {
if (targetType === 'user') {
const lastMessage = await Chat.findOne({ groupId: party._id })
.sort('-timestamp')
.exec();
if (lastMessage && lastMessage.info.spell === spellId
&& lastMessage.info.user === user.profile.name) {
if (targetType === 'user') {
const newChatMessage = party.sendChat({
message: `\`${common.i18n.t('chatCastSpellUserTimes', {
username: user.profile.name,
spell: spell.text(),
target: partyMembers.profile.name,
times: lastMessage.info.times + 1,
}, 'en')}\``,
info: {
type: 'spell_cast_user_multi',
user: user.profile.name,
class: klass,
spell: spellId,
target: partyMembers.profile.name,
times: lastMessage.info.times + 1,
},
});
await newChatMessage.save();
await lastMessage.remove();
} else {
const newChatMessage = party.sendChat({
message: `\`${common.i18n.t('chatCastSpellPartyTimes', {
username: user.profile.name,
spell: spell.text(),
times: lastMessage.info.times + 1,
}, 'en')}\``,
info: {
type: 'spell_cast_party_multi',
user: user.profile.name,
class: klass,
spell: spellId,
times: lastMessage.info.times + 1,
},
});
await newChatMessage.save();
await lastMessage.remove();
}
} else if (targetType === 'user') {
const newChatMessage = party.sendChat({
message: `\`${common.i18n.t('chatCastSpellUser', { username: user.profile.name, spell: spell.text(), target: partyMembers.profile.name }, 'en')}\``,
info: {
@@ -250,6 +293,7 @@ async function castSpell (req, res, { isV3 = false }) {
class: klass,
spell: spellId,
target: partyMembers.profile.name,
times: 1,
},
});
await newChatMessage.save();
@@ -261,6 +305,7 @@ async function castSpell (req, res, { isV3 = false }) {
user: user.profile.name,
class: klass,
spell: spellId,
times: 1,
},
});
await newChatMessage.save();