-
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
4 changed files
with
112 additions
and
0 deletions.
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
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", | ||
}, | ||
] | ||
`; |
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,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(); | ||
}); | ||
}); |
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,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(); |
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