Skip to content

Commit

Permalink
Completed healer quest but unable to renew
Browse files Browse the repository at this point in the history
Fixes #137
  • Loading branch information
brian-gates committed Mar 21, 2022
1 parent 0b13098 commit 27f03d2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 16 deletions.
16 changes: 9 additions & 7 deletions packages/game/src/commands/heal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export const execute = async ({
interaction.user
)

const healer = getUserCharacter(interaction.user)
let character = getUserCharacter(interaction.user)

const result = heal(healer.id, target.id)
const result = heal({ healerId: character.id, targetId: target.id })
if (!result) {
interaction.editReply('No result. This should not happen.')
return
Expand All @@ -45,21 +45,23 @@ export const execute = async ({
}
updateUserQuestProgess(interaction.user, 'healer', result.amount)

character = getUserCharacter(interaction.user)

await interaction.editReply({
embeds: [
new MessageEmbed({
title: `${decoratedName(healer)} ${
healer.id === target.id
? 'self healed'
: 'healed ' + decoratedName(target)
title: `${decoratedName(character)} healed ${
character.id === target.id ? '' : decoratedName(target)
} for ${EmojiModifier('heal', result.amount)}`,
fields: [
hpBarField({
character: target,
adjustment: result.amount,
}),
].concat(
healer.quests.healer ? questProgressField(healer.quests.healer) : []
character.quests.healer
? questProgressField(character.quests.healer)
: []
),
}).setImage(
asset('fantasy', 'magic', 'a glowing hand applying healing magic').s3Url
Expand Down
13 changes: 8 additions & 5 deletions packages/game/src/heal/heal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,15 @@ import store from '@adventure-bot/game/store'
import { healed } from '@adventure-bot/game/store/slices/characters'
import { d6 } from '@adventure-bot/game/utils'

export const heal = (
initiatorId: string,
export function heal({
healerId,
targetId,
}: {
healerId: string
targetId: string
): HealResult | undefined => {
if (isCharacterOnCooldown(initiatorId, 'heal')) return { outcome: 'cooldown' }
const healer = getCharacter(initiatorId)
}): HealResult | undefined {
if (isCharacterOnCooldown(healerId, 'heal')) return { outcome: 'cooldown' }
const healer = getCharacter(healerId)
if (!healer) return
const targetBeforeHeal = getCharacter(targetId)
if (!targetBeforeHeal) return
Expand Down
6 changes: 2 additions & 4 deletions packages/game/src/quest/rewards/healerQuestReward.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { CommandInteraction } from 'discord.js'

import { getUserCharacter } from '@adventure-bot/game/character'
import { buffQuestReward, healerStatus } from '@adventure-bot/game/quest'
import { quests } from '@adventure-bot/game/quest/quests'

export const healerQuestReward = async (
interaction: CommandInteraction
): Promise<void> => {
const quest = getUserCharacter(interaction.user).quests.healer
if (!quest) return
buffQuestReward(interaction, healerStatus, quest)
buffQuestReward(interaction, healerStatus, quests.healer)
}

0 comments on commit 27f03d2

Please sign in to comment.