Merge skill casting messages together

This commit is contained in:
Phillip Thelen
2023-07-10 16:27:31 +02:00
parent c7aadede4d
commit 2d71a902f1

View File

@@ -222,6 +222,18 @@ async function castSpell (req, res, { isV3 = false }) {
});
if (party && !spell.silent) {
const lastMessages = await Chat.find({ groupId: group._id })
.limit(1)
.sort('-timestamp')
.exec();
if (lastMessages.size == 1) {
const lastMessage = lastMessages[0];
if (lastMessage.info.spell == spellId && lastMessage.info.user == user.profile.name) {
lastMessage.info.times += 1;
await lastMessage.save();
return;
}
}
if (targetType === 'user') {
const newChatMessage = party.sendChat({
message: `\`${common.i18n.t('chatCastSpellUser', { username: user.profile.name, spell: spell.text(), target: partyMembers.profile.name }, 'en')}\``,
@@ -231,6 +243,7 @@ async function castSpell (req, res, { isV3 = false }) {
class: klass,
spell: spellId,
target: partyMembers.profile.name,
times: 1
},
});
await newChatMessage.save();
@@ -242,6 +255,7 @@ async function castSpell (req, res, { isV3 = false }) {
user: user.profile.name,
class: klass,
spell: spellId,
times: 1
},
});
await newChatMessage.save();