Skip to content

Commit

Permalink
#152 Body spirit
Browse files Browse the repository at this point in the history
  • Loading branch information
kyvg committed Nov 4, 2023
1 parent 2b79c46 commit 9b5f039
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/arena/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
'entangle'], // ???
[
'blight',
'body_spirit'], // ????????
'bodySpirit'],
'mirror_reflection',
[
'smallAura',
Expand Down
27 changes: 27 additions & 0 deletions src/arena/magics/__snapshots__/bodySpirit.test.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`bodySpirit should hit target and get mp 1`] = `
[
8,
3.12,
]
`;

exports[`bodySpirit should hit target and get mp 2`] = `2.44`;

exports[`bodySpirit should hit target and get mp 3`] = `
[
{
"action": "Дух тела",
"actionType": "dmg-magic",
"dmg": 4.88,
"dmgType": "physical",
"effect": undefined,
"exp": 47,
"hp": 3.12,
"initiator": "asperiores",
"msg": undefined,
"target": "magni",
},
]
`;
47 changes: 47 additions & 0 deletions src/arena/magics/bodySpirit.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import casual from 'casual';
import CharacterService from '@/arena/CharacterService';
import GameService from '@/arena/GameService';
import TestUtils from '@/utils/testUtils';
import bodySpirit from './bodySpirit';

// npm t src/arena/magics/bodySpirit.test.ts

describe('bodySpirit', () => {
let game: GameService;

beforeAll(() => {
casual.seed(1);
});

beforeEach(async () => {
const initiator = await TestUtils.createCharacter({ prof: 'm', magics: { bodySpirit: 3 } });
const target = await TestUtils.createCharacter();

const charIds = [initiator, target].map(({ id }) => id);

await Promise.all(charIds.map(CharacterService.getCharacterById));

game = new GameService(charIds);
});

beforeEach(() => {
jest.spyOn(global.Math, 'random').mockReturnValue(0.15);
});

afterEach(() => {
jest.spyOn(global.Math, 'random').mockRestore();
});

it('should hit target and get mp', () => {
game.players.players[0].proc = 1;
game.players.players[0].stats.set('mp', bodySpirit.cost);

bodySpirit.cast(game.players.players[0], game.players.players[1], game);

expect(
game.players.players.map((player) => player.stats.val('hp')),
).toMatchSnapshot();
expect(game.players.players[0].stats.val('mp')).toMatchSnapshot();
expect(TestUtils.normalizeRoundHistory(game.getRoundResults())).toMatchSnapshot();
});
});
34 changes: 34 additions & 0 deletions src/arena/magics/bodySpirit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { DmgMagic } from '../Constuructors/DmgMagicConstructor';

const damageToManaMultiplier = 0.5;

class Blessing extends DmgMagic {
constructor() {
super({
name: 'bodySpirit',
displayName: 'Дух тела',
desc: 'Забирает жизнь цели, и превращает в ману кастующего',
cost: 22,
baseExp: 8,
costType: 'mp',
lvl: 4,
orderType: 'all',
aoeType: 'target',
magType: 'bad',
dmgType: 'physical',
chance: [92, 94, 95],
effect: ['1d4', '1d5+2', '1d6+3'],
profList: ['m'],
});
}

run() {
const { initiator, target } = this.params;

const effectVal = this.effectVal();
target.stats.down('hp', effectVal);
initiator.stats.up('mp', effectVal * damageToManaMultiplier);
}
}

export default new Blessing();
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 bodySpirit } from './bodySpirit';

0 comments on commit 9b5f039

Please sign in to comment.