-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into prosperity
- Loading branch information
Showing
15 changed files
with
2,000 additions
and
74 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -11109,4 +11109,4 @@ | |
"imageURL": "./charaimgs/3030274000_01.png", | ||
"en": "Leona (Summer)" | ||
} | ||
} | ||
} |
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
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,120 @@ | ||
'use strict'; | ||
|
||
|
||
// ported from #201 (not-merged yet) | ||
const zip = (arr, ...args) => | ||
arr.map((val, idx) => args.reduce((x, xs) => [...x, xs[idx]], [val])); | ||
|
||
const sumBy = (arr, key) => | ||
arr.reduce((total, item) => total + item[key], 0); | ||
|
||
|
||
const _strip_arm_name = (name) => name.replace(/\s*\+\s*\w+\s*/, ''); | ||
|
||
/** | ||
* @param {Array<Arm>} arml arm list | ||
* @param {Array<number>} comb combinations | ||
* @return {Array<Arm>} arm list with "count" | ||
*/ | ||
const armListWithCount = (arml, comb) => | ||
zip(arml, comb).map(([arm, count]) => Object.assign({}, arm, {count})); | ||
|
||
/** | ||
* TODO: how to document Types for "higher-order function" | ||
*/ | ||
const genCountWeaponFunc = (func) => (arml, comb) => | ||
sumBy(armListWithCount(arml, comb).filter(func), "count"); | ||
|
||
|
||
// #326 discussion for how to detect epic weapon | ||
const isEpicWeapon = (arm) => arm.series && arm.series === "epic"; | ||
|
||
|
||
const isWandType = (arm) => arm.armType === "wand"; | ||
|
||
|
||
// public | ||
|
||
/** | ||
* @param {Array<Arm>} arml arm list | ||
* @param {Array<number>} comb combinations | ||
* @return {number} count of epic weapon | ||
*/ | ||
const countEpicWeapon = genCountWeaponFunc(isEpicWeapon); | ||
|
||
/** | ||
* @param {Array<Arm>} arml arm list | ||
* @param {Array<number>} comb combinations | ||
* @return {number} count of wand type weapon | ||
*/ | ||
const countWandType = genCountWeaponFunc(isWandType); | ||
|
||
|
||
/** | ||
* @param {Array<Arm>} arml arm list | ||
* @param {Array<number>} comb combinations | ||
* @return {number} is all unique arm name | ||
*/ | ||
const countUniqueArm = (arml, comb) => (new Set( | ||
armListWithCount(arml, comb) | ||
.filter(arm => arm.name && arm.count === 1) | ||
.map(arm => _strip_arm_name(arm.name)))).size; | ||
|
||
/** | ||
* @param {Array<Arm>} arml arm list | ||
* @param {Array<number>} comb combinations | ||
* @return {number} is all unique arm type | ||
*/ | ||
const countUniqueArmType = (arml, comb) => (new Set( | ||
armListWithCount(arml, comb) | ||
.filter(arm => arm.name && arm.count === 1) | ||
.map(arm => arm.armType))).size; | ||
|
||
/** | ||
* @param {Array<number>} comb combinations | ||
* @return {number} count unique arm | ||
*/ | ||
const countComb = (arml, comb) => | ||
armListWithCount(arml, comb) | ||
.filter(arm => arm.name && arm.count > 0).length; | ||
|
||
|
||
/** | ||
* @param {Array<Arm>} arml arm list | ||
* @param {Array<number>} comb combinations | ||
* @return {boolean} is all unique arm | ||
*/ | ||
const isAllUniqueArm = (arml, comb) => | ||
countUniqueArm(arml, comb) === countComb(arml, comb); | ||
|
||
|
||
/** | ||
* @param {Array<Arm>} arml arm list | ||
* @param {Array<number>} comb combinations | ||
* @return {boolean} is all unique arm type | ||
*/ | ||
const isAllUniqueArmType = (arml, comb) => | ||
countUniqueArmType(arml, comb) === 10 && countComb(arml, comb) === 10; | ||
|
||
|
||
// FIXME: it is not enough completed implementation, yet. | ||
// - if arml contained blank data | ||
// - if comb contained value 0 | ||
|
||
// FIXME: this logic can't check following: | ||
// - if same weapon was added as different item, with different Lv or plug bonus etc. | ||
// - Omega, JMP, different colors can be different weapon? Cosmos types too. | ||
|
||
|
||
module.exports = { | ||
_strip_arm_name: _strip_arm_name, | ||
isEpicWeapon: isEpicWeapon, | ||
isWandType: isWandType, | ||
countEpicWeapon: countEpicWeapon, | ||
countWandType: countWandType, | ||
countUniqueArm: countUniqueArm, | ||
countUniqueArmType: countUniqueArmType, | ||
countComb: countComb, | ||
isAllUniqueArm: isAllUniqueArm, | ||
isAllUniqueArmType: isAllUniqueArmType, | ||
}; |
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,130 @@ | ||
|
||
const { | ||
_strip_arm_name, | ||
isEpicWeapon, | ||
isWandType, | ||
countEpicWeapon, | ||
countWandType, | ||
countUniqueArm, | ||
countUniqueArmType, | ||
countComb, | ||
isAllUniqueArm, | ||
isAllUniqueArmType, | ||
} = require('./epic'); | ||
|
||
|
||
// Dummy arm data for tests | ||
const Arm = (armType, name="") => ({name:name||armType, armType}); | ||
const EpicArm = (armType, name="") => Object.assign(Arm(armType, name), {series:"epic"}) | ||
|
||
|
||
describe('New Epic Weapons skills', () => { | ||
|
||
const ALL_ARM_TYPES = ["spear", "bow", "axe", "dagger", "wand", "fist", "sword", "katana", "music", "gun"]; | ||
// console.assert(ALL_ARM_TYPES.length === 10); | ||
|
||
const allUniqueTypes = { | ||
arml: ALL_ARM_TYPES.map(armType => EpicArm(armType, name=armType)), | ||
comb: ALL_ARM_TYPES.map(() => 1), | ||
}; | ||
|
||
describe('#_strip_arm_name', () => { | ||
it('checks ignore plus and whitespaces', () => { | ||
expect(_strip_arm_name("AAA+99")).toBe("AAA"); | ||
expect(_strip_arm_name("AAA +99")).toBe("AAA"); | ||
expect(_strip_arm_name("AAA + 99")).toBe("AAA"); | ||
expect(_strip_arm_name("AAA + 99 ")).toBe("AAA"); | ||
}); | ||
// TODO: ignore lv/slv | ||
// TODO: ignore uncap? (require verification) | ||
// TODO: ignore element change name (require verification) | ||
}); | ||
|
||
describe('#isEpicWeapon', () => { | ||
it('checks the series is "epic"', () => { | ||
expect(isEpicWeapon(EpicArm("sword"))).toBeTruthy(); | ||
expect(isEpicWeapon(Arm("sword"))).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('#isWandType', () => { | ||
it('checks armType is "wand"', () => { | ||
expect(isWandType(EpicArm("wand"))).toBeTruthy(); | ||
expect(isWandType(Arm("wand"))).toBeTruthy(); | ||
expect(isWandType(EpicArm("sword"))).toBeFalsy(); | ||
expect(isWandType(Arm("dagger"))).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('#countEpicWeapon', () => { | ||
it('checks total 3 epic weapons', () => { | ||
const arml = [EpicArm(), EpicArm(), Arm(), Arm()]; | ||
const comb = [1, 2, 2, 1]; | ||
expect(countEpicWeapon(arml, comb)).toBe(3); | ||
}); | ||
}); | ||
|
||
describe('#countWandWeapon', () => { | ||
it('checks total 3 wand weapons', () => { | ||
const arml = [EpicArm("sword"), EpicArm("wand"), Arm("dagger"), Arm("wand")]; | ||
const comb = [1, 2, 2, 1]; | ||
expect(countEpicWeapon(arml, comb)).toBe(3); | ||
}); | ||
}); | ||
|
||
describe('#countUniqueArm', () => { | ||
it('check unique arm', () => { | ||
const arml = [Arm("sword"), Arm("dagger"), Arm("axe"), Arm(), Arm()]; | ||
const comb = [1, 1, 1, 1, 0]; | ||
expect(countUniqueArm(arml, comb)).toBe(3); | ||
expect(isAllUniqueArm(arml, comb)).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
describe('#countComb', () => { | ||
it('checks ignore count 0', () => { | ||
const arml = ["A", "B", "C", "D", "E"].map(type => Arm(type)); | ||
const comb = [1, 0, 1, 2, 0]; | ||
expect(countComb(arml, comb)).toBe(3); | ||
}); | ||
}); | ||
|
||
describe('#isAllUniqueArm', () => { | ||
it('should false if two or more weapons', () => { | ||
const arml = ["A", "B", "C", "D", "E"].map(type => Arm(type)); | ||
const comb = [0, 1, 1, 1, 2]; | ||
expect(countComb(arml, comb)).toBe(4); // count > 0 | ||
expect(countUniqueArm(arml, comb)).toBe(3); // count === 1 | ||
expect(isAllUniqueArm(arml, comb)).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('#isAllUniqueArmType', () => { | ||
it('checks all unique armType and the length 10', () => { | ||
const {arml, comb} = allUniqueTypes; | ||
expect(countUniqueArmType(arml, comb)).toBe(10); | ||
expect(countComb(arml, comb)).toBe(10); | ||
expect(isAllUniqueArm(arml, comb)).toBeTruthy(); | ||
expect(isAllUniqueArmType(arml, comb)).toBeTruthy(); | ||
}); | ||
|
||
it('should ignore blank slots', () => { | ||
// initial setting has blank slots | ||
const arml = [Arm("sword"), Arm("dagger"), Arm("axe"), Arm(), Arm(), Arm()]; | ||
const comb = [1, 1, 1, 1, 1, 1]; | ||
expect(countUniqueArmType(arml, comb)).toBe(3); | ||
expect(countComb(arml, comb)).toBe(3); | ||
expect(isAllUniqueArm(arml, comb)).toBeTruthy(); | ||
expect(isAllUniqueArmType(arml, comb)).toBeFalsy(); | ||
}); | ||
|
||
it('should detect same weapon in different entry', () => { | ||
const arml = [Arm("sword"), Arm("axe", name="AAA"), Arm("axe", name="AAA+99")]; | ||
const comb = [1, 1, 1]; | ||
expect(countUniqueArm(arml, comb)).toBe(2); | ||
expect(countComb(arml, comb)).toBe(3); | ||
expect(isAllUniqueArm(arml, comb)).toBeFalsy(); | ||
expect(isAllUniqueArmType(arml, comb)).toBeFalsy(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.