Skip to content

Commit

Permalink
Merge branch 'master' into prosperity
Browse files Browse the repository at this point in the history
  • Loading branch information
happypurpleduck committed Sep 16, 2019
2 parents 1c41d80 + 9c10dfc commit 7d426b3
Show file tree
Hide file tree
Showing 15 changed files with 2,000 additions and 74 deletions.
1,505 changes: 1,504 additions & 1 deletion armData.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion charaData.json
Original file line number Diff line number Diff line change
Expand Up @@ -11109,4 +11109,4 @@
"imageURL": "./charaimgs/3030274000_01.png",
"en": "Leona (Summer)"
}
}
}
1 change: 1 addition & 0 deletions css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@
vertical-align: middle;
font-size: 11pt;
text-align: center;
font-family: arial, sans-serif;
}

tbody.result>tr>td:first-child {
Expand Down
24 changes: 21 additions & 3 deletions scripts/arm_data_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -983,6 +983,21 @@
u"チェインフォース": "dark",
}

# New epic weapons
skillnamelist["epic-grandEpic"] = {
u"エピックブランド・ゲイン": "all",
}
skillnamelist["epic-staffResonance"] = {
u"レゾナンス・スタッフ": "all",
}
skillnamelist["epic-heroicTale"] = {
u"ヒロイック・テイル": "all",
}
skillnamelist["epic-absoluteEquality"] = {
u"ソール・イコーリティ": "all",
}


# Character specific weapon
skillnamelist["tsuranukiKiba"] = {u"貫きの牙": "fire"}
skillnamelist["washiouKekkai"] = {u"鷲王の結界": "fire"}
Expand Down Expand Up @@ -1014,6 +1029,10 @@
armtypelist[u"楽器"] = "music"
armtypelist[u"刀"] = "katana"

SERIES = {
u"エピックウェポン": "epic",
}

########################################################################################################################
filename = inspect.getframeinfo(inspect.currentframe()).filename
path = os.path.dirname(os.path.abspath(filename))
Expand Down Expand Up @@ -1132,7 +1151,7 @@ def processCSVdata(csv_file_name, json_data, image_wiki_url_list, image_game_url
newdict["skill3"] = skill3
newdict["element3"] = element3

if index == 9:
elif index == 9:
newdict["minhp"] = int(value)
elif index == 10:
newdict["minattack"] = int(value)
Expand All @@ -1143,8 +1162,7 @@ def processCSVdata(csv_file_name, json_data, image_wiki_url_list, image_game_url
elif index == 13:
pass
elif index == 14:
# category
pass
newdict["series"] = SERIES.get(value, "none")
elif index == 15:
if PROCESS_TYPE_SSR:
if jougen_5_pattern.search(value):
Expand Down
9 changes: 9 additions & 0 deletions src/armlist.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ var Arm = CreateClass({
skill1Detail: 0,
skill2Detail: 0,
skill3Detail: 0,
series: "none",
};
},
componentWillReceiveProps: function (nextProps) {
Expand Down Expand Up @@ -352,6 +353,7 @@ var Arm = CreateClass({
},
treatAddArmFromTemplate: function (state, newarm, considerNum) {
state["name"] = newarm.name;
state["series"] = newarm.series;

var attackCalcFunc = (lv, minlv, atk, minatk, plus, levelWidth) => {
return Math.floor((lv - minlv) * (parseInt(atk) - parseInt(minatk)) / levelWidth + parseInt(minatk) + 5 * parseInt(plus))
Expand Down Expand Up @@ -502,6 +504,13 @@ var Arm = CreateClass({
onChange={this.handleEvent.bind(this, "name")}/>
</td>
</tr>
<tr>
<th className="bg-primary">{intl.translate("カテゴリー", locale)}</th>
<td>
<FormControl componentClass="select" value={this.state.series}
onChange={this.handleSelectEvent.bind(this, "series")}> {selector[locale].series} </FormControl>
</td>
</tr>
<tr>
<th className="bg-primary">{intl.translate("攻撃力", locale)}</th>
<td>
Expand Down
120 changes: 120 additions & 0 deletions src/epic.js
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,
};
130 changes: 130 additions & 0 deletions src/epic.test.js
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();
});
});
});
Loading

0 comments on commit 7d426b3

Please sign in to comment.