Skip to content

Commit

Permalink
Fix mage
Browse files Browse the repository at this point in the history
  • Loading branch information
leaftail1880 committed Jan 6, 2025
1 parent 5d47c5e commit cbd2a7e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/utils/lang.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { MinecraftEnchantmentTypes } from '@minecraft/vanilla-data'
import { inspect } from 'lib/util'
import { blockItemsLangJson, langs, Language } from '../assets/lang'
import { sprintf } from './sprintf'
import { nmspc } from 'lib'

/**
* Converts any minecraft type id to human readable format, e.g. removes minecraft: prefix, replaces _ with spaces and
Expand Down Expand Up @@ -48,7 +49,13 @@ export function langToken(item: { typeId: string } | string) {
* another translated RawMessage
*/
export function translateEnchantment(e: MinecraftEnchantmentTypes | Enchantment): RawText {
const rawtext: RawMessage[] = [{ translate: langToken({ typeId: typeof e === 'string' ? e : e.type.id }) }]
const rawtext: RawMessage[] = [
{
translate: langToken({
typeId: typeof e === 'string' ? e.replace('minecraft:', '') : e.type.id.replace('minecraft:', ''),
}),
},
]
if (typeof e === 'object') {
rawtext.push(
{ text: ' ' },
Expand Down
13 changes: 13 additions & 0 deletions src/modules/places/village-of-explorers/mage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,19 @@ export class Mage extends ShopNpc {
},
)

form.itemModifierSection(
'Улучшить лук',
item => item.typeId.endsWith('bow'),
'любой лук',
(form, slot, item) => {
const ench = this.createEnch(form, item, slot)
const enchs = item.enchantable?.getEnchantments().reduce((p, c) => p + c.level, 1) ?? 1

ench(e.Power, level => new MultiCost().money(level * 20).xp(level * enchs))
ench(e.Flame, level => new MultiCost().money(level * 2000).xp(level * enchs))
},
)

form.itemModifierSection(
'Улучшить броню',
item => ['chestplate', 'leggings', 'boots', 'helmet'].some(e => item.typeId.endsWith(e)),
Expand Down

0 comments on commit cbd2a7e

Please sign in to comment.