diff --git a/src/arena/magics/__snapshots__/blight.test.ts.snap b/src/arena/magics/__snapshots__/blight.test.ts.snap new file mode 100644 index 0000000..c3d8853 --- /dev/null +++ b/src/arena/magics/__snapshots__/blight.test.ts.snap @@ -0,0 +1,20 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`blight should hit percentage damage 1`] = `5.95`; + +exports[`blight should hit percentage damage 2`] = ` +[ + { + "action": "Истощение", + "actionType": "dmg-magic", + "dmg": 2.05, + "dmgType": "physical", + "effect": undefined, + "exp": 24, + "hp": 5.95, + "initiator": "asperiores", + "msg": undefined, + "target": "magni", + }, +] +`; diff --git a/src/arena/magics/blight.test.ts b/src/arena/magics/blight.test.ts new file mode 100644 index 0000000..9a15548 --- /dev/null +++ b/src/arena/magics/blight.test.ts @@ -0,0 +1,43 @@ +import casual from 'casual'; +import GameService from '@/arena/GameService'; +import { profsData } from '@/data/profs'; +import { type Char } from '@/models/character'; +import TestUtils from '@/utils/testUtils'; +import blight from './blight'; + +// npm t src/arena/magics/blight.test.ts + +describe('blight', () => { + let game: GameService; + let initiator: Char; + let target: Char; + + beforeAll(async () => { + casual.seed(1); + const harks = { ...profsData.m.hark, wis: 20 }; + + initiator = await TestUtils.createCharacter({ prof: 'm', magics: { blight: 3 }, harks }); + target = await TestUtils.createCharacter(); + }); + + beforeEach(async () => { + game = new GameService([initiator.id, target.id]); + }); + + beforeEach(() => { + jest.spyOn(global.Math, 'random').mockReturnValue(0.15); + }); + + afterEach(() => { + jest.spyOn(global.Math, 'random').mockRestore(); + }); + + it('should hit percentage damage', () => { + game.players.players[0].proc = 1; + + blight.cast(game.players.players[0], game.players.players[1], game); + + expect(game.players.players[1].stats.val('hp')).toMatchSnapshot(); + expect(TestUtils.normalizeRoundHistory(game.getRoundResults())).toMatchSnapshot(); + }); +}); diff --git a/src/arena/magics/blight.ts b/src/arena/magics/blight.ts new file mode 100644 index 0000000..f077a0a --- /dev/null +++ b/src/arena/magics/blight.ts @@ -0,0 +1,48 @@ +import { LongDmgMagic } from '../Constuructors/LongDmgMagicConstructor'; + +/** + * Ледяное прикосновение + * Основное описание магии общее требовани есть в конструкторе + */ +class Blight extends LongDmgMagic { + constructor() { + super({ + name: 'blight', + displayName: 'Истощение', + desc: 'Истощает цель, заставляя ей терять жизни.', + cost: 14, + baseExp: 8, + costType: 'mp', + lvl: 4, + orderType: 'enemy', + aoeType: 'target', + magType: 'bad', + chance: [92, 94, 95], + effect: ['1d10+5', '1d10+10', '1d10+15'], + dmgType: 'physical', + profList: ['m'], + }); + } + + run() { + const { target } = this.params; + const hp = target.stats.val('hp'); + const effectVal = this.effectVal(); + const hit = hp * (effectVal / 100); + + this.status.hit = hit; + target.stats.down('hp', hit); + } + + runLong() { + const { target } = this.params; + const hp = target.stats.val('hp'); + const effectVal = this.effectVal(); + const hit = hp * (effectVal / 100); + + this.status.hit = hit; + target.stats.down('hp', hit); + } +} + +export default new Blight(); diff --git a/src/arena/magics/index.ts b/src/arena/magics/index.ts index 66bef57..95082fd 100644 --- a/src/arena/magics/index.ts +++ b/src/arena/magics/index.ts @@ -25,3 +25,4 @@ export { default as strongHeal } from './strongHeal'; export { default as anathema } from './anathema'; export { default as fireBall } from './fireBall'; export { default as physicalSadness } from './physicalSadness'; +export { default as blight } from './blight';