-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
] | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters