Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오윤석
/
maplespec.ga
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
4
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
오윤석
2020-06-06 21:22:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d24e20138fc60abbb4cdc05ddc37a6045697813e
d24e2013
1 parent
ea172c42
기본 스탯정보 분석 기능 추가
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
2 deletions
app/node/package-lock.json
app/node/package.json
app/node/routes/character.js
app/node/package-lock.json
View file @
d24e201
This diff is collapsed. Click to expand it.
app/node/package.json
View file @
d24e201
...
...
@@ -12,6 +12,8 @@
"axios"
:
"^0.19.2"
,
"express"
:
"^4.17.1"
,
"http"
:
"0.0.1-security"
,
"jquery"
:
"^3.5.1"
,
"jsdom"
:
"^16.2.2"
,
"nodemon"
:
"^2.0.4"
}
}
...
...
app/node/routes/character.js
View file @
d24e201
...
...
@@ -17,6 +17,83 @@ const crwalCharacterCode = async function(nickname) {
}
}
const
getCharacterInfo
=
async
function
(
nickname
,
characterCode
)
{
try
{
const
resp
=
await
axios
.
get
(
"https://maplestory.nexon.com/Common/Character/Detail/"
+
encodeURI
(
nickname
)
+
"?p="
+
characterCode
);
if
(
resp
.
data
.
indexOf
(
"공개하지 않은 정보입니다."
)
>
0
)
{
throw
new
Error
(
"private_character"
);
}
const
character
=
{
'nickname'
:
nickname
,
'characterCode'
:
characterCode
};
const
stats
=
{};
const
{
JSDOM
}
=
require
(
'jsdom'
);
const
dom
=
new
JSDOM
(
resp
.
data
);
const
$
=
(
require
(
'jquery'
))(
dom
.
window
);
const
jobModel
=
require
(
'../model/job'
);
const
statModel
=
require
(
'../model/stat'
);
character
.
job
=
$
(
".tab01_con_wrap .table_style01:eq(0) tbody tr:eq(0) td:eq(1) span"
).
text
();
character
.
level
=
parseInt
(
$
(
".char_info dl:eq(0) dd"
).
text
().
substring
(
3
));
const
$statInfo
=
$
(
".tab01_con_wrap .table_style01:eq(1)"
);
$
(
"tbody tr"
,
$statInfo
).
each
(
function
()
{
if
(
$
(
"th"
,
this
).
length
==
1
)
{
if
(
$
(
"th span"
,
this
).
text
()
==
"하이퍼스탯"
)
{
const
values
=
$
(
"td span"
,
this
).
html
().
split
(
"<br>"
);
const
regex
=
new
RegExp
(
`
${
statModel
[
jobModel
[
character
.
job
].
major
].
korean
}
(\\d+) 증가`
);
for
(
let
i
=
0
;
i
<
values
.
length
;
i
++
)
{
const
regexResult
=
regex
.
exec
(
values
[
i
]);
if
(
!
regexResult
)
continue
;
stats
[
'majorHyper'
]
=
parseInt
(
regexResult
[
1
]);
}
}
}
else
{
for
(
let
i
=
0
;
i
<
2
;
i
++
)
{
const
statName
=
$
(
`th:eq(
${
i
}
) span`
,
this
).
text
();
const
value
=
$
(
`td:eq(
${
i
}
) span`
,
this
).
text
().
replace
(
/
\,
/g
,
""
);
switch
(
statName
)
{
case
jobModel
[
character
.
job
].
major
:
stats
[
'major'
]
=
parseInt
(
value
);
break
;
case
jobModel
[
character
.
job
].
minor
:
stats
[
'minor'
]
=
parseInt
(
value
);
break
;
case
"크리티컬 데미지"
:
stats
[
'criticalDamage'
]
=
parseInt
(
value
);
break
;
case
"보스공격력"
:
stats
[
'bossAttackDamage'
]
=
parseInt
(
value
);
break
;
case
"방어율무시"
:
stats
[
'ignoreGuard'
]
=
parseInt
(
value
);
break
;
case
"스탯공격력"
:
stats
[
'statAttackPower'
]
=
parseInt
(
value
.
split
(
' ~ '
)[
1
]);
}
}
}
});
return
{
character
:
character
,
stats
:
stats
};
}
catch
(
error
)
{
console
.
log
(
error
);
return
false
;
}
}
module
.
exports
=
{
getCharacter
:
async
function
(
req
,
res
)
{
if
(
!
req
.
query
.
nickname
)
{
...
...
@@ -32,7 +109,12 @@ module.exports = {
return
;
}
console
.
log
(
characterCode
);
res
.
send
({
text
:
characterCode
});
const
characterInfo
=
await
getCharacterInfo
(
nickname
,
characterCode
);
if
(
!
characterInfo
)
{
res
.
status
(
403
).
send
();
return
;
}
res
.
send
(
characterInfo
);
}
};
\ No newline at end of file
...
...
Please
register
or
login
to post a comment