Skip to content

Commit

Permalink
#149 Blight (#302)
Browse files Browse the repository at this point in the history
  • Loading branch information
kyvg authored Nov 7, 2023
1 parent 2b79c46 commit 1e32c11
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/arena/magics/__snapshots__/blight.test.ts.snap
Original file line number Diff line number Diff line change
@@ -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",
},
]
`;
43 changes: 43 additions & 0 deletions src/arena/magics/blight.test.ts
Original file line number Diff line number Diff line change
@@ -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();
});
});
48 changes: 48 additions & 0 deletions src/arena/magics/blight.ts
Original file line number Diff line number Diff line change
@@ -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();
1 change: 1 addition & 0 deletions src/arena/magics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

0 comments on commit 1e32c11

Please sign in to comment.