我正在开发一个编码挑战项目,我不知道如何在下面的Mongo架构中打印一个对象。
我需要知道finishQuest()
中参数的内容是什么,但是在应用程序中根本不会调用脚本。 console.log
在测试中被阻止,因此不能运行节点file.js,因为它使用节点6并且文件具有导入。我从来没有在这么庞大的文件结构中工作过。
schema.methods._processBossQuest = async function processBossQuest
(options) {
let {
user,
progress,
} = options;
let group = this;
let quest = questScrolls[group.quest.key];
let down = progress.down * quest.boss.str; /* multiply by boss
strength */
// Everyone takes damage
let updates = {
$inc: {'stats.hp': down},
};
group.quest.progress.hp -= progress.up;
/* TODO Create a party preferred language option so emits like this
can be localized. Suggestion: Always display the English version
too. Or, if English is not displayed to the players, at least
include it in a new field in the chat object that's visible in the
database - essential for admins when troubleshooting quests!*/
let playerAttack = `${user.profile.name} attacks
${quest.boss.name('en')} for ${progress.up.toFixed(1)} damage.`;
let bossAttack = CRON_SAFE_MODE || CRON_SEMI_SAFE_MODE ?
`${quest.boss.name('en')} does not attack, because it respects the
fact that there are some bugs\` \`post-maintenance and it doesn't
want to hurt anyone unfairly. It will continue its rampage soon!` :
`${quest.boss.name('en')} attacks party for
${Math.abs(down).toFixed(1)} damage.`;
/*TODO Consider putting the safe mode boss attack message in an ENV
var*/
group.sendChat(`\`${playerAttack}\` \`${bossAttack}\``);
/* If boss has Rage, increment Rage as well */
if (quest.boss.rage) {
group.quest.progress.rage += Math.abs(down);
if (group.quest.progress.rage >= quest.boss.rage.value) {
group.sendChat(quest.boss.rage.effect('en'));
group.quest.progress.rage = 0;
/* TODO To make Rage effects more expandable, let's turn these
into functions in quest.boss.rage */
if (quest.boss.rage.healing) group.quest.progress.hp +=
group.quest.progress.hp * quest.boss.rage.healing;
if (group.quest.progress.hp > quest.boss.hp)
group.quest.progress.hp = quest.boss.hp;
if (quest.boss.rage.mpDrain) {
updates.$set = {'stats.mp': 0};
}
}
}
await User.update(
{_id:
{$in: this.getParticipatingQuestMembers()},
},
updates,
{multi: true}
).exec();
/* Apply changes the currently cronning user locally so we don't
have to reload it to get the updated state
// TODO how to mark not modified?
https://github.com/Automattic/mongoose/pull/1167
// must be notModified or otherwise could overwrite future changes:
if the user is saved it'll save
// the modified user.stats.hp but that must not happen as the hp
value has already been updated by the User.update above */
if (down) user.stats.hp += down;
// Boss slain, finish quest
if (group.quest.progress.hp <= 0) {
group.sendChat(`\`You defeated ${quest.boss.name('en')}! Questing
party members receive the rewards of victory.\``);
// Participants: Grant rewards & achievements, finish quest
await group.finishQuest(shared.content.quests[group.quest.key]);
}
return await group.save();
};