오윤석

스펙 계산 기능 추가

module.exports = {
'한손검': 1.2,
'한손도끼': 1.2,
'한손둔기': 1.2,
'스태프': 1,
'완드': 1,
'샤이닝 로드': 1.2,
'단검': 1.3,
'케인': 1.3,
'데스페라도': 1.3,
'에너지소드': 1.5,
'소울 슈터': 1.7,
'ESP 리미터': 1.2,
'체인': 1.3,
'매직 건틀렛': 1.2,
'부채': 1.3,
'튜너': 1.3,
'두손검': 1.34,
'두손도끼': 1.34,
'두손둔기': 1.34,
'창': 1.34,
'폴암': 1.49,
'태도': 1.34,
'건틀렛 리볼버': 1.7,
'활': 1.3,
'석궁': 1.35,
'듀얼 보우건': 1.3,
'에인션트 보우': 1.3,
'아대': 1.75,
'건': 1.5,
'너클': 1.7,
'핸드캐논': 1.5
}
\ No newline at end of file
......@@ -144,6 +144,7 @@ const analyzeEquipment = async function(nickname, characterCode, job) {
let damagePercent = 0;
let majorPercent = 0;
let attackPowerPercent = 0;
let weapon = undefined;
const equipmentURLs = [];
$(".tab01_con_wrap .weapon_wrap .item_pot li span a").each(async function() {
equipmentURLs.push("https://maplestory.nexon.com" + $(this).attr("href"));
......@@ -159,13 +160,18 @@ const analyzeEquipment = async function(nickname, characterCode, job) {
const equipmentDom = new JSDOM(equipmentResp.data.view);
const $equipment = (require('jquery'))(equipmentDom.window);
const equipmentType = $equipment(".item_ability .ablilty02:eq(1) .job_name em").text();
if (equipmentType.indexOf("손무기") >= 0 && equipmentType.indexOf("블레이드") < 0 && equipmentType.indexOf("대검") < 0) {
weapon = equipmentType.split(" (")[0];
}
$equipment(".stet_info ul li").each(function() {
const regexMajor1 = new RegExp(`${jobModel[job].major} : \\+(\\d)%`);
const regexMajor2 = new RegExp(`올스탯 : \\+(\\d)%`);
const regexMajor1 = new RegExp(`${jobModel[job].major} : \\+(\\d+)%`);
const regexMajor2 = new RegExp(`올스탯 : \\+(\\d+)%`);
const regexAttackPower = (jobModel[job].major == "INT") ?
new RegExp(`마력 : \\+(\\d)%`) :
new RegExp(`공격력 : \\+(\\d)%`);
const regexDamage = new RegExp(`데미지 : \\+(\\d)%`);
new RegExp(`마력 : \\+(\\d+)%`) :
new RegExp(`공격력 : \\+(\\d+)%`);
const regexDamage = new RegExp(`^데미지 : \\+(\\d+)%`);
if ($(this).find(".stet_th span").text() == "올스탯") {
majorPercent += parseInt($(this).find(".point_td font:eq(0)").text().substring(1));
......@@ -191,7 +197,8 @@ const analyzeEquipment = async function(nickname, characterCode, job) {
majorArcane: majorArcane,
majorPercent: majorPercent,
attackPowerPercent: attackPowerPercent,
damagePercent: damagePercent
damagePercent: damagePercent,
weapon: weapon
};
} catch (error) {
console.log(error);
......@@ -199,6 +206,146 @@ const analyzeEquipment = async function(nickname, characterCode, job) {
}
}
const analyzeStats = function(characterInfo, analysisEquipment) {
const jobModel = require('../model/job');
const job = jobModel[characterInfo.character.job];
const jobDefault = jobModel.default;
const weaponConst = require('../model/weapon')[analysisEquipment.weapon] || 1;
const stats = {
major: {
pure: 0,
percent: analysisEquipment.majorPercent +
job.stats.passive.major.percent +
jobDefault.stats.passive.major.percent,
added: 0
},
minor: characterInfo.stats.minor,
damage: {
all: characterInfo.stats.damageHyper +
analysisEquipment.damagePercent +
job.stats.passive.damage.all +
jobDefault.stats.passive.damage.all,
boss: characterInfo.stats.bossAttackDamage
},
finalDamage: job.stats.passive.finalDamage,
criticalDamage: characterInfo.stats.criticalDamage,
attackPower: {
pure: 0,
percent: analysisEquipment.attackPowerPercent +
job.stats.passive.attackPower.percent
},
ignoreGuard: characterInfo.stats.ignoreGuard
};
stats.major.added = characterInfo.stats.majorHyper +
analysisEquipment.majorArcane;
stats.major.pure = (characterInfo.stats.major - stats.major.added) / (1 + stats.major.percent / 100);
stats.attackPower.pure = characterInfo.stats.statAttackPower * 100 / (characterInfo.stats.major * 4 + stats.minor) / job.jobConst / weaponConst / (1 + stats.attackPower.percent / 100) / (1 + stats.damage.all / 100) / (1 + stats.finalDamage / 100);
return stats;
}
const calculateEfficiency = function(stats, job, weapon) {
const efficiency = {
major: {
pure: 1,
percent: 0
},
attackPower: {
pure: 0,
percent: 0,
},
damage: 0,
criticalDamage: 0,
ignoreGuard: 0
};
const defaultPower = calculatePower(stats, job, weapon);
stats.major.pure += 1;
const majorPure = calculatePower(stats, job, weapon) - defaultPower;
stats.major.pure -= 1;
if (majorPure == 0)
return efficiency;
stats.major.percent += 1;
efficiency.major.percent = (calculatePower(stats, job, weapon) - defaultPower) / majorPure;
stats.major.percent -= 1;
stats.attackPower.pure += 1;
efficiency.attackPower.pure = (calculatePower(stats, job, weapon) - defaultPower) / majorPure;
stats.attackPower.pure -= 1;
stats.attackPower.percent += 1;
efficiency.attackPower.percent = (calculatePower(stats, job, weapon) - defaultPower) / majorPure;
stats.attackPower.percent -= 1;
stats.damage.all += 1;
efficiency.damage = (calculatePower(stats, job, weapon) - defaultPower) / majorPure;
stats.damage.all -= 1;
stats.criticalDamage += 1;
efficiency.criticalDamage = (calculatePower(stats, job, weapon) - defaultPower) / majorPure;
stats.criticalDamage -= 1;
// 곱연산
const ignoreGuardSaved = stats.ignoreGuard;
stats.ignoreGuard = (1 - (1 - stats.ignoreGuard / 100) * 0.99) * 100;
efficiency.ignoreGuard = (calculatePower(stats, job, weapon) - defaultPower) / majorPure;
stats.ignoreGuard = ignoreGuardSaved;
return efficiency;
}
// 버프 적용 스탯 구하기
const getBuffStats = function(stats, job) {
const jobModel = require('../model/job');
const buff = jobModel[job].stats.active;
const defaultBuff = jobModel.default.stats.active;
return {
major: {
pure: stats.major.pure + buff.major.pure,
percent: stats.major.percent + buff.major.percent,
added: stats.major.added
},
minor: stats.minor,
damage: {
all: stats.damage.all + buff.damage.all + defaultBuff.damage.all,
boss: stats.damage.boss + buff.damage.boss + defaultBuff.damage.boss
},
finalDamage: stats.finalDamage,
criticalDamage: stats.criticalDamage + buff.criticalDamage + defaultBuff.criticalDamage,
attackPower: {
pure: stats.attackPower.pure + buff.attackPower.pure,
percent: stats.attackPower.percent + buff.attackPower.percent + defaultBuff.attackPower.percent
},
ignoreGuard: (1 - (1 - (stats.ignoreGuard / 100)) * (1 - (buff.ignoreGuard / 100)) * (1 - (defaultBuff.ignoreGuard / 100))) * 100
};
}
// 크리티컬 데미지, 보스 공격력, 방어율 무시를 반영하여 방어율 300% 몬스터 공격시 데미지 산출 값
const calculatePower = function(stats, job, weapon) {
const jobConst = require('../model/job')[job].jobConst;
const weaponConst = require('../model/weapon')[weapon];
return Math.max(
(
(stats.major.pure * (1 + stats.major.percent / 100) + stats.major.added) * 4 +
stats.minor
) *
0.01 *
(stats.attackPower.pure * (1 + stats.attackPower.percent / 100)) *
jobConst *
weaponConst *
(1 + stats.damage.all / 100 + stats.damage.boss / 100) *
(1 + stats.finalDamage / 100) *
(1.2 + stats.criticalDamage / 100) *
(1 - 3 * (1 - stats.ignoreGuard / 100)),
1);
}
module.exports = {
getCharacter: async function(req, res) {
if (!req.query.nickname) {
......@@ -225,8 +372,21 @@ module.exports = {
res.status(403).send();
return;
}
console.log(analysisEquipment);
res.send(characterInfo);
const stats = analyzeStats(characterInfo, analysisEquipment);
const buffStats = getBuffStats(stats, characterInfo.character.job);
const efficiency = calculateEfficiency(stats, characterInfo.character.job, analysisEquipment.weapon);
const buffEfficiency = calculateEfficiency(buffStats, characterInfo.character.job, analysisEquipment.weapon);
res.send({
default: {
stats: stats,
efficiency: efficiency
},
buff: {
stats: buffStats,
efficiency: buffEfficiency
}
});
}
};
\ No newline at end of file
......