Showing
3 changed files
with
9 additions
and
16 deletions
| ... | @@ -53,7 +53,6 @@ module.exports = (server, app) => { | ... | @@ -53,7 +53,6 @@ module.exports = (server, app) => { |
| 53 | Heat_index = await req_API("index", "heat"); //열지수 | 53 | Heat_index = await req_API("index", "heat"); //열지수 |
| 54 | Discomport_index = await req_API("index", "th"); //불쾌지수 | 54 | Discomport_index = await req_API("index", "th"); //불쾌지수 |
| 55 | Ultra_Violet_index = await req_API("index", "uv"); //자외선지수 | 55 | Ultra_Violet_index = await req_API("index", "uv"); //자외선지수 |
| 56 | - console.log("bundle"); | ||
| 57 | 56 | ||
| 58 | info = { | 57 | info = { |
| 59 | heat: Heat_index.weather.wIndex.heatIndex[0].current.index, //열지수 | 58 | heat: Heat_index.weather.wIndex.heatIndex[0].current.index, //열지수 |
| ... | @@ -70,24 +69,23 @@ module.exports = (server, app) => { | ... | @@ -70,24 +69,23 @@ module.exports = (server, app) => { |
| 70 | time: Current_Weather.weather.minutely[0].timeObservation, // 불러온 시각 | 69 | time: Current_Weather.weather.minutely[0].timeObservation, // 불러온 시각 |
| 71 | death_prob: 0 //확률 | 70 | death_prob: 0 //확률 |
| 72 | } | 71 | } |
| 73 | - console.log("callback") | 72 | + console.log("API INFO \n", info); |
| 74 | - console.log(info); | ||
| 75 | 73 | ||
| 76 | // ------------------------------ death_prob 정의 ------------------------------ | 74 | // ------------------------------ death_prob 정의 ------------------------------ |
| 77 | 75 | ||
| 78 | info.death_prob += info.sky.substr(5) * 1 //하늘 상태에 따라 확률 증가 | 76 | info.death_prob += info.sky.substr(5) * 1 //하늘 상태에 따라 확률 증가 |
| 79 | 77 | ||
| 80 | if (info.lightning === 1) //낙뢰시에 확률 증가 | 78 | if (info.lightning === 1) //낙뢰시에 확률 증가 |
| 81 | - info.death_prob += 10; | 79 | + info.death_prob += 1.5; |
| 82 | if (info.typhoon === "Y") //태풍시에 확률 증가 | 80 | if (info.typhoon === "Y") //태풍시에 확률 증가 |
| 83 | - info.death_prob += 10; | 81 | + info.death_prob += 1.5; |
| 84 | if (info.warning === "Y") // 특보 발령시 확률 증가 | 82 | if (info.warning === "Y") // 특보 발령시 확률 증가 |
| 85 | - info.death_prob += 5 | 83 | + info.death_prob += 1 |
| 86 | 84 | ||
| 87 | //죽을 확률 계산(내맘대로 커스텀) | 85 | //죽을 확률 계산(내맘대로 커스텀) |
| 88 | info.death_prob = ( | 86 | info.death_prob = ( |
| 89 | - (info.heat / 8) + (Math.abs(info.sensible_temperature - 15) / 2) + (info.discomport / 10) + (info.UV / 5) | 87 | + (info.heat / 50) + (Math.abs(info.sensible_temperature - 15) / 10) + (info.discomport / 10) + (info.UV / 10) |
| 90 | - + (info.windspd * 3) + (info.rain / 10) + (Math.abs(info.current_temperature - 15) / 2) | 88 | + + info.windspd*1 + (info.rain / 10) + (Math.abs(info.current_temperature - 15) / 10) |
| 91 | ); | 89 | ); |
| 92 | 90 | ||
| 93 | //이벤트 기반으로 일정 시간 간격으로 클라이언트에게 보낼 정보 | 91 | //이벤트 기반으로 일정 시간 간격으로 클라이언트에게 보낼 정보 |
| ... | @@ -104,13 +102,13 @@ module.exports = (server, app) => { | ... | @@ -104,13 +102,13 @@ module.exports = (server, app) => { |
| 104 | 102 | ||
| 105 | 103 | ||
| 106 | // 심장이 크게 뛰며 확률이 증가하거나 감소 할 수 있음 | 104 | // 심장이 크게 뛰며 확률이 증가하거나 감소 할 수 있음 |
| 107 | - Math.random() * 2 >= 1 ? client_send.death += getRandom_add_prob(0,10) : client_send.death -= getRandom_add_prob(0,10) ; | 105 | + Math.random() * 2 >= 1 ? client_send.death += getRandom_add_prob(0,5) : client_send.death -= getRandom_add_prob(0,5) ; |
| 108 | 106 | ||
| 109 | 107 | ||
| 110 | //운명의 장난으로 죽을 확률이 증가하거나 감소함 | 108 | //운명의 장난으로 죽을 확률이 증가하거나 감소함 |
| 111 | const rand = Math.floor(Math.random() * 6) //생년월일 중 한자리 뽑음 | 109 | const rand = Math.floor(Math.random() * 6) //생년월일 중 한자리 뽑음 |
| 112 | 110 | ||
| 113 | - Destiny=client_birth.charAt(rand)*1; //명시적 형 변환 | 111 | + Destiny=client_birth.charAt(rand)/3; //명시적 형 변환 |
| 114 | if(Destiny==0)Destiny=1; //사용자 잘못 입력했을때 예외처리 | 112 | if(Destiny==0)Destiny=1; //사용자 잘못 입력했을때 예외처리 |
| 115 | Math.random() * 2 >= 1 ? client_send.death += Destiny : client_send.death -= Destiny ; | 113 | Math.random() * 2 >= 1 ? client_send.death += Destiny : client_send.death -= Destiny ; |
| 116 | 114 | ||
| ... | @@ -120,7 +118,7 @@ module.exports = (server, app) => { | ... | @@ -120,7 +118,7 @@ module.exports = (server, app) => { |
| 120 | client_send.death = 100; | 118 | client_send.death = 100; |
| 121 | } | 119 | } |
| 122 | 120 | ||
| 123 | - console.log(client_send) | 121 | + console.log("client send data \n",client_send) |
| 124 | 122 | ||
| 125 | app.get("socket").emit("weatherInfo_minutely_send_to_client", client_send); // 클라이언트에게 정보 담아서 이벤트 발산 | 123 | app.get("socket").emit("weatherInfo_minutely_send_to_client", client_send); // 클라이언트에게 정보 담아서 이벤트 발산 |
| 126 | console.log("emit"); | 124 | console.log("emit"); | ... | ... |
| ... | @@ -39,7 +39,6 @@ router.get('/name/:name/birth/:birth', (req,res) => { | ... | @@ -39,7 +39,6 @@ router.get('/name/:name/birth/:birth', (req,res) => { |
| 39 | { | 39 | { |
| 40 | for(var i = rows.length - 1; i >= 0; i--) | 40 | for(var i = rows.length - 1; i >= 0; i--) |
| 41 | { | 41 | { |
| 42 | - console.log('kk'); | ||
| 43 | probArr.unshift(rows[i].prob); | 42 | probArr.unshift(rows[i].prob); |
| 44 | time.unshift(rows[i].time); | 43 | time.unshift(rows[i].time); |
| 45 | ptArr.unshift(rows[i].temperature); | 44 | ptArr.unshift(rows[i].temperature); | ... | ... |
| ... | @@ -604,24 +604,20 @@ plotOptions: { | ... | @@ -604,24 +604,20 @@ plotOptions: { |
| 604 | x: date, | 604 | x: date, |
| 605 | y: info.death | 605 | y: info.death |
| 606 | }); | 606 | }); |
| 607 | -console.log(chart1.series[0]) | ||
| 608 | chart2.series[0].addPoint({ | 607 | chart2.series[0].addPoint({ |
| 609 | x: date, | 608 | x: date, |
| 610 | y: info.temperature*1 | 609 | y: info.temperature*1 |
| 611 | }); | 610 | }); |
| 612 | 611 | ||
| 613 | -console.log(chart2.series[0]) | ||
| 614 | chart3.series[0].addPoint({ | 612 | chart3.series[0].addPoint({ |
| 615 | x: date, | 613 | x: date, |
| 616 | y: info.wind*1 | 614 | y: info.wind*1 |
| 617 | }); | 615 | }); |
| 618 | 616 | ||
| 619 | -console.log(chart3.series[0]) | ||
| 620 | chart4.series[0].addPoint({ | 617 | chart4.series[0].addPoint({ |
| 621 | x: date, | 618 | x: date, |
| 622 | y: info.rain*1 | 619 | y: info.rain*1 |
| 623 | }); | 620 | }); |
| 624 | -console.log(chart4.series[0]) | ||
| 625 | 621 | ||
| 626 | }); | 622 | }); |
| 627 | 623 | ... | ... |
-
Please register or login to post a comment