Showing
2 changed files
with
128 additions
and
23 deletions
| ... | @@ -11,11 +11,13 @@ const itemData = JSON.parse(itemRawData); | ... | @@ -11,11 +11,13 @@ const itemData = JSON.parse(itemRawData); |
| 11 | exports.basicItemFunction = function(req,res){ | 11 | exports.basicItemFunction = function(req,res){ |
| 12 | var responseBody = {}; | 12 | var responseBody = {}; |
| 13 | const itemName = req.body["action"]["params"]["basic_item_name"]; | 13 | const itemName = req.body["action"]["params"]["basic_item_name"]; |
| 14 | + console.log(itemName); | ||
| 14 | if (itemName == undefined){ | 15 | if (itemName == undefined){ |
| 15 | var itemList = ""; | 16 | var itemList = ""; |
| 16 | for (var i = 0; i < itemData.length; ++i){ | 17 | for (var i = 0; i < itemData.length; ++i){ |
| 17 | - if (itemData[i].type == "basic") | 18 | + if (itemData[i].type == "basic"){ |
| 18 | - itemList += (itemData[i].name + '\n'); | 19 | + itemList += (itemData[i].name + '\n'); |
| 20 | + } | ||
| 19 | }; | 21 | }; |
| 20 | responseBody = { | 22 | responseBody = { |
| 21 | "version": "2.0", | 23 | "version": "2.0", |
| ... | @@ -23,7 +25,7 @@ exports.basicItemFunction = function(req,res){ | ... | @@ -23,7 +25,7 @@ exports.basicItemFunction = function(req,res){ |
| 23 | "outputs": [ | 25 | "outputs": [ |
| 24 | { | 26 | { |
| 25 | "simpleText": { | 27 | "simpleText": { |
| 26 | - "text": "원하시는 아이템 이름(줄임말 포함)을 입력하시면 해당 아이템에 대한 정보를 확인할 수 있습니다!\n현재 존재하는 기본 아이템 목록 :\n" + itemList | 28 | + "text": "원하시는 아이템 이름(줄임말 포함)을 입력하시면 해당 아이템에 대한 정보를 확인할 수 있습니다!\n\n현재 존재하는 완성 아이템 목록 :\n" + itemList |
| 27 | 29 | ||
| 28 | } | 30 | } |
| 29 | } | 31 | } |
| ... | @@ -40,22 +42,34 @@ exports.basicItemFunction = function(req,res){ | ... | @@ -40,22 +42,34 @@ exports.basicItemFunction = function(req,res){ |
| 40 | break; | 42 | break; |
| 41 | } | 43 | } |
| 42 | }; | 44 | }; |
| 45 | + | ||
| 46 | + itemPictureNum = "0" + itemData[index].id; | ||
| 47 | + | ||
| 43 | 48 | ||
| 44 | - var itemCombination = {}; | 49 | + console.log(itemData[index].effect); |
| 45 | - for (const elem1 in itemData[index].comination){ | ||
| 46 | - for (var i = 0; i < itemData.length; ++i){ | ||
| 47 | - if (itemData[i].id == elem1){ | ||
| 48 | - for (const elem2 in itemData[i].material){ | ||
| 49 | - for (var j = 0; j < itemData.length; ++i){ | ||
| 50 | - if (itemData[j].id == elem2 && itemData[j].id != itemData[index].id){ | ||
| 51 | - itemCombination += (itemData[index].name + " + " + itemData[j].name + " = " + itemData[i].name + '\n'); | ||
| 52 | - } | ||
| 53 | - } | ||
| 54 | - } | ||
| 55 | 50 | ||
| 51 | + | ||
| 52 | + var itemCombination = ""; | ||
| 53 | + for (var i in itemData[index].combination){ | ||
| 54 | + let left = itemData[index].combination[i].toString().substr(0,1); | ||
| 55 | + let right = itemData[index].combination[i].toString().substr(1,2); | ||
| 56 | + for (var j = 0; j < itemData.length; ++j){ | ||
| 57 | + if (itemData[j].id == left){ | ||
| 58 | + itemCombination += (itemData[j].name + " + "); | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + for (var j = 0; j < itemData.length; ++j){ | ||
| 62 | + if (itemData[j].id == right){ | ||
| 63 | + itemCombination += (itemData[j].name + " = "); | ||
| 64 | + } | ||
| 65 | + } | ||
| 66 | + for (var j = 0; j < itemData.length; ++j){ | ||
| 67 | + if (itemData[j].id == itemData[index].combination[i]){ | ||
| 68 | + itemCombination += (itemData[j].name + '\n'); | ||
| 56 | } | 69 | } |
| 57 | } | 70 | } |
| 58 | } | 71 | } |
| 72 | + | ||
| 59 | responseBody = { | 73 | responseBody = { |
| 60 | "version": "2.0", | 74 | "version": "2.0", |
| 61 | "template": { | 75 | "template": { |
| ... | @@ -63,10 +77,17 @@ exports.basicItemFunction = function(req,res){ | ... | @@ -63,10 +77,17 @@ exports.basicItemFunction = function(req,res){ |
| 63 | { | 77 | { |
| 64 | "basicCard": { | 78 | "basicCard": { |
| 65 | "title": itemName, | 79 | "title": itemName, |
| 66 | - "description": "효과 : " + itemData[i].effect + "\n" + "조합가능한 아이템 : " + itemCombination, | 80 | + "description": "효과 : " + itemData[index].effect + '\n' + "조합가능한 아이템 : \n" + itemCombination, |
| 67 | "thumbnail": { | 81 | "thumbnail": { |
| 68 | - "imageUrl": "http://tft-helper.tk:23023/static/items/" + itemData[index].id + ".png" | 82 | + "imageUrl": "http://tft-helper.tk:23023/static/items/" + itemPictureNum + ".png" |
| 69 | - } | 83 | + }, |
| 84 | + "buttons": [ | ||
| 85 | + { | ||
| 86 | + "action": "block", | ||
| 87 | + "label": "아이템 목록으로 돌아가기", | ||
| 88 | + "blockId": "5ee0d73f127dbe0001aa6647" | ||
| 89 | + } | ||
| 90 | + ] | ||
| 70 | } | 91 | } |
| 71 | } | 92 | } |
| 72 | ] | 93 | ] |
| ... | @@ -79,11 +100,13 @@ exports.basicItemFunction = function(req,res){ | ... | @@ -79,11 +100,13 @@ exports.basicItemFunction = function(req,res){ |
| 79 | exports.completedItemFunction = function(req,res){ | 100 | exports.completedItemFunction = function(req,res){ |
| 80 | var responseBody = {}; | 101 | var responseBody = {}; |
| 81 | const itemName = req.body["action"]["params"]["completed_item_name"]; | 102 | const itemName = req.body["action"]["params"]["completed_item_name"]; |
| 103 | + console.log(itemName); | ||
| 82 | if (itemName == undefined){ | 104 | if (itemName == undefined){ |
| 83 | var itemList = ""; | 105 | var itemList = ""; |
| 84 | for (var i = 0; i < itemData.length; ++i){ | 106 | for (var i = 0; i < itemData.length; ++i){ |
| 85 | - if (itemData[i].type == "completed") | 107 | + if (itemData[i].type == "completed"){ |
| 86 | - itemList += (itemData[i].name + '\n'); | 108 | + itemList += (itemData[i].name + '\n'); |
| 109 | + } | ||
| 87 | }; | 110 | }; |
| 88 | responseBody = { | 111 | responseBody = { |
| 89 | "version": "2.0", | 112 | "version": "2.0", |
| ... | @@ -91,7 +114,7 @@ exports.completedItemFunction = function(req,res){ | ... | @@ -91,7 +114,7 @@ exports.completedItemFunction = function(req,res){ |
| 91 | "outputs": [ | 114 | "outputs": [ |
| 92 | { | 115 | { |
| 93 | "simpleText": { | 116 | "simpleText": { |
| 94 | - "text": "원하시는 아이템 이름(줄임말 포함)을 입력하시면 해당 아이템에 대한 정보를 확인할 수 있습니다!\n현재 존재하는 완성 아이템 목록 :\n" + itemList | 117 | + "text": "원하시는 아이템 이름(줄임말 포함)을 입력하시면 해당 아이템에 대한 정보를 확인할 수 있습니다!\n\n현재 존재하는 완성 아이템 목록 :\n" + itemList |
| 95 | 118 | ||
| 96 | } | 119 | } |
| 97 | } | 120 | } |
| ... | @@ -100,11 +123,58 @@ exports.completedItemFunction = function(req,res){ | ... | @@ -100,11 +123,58 @@ exports.completedItemFunction = function(req,res){ |
| 100 | } | 123 | } |
| 101 | res.status(200).send(responseBody); | 124 | res.status(200).send(responseBody); |
| 102 | } | 125 | } |
| 126 | + else{ | ||
| 127 | + var index = 0; | ||
| 128 | + for (index; index < itemData.length; ++index){ | ||
| 129 | + if(itemData[index].name == itemName){ | ||
| 130 | + break; | ||
| 131 | + } | ||
| 132 | + }; | ||
| 133 | + const itemPictureNum = itemData[index].id; | ||
| 134 | + var itemCombination = (itemName + " = "); | ||
| 135 | + let left = itemData[index].material[0]; | ||
| 136 | + let right = itemData[index].material[1]; | ||
| 137 | + | ||
| 138 | + for (var i = 0; i < itemData.length; ++i){ | ||
| 139 | + if (itemData[i].id == left){ | ||
| 140 | + itemCombination += (itemData[i].name + " + "); | ||
| 141 | + } | ||
| 142 | + if (itemData[i].id == right){ | ||
| 143 | + itemCombination += (itemData[i].name); | ||
| 144 | + } | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + responseBody = { | ||
| 148 | + "version": "2.0", | ||
| 149 | + "template": { | ||
| 150 | + "outputs": [ | ||
| 151 | + { | ||
| 152 | + "basicCard": { | ||
| 153 | + "title": itemName, | ||
| 154 | + "description": "효과 : " + itemData[index].effect + '\n' + "조합식 : \n" + itemCombination, | ||
| 155 | + "thumbnail": { | ||
| 156 | + "imageUrl": "http://tft-helper.tk:23023/static/items/" + itemPictureNum + ".png" | ||
| 157 | + }, | ||
| 158 | + "buttons": [ | ||
| 159 | + { | ||
| 160 | + "action": "block", | ||
| 161 | + "label": "아이템 목록으로 돌아가기", | ||
| 162 | + "blockId": "5ee0d73f127dbe0001aa6647" | ||
| 163 | + } | ||
| 164 | + ] | ||
| 165 | + } | ||
| 166 | + } | ||
| 167 | + ] | ||
| 168 | + } | ||
| 169 | + } | ||
| 170 | + res.status(200).send(responseBody); | ||
| 171 | + } | ||
| 103 | } | 172 | } |
| 104 | 173 | ||
| 105 | exports.consumableItemFunction = function(req,res){ | 174 | exports.consumableItemFunction = function(req,res){ |
| 106 | var responseBody = {}; | 175 | var responseBody = {}; |
| 107 | const itemName = req.body["action"]["params"]["consumable_item_name"]; | 176 | const itemName = req.body["action"]["params"]["consumable_item_name"]; |
| 177 | + console.log(itemName); | ||
| 108 | if (itemName == undefined){ | 178 | if (itemName == undefined){ |
| 109 | responseBody = { | 179 | responseBody = { |
| 110 | "version": "2.0", | 180 | "version": "2.0", |
| ... | @@ -112,7 +182,7 @@ exports.consumableItemFunction = function(req,res){ | ... | @@ -112,7 +182,7 @@ exports.consumableItemFunction = function(req,res){ |
| 112 | "outputs": [ | 182 | "outputs": [ |
| 113 | { | 183 | { |
| 114 | "simpleText": { | 184 | "simpleText": { |
| 115 | - "text": "원하시는 아이템 이름(줄임말 포함)을 입력하시면 해당 아이템에 대한 정보를 확인할 수 있습니다!\n현재 존재하는 완성 아이템 목록 :\n니코의 도움" | 185 | + "text": "원하시는 아이템 이름(줄임말 포함)을 입력하시면 해당 아이템에 대한 정보를 확인할 수 있습니다!\n\n현재 존재하는 완성 아이템 목록 :\n니코의 도움" |
| 116 | 186 | ||
| 117 | } | 187 | } |
| 118 | } | 188 | } |
| ... | @@ -121,4 +191,39 @@ exports.consumableItemFunction = function(req,res){ | ... | @@ -121,4 +191,39 @@ exports.consumableItemFunction = function(req,res){ |
| 121 | } | 191 | } |
| 122 | res.status(200).send(responseBody); | 192 | res.status(200).send(responseBody); |
| 123 | } | 193 | } |
| 124 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 194 | + | ||
| 195 | + else{ | ||
| 196 | + var index = 0; | ||
| 197 | + for (index; index < itemData.length; ++index){ | ||
| 198 | + if(itemData[index].name == itemName){ | ||
| 199 | + break; | ||
| 200 | + } | ||
| 201 | + }; | ||
| 202 | + const itemPictureNum = itemData[index].id; | ||
| 203 | + | ||
| 204 | + responseBody = { | ||
| 205 | + "version": "2.0", | ||
| 206 | + "template": { | ||
| 207 | + "outputs": [ | ||
| 208 | + { | ||
| 209 | + "basicCard": { | ||
| 210 | + "title": itemName, | ||
| 211 | + "description": "효과 : " + itemData[index].effect, | ||
| 212 | + "thumbnail": { | ||
| 213 | + "imageUrl": "http://tft-helper.tk:23023/static/items/" + itemPictureNum + ".png" | ||
| 214 | + }, | ||
| 215 | + "buttons": [ | ||
| 216 | + { | ||
| 217 | + "action": "block", | ||
| 218 | + "label": "아이템 목록으로 돌아가기", | ||
| 219 | + "blockId": "5ee0d73f127dbe0001aa6647" | ||
| 220 | + } | ||
| 221 | + ] | ||
| 222 | + } | ||
| 223 | + } | ||
| 224 | + ] | ||
| 225 | + } | ||
| 226 | + } | ||
| 227 | + res.status(200).send(responseBody); | ||
| 228 | + } | ||
| 229 | +}; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -59,7 +59,7 @@ | ... | @@ -59,7 +59,7 @@ |
| 59 | "type": "basic", | 59 | "type": "basic", |
| 60 | "id": 9, | 60 | "id": 9, |
| 61 | "name": "연습용 장갑", | 61 | "name": "연습용 장갑", |
| 62 | - "effect": "치명타 확률 +10%'\n 회피 확률 +10%", | 62 | + "effect": "치명타 확률 +10%, 회피 확률 +10%", |
| 63 | "combination": [19,29,39,49,59,69,79,89,99] | 63 | "combination": [19,29,39,49,59,69,79,89,99] |
| 64 | }, | 64 | }, |
| 65 | { | 65 | { | ... | ... |
-
Please register or login to post a comment