mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-13 23:42:12 +00:00
Merge branch 'phillip/chat-skill-merge' into release
This commit is contained in:
commit
f8a8b61726
3 changed files with 64 additions and 1 deletions
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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('`')) {
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Reference in a new issue