This repository has been archived by the owner on Jan 5, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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
58 additions
and
3 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
19 changes: 19 additions & 0 deletions
19
src/containers/item/components/properties/ShieldProperties.ts
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,19 @@ | ||
import ArmourProperties from './ArmourProperties'; | ||
import Stat from '../../../../calculator/Stat'; | ||
import ValueRange from '../../../../calculator/ValueRange'; | ||
import Value from '../../../../calculator/Value'; | ||
|
||
export default class ShieldProperties extends ArmourProperties { | ||
public block() { | ||
const { shield_type } = this.parent.baseitem; | ||
|
||
if (shield_type === undefined) { | ||
throw new Error('shield_type not set in baseitem'); | ||
} | ||
|
||
const { block } = shield_type; | ||
const base_block = new Value([block, block], ['local', 'block']) | ||
|
||
return base_block.augmentWith(Object.values(this.parent.stats())).compute(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/containers/item/components/properties/__tests__/ShieldProperties.ts
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,33 @@ | ||
import { createTables } from '../../../../../__fixtures__/util'; | ||
import ShieldProperties from '../ShieldProperties'; | ||
|
||
const { items, mods } = createTables(); | ||
|
||
it('should consider have a base block', () => { | ||
const buckler = items.fromName('Goathide Buckler'); | ||
|
||
expect((buckler.properties as ShieldProperties).block().value).toEqual(25); | ||
}); | ||
|
||
it('should consider stats that improve block', () => { | ||
const eva_shield = items | ||
.fromName('Goathide Buckler') | ||
.addMod(mods.fromId('AdditionalBlockChance1')); | ||
expect((eva_shield.properties as ShieldProperties).block().value).toEqual([ | ||
26, | ||
28, | ||
]); | ||
|
||
const str_shield = items | ||
.fromName('Goathide Buckler') | ||
.addMod(mods.fromId('AdditionalBlockChance1')) | ||
.addMod( | ||
mods.fromId( | ||
'LocalIncreasedPhysicalDamageReductionRatingPercentAndAdditionalBlockChance1', | ||
), | ||
); | ||
expect((str_shield.properties as ShieldProperties).block().value).toEqual([ | ||
28, | ||
30, | ||
]); | ||
}); |
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