Skip to content

Commit

Permalink
Merge branch 'develop' into report-challenge
Browse files Browse the repository at this point in the history
  • Loading branch information
CuriousMagpie committed Jul 18, 2023
2 parents d537cb4 + 8558dcc commit aa97ca4
Show file tree
Hide file tree
Showing 9 changed files with 157 additions and 4 deletions.
2 changes: 1 addition & 1 deletion habitica-images
79 changes: 79 additions & 0 deletions migrations/archive/2023/20230718_summer_splash_orcas.js
Original file line number Diff line number Diff line change
@@ -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
}
};
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "habitica",
"description": "A habit tracker app which treats your goals like a Role Playing Game.",
"version": "4.276.0",
"version": "4.276.2",
"main": "./website/server/index.js",
"dependencies": {
"@babel/core": "^7.22.5",
Expand Down
10 changes: 10 additions & 0 deletions website/client/src/assets/css/sprites/spritesmith-main.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions website/client/src/components/groups/lookingForParty.vue
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@
padding: 8px;
border-radius: 4px;
box-shadow: 0 1px 3px 0 rgba(26, 24, 29, 0.12), 0 1px 2px 0 rgba(26, 24, 29, 0.24);
background-color: $white;
&:first-of-type {
margin-top: 24px;
Expand Down
2 changes: 2 additions & 0 deletions website/common/locales/en/character.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 16 additions & 0 deletions website/server/libs/chat/group-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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('`')) {
Expand Down
47 changes: 46 additions & 1 deletion website/server/libs/spells.js
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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: {
Expand All @@ -250,6 +293,7 @@ async function castSpell (req, res, { isV3 = false }) {
class: klass,
spell: spellId,
target: partyMembers.profile.name,
times: 1,
},
});
await newChatMessage.save();
Expand All @@ -261,6 +305,7 @@ async function castSpell (req, res, { isV3 = false }) {
user: user.profile.name,
class: klass,
spell: spellId,
times: 1,
},
});
await newChatMessage.save();
Expand Down

0 comments on commit aa97ca4

Please sign in to comment.