Toggle navigation
Toggle navigation
This project
Loading...
Sign in
조민지
/
2018_2_project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
DESKTOP-PC6TBNS\강환석씨
2018-12-14 03:37:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fbd8c5e8c55e10d06a8e77ebef60611f8d27153f
fbd8c5e8
1 parent
036e2a64
사망확률 수정
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
16 deletions
lib/socketio.js
routes/index.js
views/index.ejs
lib/socketio.js
View file @
fbd8c5e
...
...
@@ -53,7 +53,6 @@ module.exports = (server, app) => {
Heat_index
=
await
req_API
(
"index"
,
"heat"
);
//열지수
Discomport_index
=
await
req_API
(
"index"
,
"th"
);
//불쾌지수
Ultra_Violet_index
=
await
req_API
(
"index"
,
"uv"
);
//자외선지수
console
.
log
(
"bundle"
);
info
=
{
heat
:
Heat_index
.
weather
.
wIndex
.
heatIndex
[
0
].
current
.
index
,
//열지수
...
...
@@ -70,24 +69,23 @@ module.exports = (server, app) => {
time
:
Current_Weather
.
weather
.
minutely
[
0
].
timeObservation
,
// 불러온 시각
death_prob
:
0
//확률
}
console
.
log
(
"callback"
)
console
.
log
(
info
);
console
.
log
(
"API INFO \n"
,
info
);
// ------------------------------ death_prob 정의 ------------------------------
info
.
death_prob
+=
info
.
sky
.
substr
(
5
)
*
1
//하늘 상태에 따라 확률 증가
if
(
info
.
lightning
===
1
)
//낙뢰시에 확률 증가
info
.
death_prob
+=
1
0
;
info
.
death_prob
+=
1
.5
;
if
(
info
.
typhoon
===
"Y"
)
//태풍시에 확률 증가
info
.
death_prob
+=
1
0
;
info
.
death_prob
+=
1
.5
;
if
(
info
.
warning
===
"Y"
)
// 특보 발령시 확률 증가
info
.
death_prob
+=
5
info
.
death_prob
+=
1
//죽을 확률 계산(내맘대로 커스텀)
info
.
death_prob
=
(
(
info
.
heat
/
8
)
+
(
Math
.
abs
(
info
.
sensible_temperature
-
15
)
/
2
)
+
(
info
.
discomport
/
10
)
+
(
info
.
UV
/
5
)
+
(
info
.
windspd
*
3
)
+
(
info
.
rain
/
10
)
+
(
Math
.
abs
(
info
.
current_temperature
-
15
)
/
2
)
(
info
.
heat
/
50
)
+
(
Math
.
abs
(
info
.
sensible_temperature
-
15
)
/
10
)
+
(
info
.
discomport
/
10
)
+
(
info
.
UV
/
10
)
+
info
.
windspd
*
1
+
(
info
.
rain
/
10
)
+
(
Math
.
abs
(
info
.
current_temperature
-
15
)
/
10
)
);
//이벤트 기반으로 일정 시간 간격으로 클라이언트에게 보낼 정보
...
...
@@ -104,13 +102,13 @@ module.exports = (server, app) => {
// 심장이 크게 뛰며 확률이 증가하거나 감소 할 수 있음
Math
.
random
()
*
2
>=
1
?
client_send
.
death
+=
getRandom_add_prob
(
0
,
10
)
:
client_send
.
death
-=
getRandom_add_prob
(
0
,
10
)
;
Math
.
random
()
*
2
>=
1
?
client_send
.
death
+=
getRandom_add_prob
(
0
,
5
)
:
client_send
.
death
-=
getRandom_add_prob
(
0
,
5
)
;
//운명의 장난으로 죽을 확률이 증가하거나 감소함
const
rand
=
Math
.
floor
(
Math
.
random
()
*
6
)
//생년월일 중 한자리 뽑음
Destiny
=
client_birth
.
charAt
(
rand
)
*
1
;
//명시적 형 변환
Destiny
=
client_birth
.
charAt
(
rand
)
/
3
;
//명시적 형 변환
if
(
Destiny
==
0
)
Destiny
=
1
;
//사용자 잘못 입력했을때 예외처리
Math
.
random
()
*
2
>=
1
?
client_send
.
death
+=
Destiny
:
client_send
.
death
-=
Destiny
;
...
...
@@ -120,7 +118,7 @@ module.exports = (server, app) => {
client_send
.
death
=
100
;
}
console
.
log
(
client_send
)
console
.
log
(
"client send data \n"
,
client_send
)
app
.
get
(
"socket"
).
emit
(
"weatherInfo_minutely_send_to_client"
,
client_send
);
// 클라이언트에게 정보 담아서 이벤트 발산
console
.
log
(
"emit"
);
...
...
routes/index.js
View file @
fbd8c5e
...
...
@@ -39,7 +39,6 @@ router.get('/name/:name/birth/:birth', (req,res) => {
{
for
(
var
i
=
rows
.
length
-
1
;
i
>=
0
;
i
--
)
{
console
.
log
(
'kk'
);
probArr
.
unshift
(
rows
[
i
].
prob
);
time
.
unshift
(
rows
[
i
].
time
);
ptArr
.
unshift
(
rows
[
i
].
temperature
);
...
...
views/index.ejs
View file @
fbd8c5e
...
...
@@ -604,24 +604,20 @@ plotOptions: {
x
:
date
,
y
:
info
.
death
});
console
.
log
(
chart1
.
series
[
0
])
chart2
.
series
[
0
].
addPoint
({
x
:
date
,
y
:
info
.
temperature
*
1
});
console
.
log
(
chart2
.
series
[
0
])
chart3
.
series
[
0
].
addPoint
({
x
:
date
,
y
:
info
.
wind
*
1
});
console
.
log
(
chart3
.
series
[
0
])
chart4
.
series
[
0
].
addPoint
({
x
:
date
,
y
:
info
.
rain
*
1
});
console
.
log
(
chart4
.
series
[
0
])
});
...
...
Please
register
or
login
to post a comment