김동근

거의 끝

...@@ -10,7 +10,13 @@ let globalDecks ...@@ -10,7 +10,13 @@ let globalDecks
10 //result.ejs 렌더링 전 수행됨. 현재 덱 ID와 상대 직업을 가지고 상대의 점유율 상위 3개 덱과, 내 덱의 추천 멀리건 출력 10 //result.ejs 렌더링 전 수행됨. 현재 덱 ID와 상대 직업을 가지고 상대의 점유율 상위 3개 덱과, 내 덱의 추천 멀리건 출력
11 //return : 렌더링 된 result.ejs 11 //return : 렌더링 된 result.ejs
12 exports.GetResults=(req,res)=>{ 12 exports.GetResults=(req,res)=>{
13 - //const opponentClass=req.session.opponentClass 13 + const mineClass = req.body.MineClass
14 + const name1 = req.body.value1
15 + const name2 = req.body.value2
16 + const name3 = req.body.value3
17 + const names = [name1, name2, name3]
18 + req.session.names = names
19 + const opponentClass=req.session.opponentClass
14 //덱 ID와 상대 직업 정보 체크 20 //덱 ID와 상대 직업 정보 체크
15 const DataCheck=()=>{ 21 const DataCheck=()=>{
16 return new Promise((resolve,reject)=>{ 22 return new Promise((resolve,reject)=>{
...@@ -28,42 +34,7 @@ exports.GetResults=(req,res)=>{ ...@@ -28,42 +34,7 @@ exports.GetResults=(req,res)=>{
28 return getCardId.GetCardId(deckId) 34 return getCardId.GetCardId(deckId)
29 } 35 }
30 //가져온 카드 정보를 바탕으로, hsreplay.net에서, 덱 검색하기, 검색한 결과의 html을 반환 36 //가져온 카드 정보를 바탕으로, hsreplay.net에서, 덱 검색하기, 검색한 결과의 html을 반환
31 - const GetMulContent=()=>{ 37 +
32 - //cardIds=JSON.stringify(cardIds)
33 - //cardIds=JSON.parse(cardIds)
34 -
35 - return new Promise((resolve,reject)=>{
36 - const asyncFunc=async ()=>{
37 - const browser=await puppeteer.launch()
38 - try{
39 - const page=await browser.newPage()
40 - await page.setViewport({width:1366,height:768})
41 - await page.goto(`https://www.heartharena.com/ko/tierlist`,{waitUntil: 'networkidle2'})
42 - let index = 0
43 - if(opponentClass == "DRUID"){ index = 1 }
44 - else if(opponentClass == "HUNTER"){ index = 2 }
45 - else if(opponentClass == "MAGE"){ index = 3 }
46 - else if(opponentClass == "PALADIN"){ index = 4 }
47 - else if(opponentClass == "PRIEST"){ index = 5 }
48 - else if(opponentClass == "ROGUE"){ index = 6 }
49 - else if(opponentClass == "SHAMAN"){ index = 7 }
50 - else if(opponentClass == "WARLOCK"){ index = 8 }
51 - else if(opponentClass == "WARRIOR"){ index = 9 }
52 - if(index != 1)
53 - await page.click('#tier-list > div > section.navs > section.tierlist-selection > nav > ul > li:nth-child(' + index)
54 - const content=await page.content()
55 - browser.close()
56 - return content
57 - }
58 - catch(err)
59 - {
60 - console.log(err)
61 - browser.close()
62 - }
63 - }
64 - resolve(asyncFunc())
65 - })
66 - }
67 //검색한 html을 가지고, 검색결과로 부터 덱의 url 파싱 38 //검색한 html을 가지고, 검색결과로 부터 덱의 url 파싱
68 const GetDeckHref=(content)=>{ 39 const GetDeckHref=(content)=>{
69 return new Promise((resolve,reject)=>{ 40 return new Promise((resolve,reject)=>{
...@@ -128,18 +99,6 @@ exports.GetResults=(req,res)=>{ ...@@ -128,18 +99,6 @@ exports.GetResults=(req,res)=>{
128 const page=await browser.newPage() 99 const page=await browser.newPage()
129 await page.setViewport({width:1366,height:768}) 100 await page.setViewport({width:1366,height:768})
130 await page.goto(`https://www.heartharena.com/ko/tierlist`,{waitUntil: 'networkidle2'}) 101 await page.goto(`https://www.heartharena.com/ko/tierlist`,{waitUntil: 'networkidle2'})
131 - let index = 0
132 - if(opponentClass == "DRUID"){ index = 1 }
133 - else if(opponentClass == "HUNTER"){ index = 2 }
134 - else if(opponentClass == "MAGE"){ index = 3 }
135 - else if(opponentClass == "PALADIN"){ index = 4 }
136 - else if(opponentClass == "PRIEST"){ index = 5 }
137 - else if(opponentClass == "ROGUE"){ index = 6 }
138 - else if(opponentClass == "SHAMAN"){ index = 7 }
139 - else if(opponentClass == "WARLOCK"){ index = 8 }
140 - else if(opponentClass == "WARRIOR"){ index = 9 }
141 - if(index != 1)
142 - await page.click('#tier-list > div > section.navs > section.tierlist-selection > nav > ul > li:nth-child(' + index)
143 const content=await page.content() 102 const content=await page.content()
144 browser.close() 103 browser.close()
145 return content 104 return content
...@@ -157,21 +116,17 @@ exports.GetResults=(req,res)=>{ ...@@ -157,21 +116,17 @@ exports.GetResults=(req,res)=>{
157 const GetDeckInfo=(content)=>{ 116 const GetDeckInfo=(content)=>{
158 return new Promise((resolve,reject)=>{ 117 return new Promise((resolve,reject)=>{
159 const $=cheerio.load(content) 118 const $=cheerio.load(content)
160 - let deckNames=$('.deck-name') 119 + let deckNames=$('li > dl')
161 - let deckGames=$('.game-count') 120 + let decks=[0,0,0]
162 - let decks=[] 121 + for(let i=0; i < deckNames.length; i++){
163 - for(let i=0;decks.length<3;i++) { 122 + if($(deckNames[i]).attr('class') != 'empty'){
164 - let deckName = $(deckNames[i]).text() 123 + let temp = $(deckNames[i].children[0]).text().split('\n')
165 - let deckGame = $(deckGames[i]).text() 124 + if(temp[0] == name1) decks[0] = $(deckNames[i].children[1]).text()
166 - let j=0 125 + else if(temp[0] == name2) decks[1] = $(deckNames[i].children[1]).text()
167 - for(;j<decks.length;j++){ 126 + else if(temp[0] == name3) decks[2] = $(deckNames[i].children[1]).text()
168 - if(deckName===decks[j].deckTitle)
169 - break
170 - }
171 - if(j===decks.length){
172 - decks.push({deckTitle:deckName,deckGame:deckGame})
173 } 127 }
174 } 128 }
129 + req.session.decks = decks
175 resolve(decks) 130 resolve(decks)
176 }) 131 })
177 } 132 }
...@@ -200,7 +155,6 @@ exports.GetResults=(req,res)=>{ ...@@ -200,7 +155,6 @@ exports.GetResults=(req,res)=>{
200 .then(()=>{ 155 .then(()=>{
201 return new Promise((resolve,reject)=>{ 156 return new Promise((resolve,reject)=>{
202 let result={} 157 let result={}
203 - result.cards=globalMulligan
204 result.decks=globalDecks 158 result.decks=globalDecks
205 resolve(result) 159 resolve(result)
206 }) 160 })
...@@ -209,8 +163,9 @@ exports.GetResults=(req,res)=>{ ...@@ -209,8 +163,9 @@ exports.GetResults=(req,res)=>{
209 fs.readFile('./views/ejs/score_result.ejs','utf-8',(err,data)=>{ 163 fs.readFile('./views/ejs/score_result.ejs','utf-8',(err,data)=>{
210 res.writeHead(200,{'Content-Type':'text/html'}) 164 res.writeHead(200,{'Content-Type':'text/html'})
211 res.end(ejs.render(data,{ 165 res.end(ejs.render(data,{
212 - cards:globalMulligan || [],
213 decks:globalDecks || [], 166 decks:globalDecks || [],
167 + MineClass:opponentClass || [],
168 + Names:names || [],
214 })) 169 }))
215 }) 170 })
216 }) 171 })
......
...@@ -5,18 +5,20 @@ const cheerio=require('cheerio') ...@@ -5,18 +5,20 @@ const cheerio=require('cheerio')
5 const mysql=require('mysql') 5 const mysql=require('mysql')
6 const fs=require('fs') 6 const fs=require('fs')
7 const ejs=require('ejs') 7 const ejs=require('ejs')
8 -let globalMulligan
9 -let globalDecks
10 8
11 //result.ejs 렌더링 전 수행됨. 현재 덱 ID와 상대 직업을 가지고 상대의 점유율 상위 3개 덱과, 내 덱의 추천 멀리건 출력 9 //result.ejs 렌더링 전 수행됨. 현재 덱 ID와 상대 직업을 가지고 상대의 점유율 상위 3개 덱과, 내 덱의 추천 멀리건 출력
12 //return : 렌더링 된 result.ejs 10 //return : 렌더링 된 result.ejs
13 exports.GetResult=(req,res)=>{ 11 exports.GetResult=(req,res)=>{
14 const opponentClass=req.session.opponentClass 12 const opponentClass=req.session.opponentClass
13 + const deck=req.session.decks
14 + const Name=req.session.names
15 try{ 15 try{
16 fs.readFile('./views/ejs/score_result.ejs','utf-8',(err,data)=>{ 16 fs.readFile('./views/ejs/score_result.ejs','utf-8',(err,data)=>{
17 res.writeHead(200,{'Content-Type':'text/html'}) 17 res.writeHead(200,{'Content-Type':'text/html'})
18 res.end(ejs.render(data,{ 18 res.end(ejs.render(data,{
19 - MineClass:opponentClass || [] 19 + MineClass:opponentClass || [],
20 + decks: deck || [0,0,0],
21 + Names: Name || ["", "", ""],
20 })) 22 }))
21 }) 23 })
22 }finally{ 24 }finally{
......
...@@ -5,4 +5,8 @@ const setOpponentClass=require('./setOpponentClass') ...@@ -5,4 +5,8 @@ const setOpponentClass=require('./setOpponentClass')
5 5
6 router.post('/setopponentclass',setOpponentClass.SetOpponentClass) 6 router.post('/setopponentclass',setOpponentClass.SetOpponentClass)
7 7
8 +const getResultMine = require('./getResultMine')
9 +router.post('/getresultmine', getResultMine.GetResults)
10 +
11 +
8 module.exports=router 12 module.exports=router
...\ No newline at end of file ...\ No newline at end of file
......
1 +const puppeteer=require('puppeteer')
2 +const cheerio=require('cheerio')
3 +const fs=require('fs')
4 +const ejs=require('ejs')
5 +
6 +exports.getDeckname=(req,res)=>{
7 + const deckname=req.session.deckname
8 + const name1 = req.body.value1
9 + const name2 = req.body.value2
10 + const name3 = req.body.value3
11 + const name4 = req.body.value4
12 + const names=[name1, name2, name3, name4]
13 + req.session.mulName = names
14 + let mulRates
15 + let WinRate=req.session.winRate
16 + const info={'비밀 사냥꾼':'Secret Hunter', '기계 사냥꾼':'Mech Hunter', '멀록 주술사':'Murloc Shaman', '토큰 드루이드':'Token Druid', '컨트롤 전사':'Control Warrior',
17 +'폭탄 전사':'Bomb Warrior', '기계 성기사':'Mech Paladin', '위니 흑마':'Zoo Warlock', '미드레인지 사냥꾼':'Midrange Hunter', '용 마법사':'Dragon Mage',
18 + '죽음의 메아리 사냥꾼':'Deathrattle Hunter', 'Cyclone Mage':'Cyclone Mage', '빅 주술사':'Big Shaman', '부활 사제':'Resurrect Priest','컨트롤 주술사':'Control Shaman',
19 + '빅 성기사':'Big Paladin', '신의 격노 성기사':'Holy Wrath Paladin', '템포 도적':'Tempo Rogue', '빙결 마법사':'Freeze Mage', '주문 마법사':'Spell Mage',
20 + '회복 드루이드':'Heal Druid', '침묵 사제':'Silence Priest', '노미 사제':'Nomi Priest', '거인 흑마법사':'Handlock', '첩보 도적':'Thief Rogue'}
21 + const GetMulContent=()=>{
22 + return new Promise((resolve,reject)=>{
23 + const asyncFunc=async ()=>{
24 + const browser=await puppeteer.launch()
25 + try{
26 + const page=await browser.newPage()
27 + await page.setViewport({width:1366,height:768})
28 + await page.goto(`https://hsreplay.net/meta`,{waitUntil: 'networkidle2'})
29 + const content=await page.content()
30 + browser.close()
31 + return content
32 + }
33 + catch(err)
34 + {
35 + console.log(err)
36 + browser.close()
37 + }
38 + }
39 + resolve(asyncFunc())
40 + })
41 + }
42 + const GetDeckInfo=(content)=>{
43 + return new Promise((resolve,reject)=>{
44 + const $=cheerio.load(content)
45 + let i = 0
46 + let deckNames=$('.archetype-info')
47 + for(; i < deckNames.length; i++){
48 + if($(deckNames[i].children[0]).text() == info[deckname]){
49 + WinRate = $(deckNames[i].children[1]).text()
50 + req.session.winRate = WinRate
51 + break
52 + }
53 + }
54 + let deckaddress=$($('a.btn')[i+1]).attr('href')
55 + resolve(deckaddress)
56 + })
57 + }
58 + const GetMulRate=(deckaddress)=>{
59 + return new Promise((resolve,reject)=>{
60 + const asyncFunc=async ()=>{
61 + const browser=await puppeteer.launch()
62 + try{
63 + const page=await browser.newPage()
64 + await page.setViewport({width:1366,height:768})
65 + await page.goto(`https://hsreplay.net` + deckaddress,{waitUntil: 'networkidle2'})
66 + const content=await page.content()
67 + browser.close()
68 + return content
69 + }
70 + catch(err)
71 + {
72 + console.log(err)
73 + browser.close()
74 + }
75 + }
76 + resolve(asyncFunc())
77 + })
78 + }
79 + const GetMulInfo=(content)=>{
80 + return new Promise((resolve,reject)=>{
81 + const $=cheerio.load(content)
82 + let MulNames=$('span.card-name')
83 + let MulRates=$('#mulligan-guide > div > div:nth-child(1) > div:nth-child(4) > div > div > div')
84 + mulRates=['', '' ,'' ,'']
85 + let USname = []
86 + let KRname = []
87 + USname = JSON.parse(fs.readFileSync('./cardsenUS.json'))
88 + KRname = JSON.parse(fs.readFileSync('./cardskoKR.json'))
89 + for(let i = 0 ;i < MulNames.length; i++){
90 + let j =0
91 + for(; j < USname.length; j++){
92 + if(USname[j].name == $(MulNames[i].children[0]).text())
93 + break
94 + }
95 + //$(MulNames[i].children[0]).text()
96 + if(j != USname.length){
97 + if(name1 == KRname[j].name) mulRates[0] = $(MulRates[6*i]).text()
98 + else if(name2 == KRname[j].name) mulRates[1] = $(MulRates[6*i]).text()
99 + else if(name3 == KRname[j].name) mulRates[2] = $(MulRates[6*i]).text()
100 + else if(name4 == KRname[j].name) mulRates[3] = $(MulRates[6*i]).text()
101 + }
102 + }
103 + req.session.mulwinRate = mulRates
104 + resolve(mulRates)
105 + })
106 + }
107 + GetMulContent()
108 + .then(GetDeckInfo)
109 + .then(GetMulRate)
110 + .then(GetMulInfo)
111 + .then(()=>{
112 + fs.readFile('./views/ejs/prob_result.ejs','utf-8',(err,data)=>{
113 + res.writeHead(200,{'Content-Type':'text/html'})
114 + res.end(ejs.render(data,{
115 + deckName : deckname || [],
116 + winRate:WinRate || [],
117 + mulNames:names || ["", "", "", ""],
118 + mulwinRate:mulRates || [0, 0, 0, 0]
119 + }))
120 + })
121 + })
122 + .catch((err)=>{
123 + console.log(err)
124 + })
125 +}
...\ No newline at end of file ...\ No newline at end of file
1 +const puppeteer=require('puppeteer')
2 +const cheerio=require('cheerio')
3 +const fs=require('fs')
4 +const ejs=require('ejs')
5 +
6 +exports.getDeckname=(req,res)=>{
7 + const deckname=req.body.value
8 + const DataCheck=()=>{
9 + return new Promise((resolve,reject)=>{
10 + if(!deckname){
11 + reject(({
12 + query:'request_body_error'
13 + }))
14 + }
15 + else resolve()
16 + })
17 + }
18 + const Set=()=>{
19 + req.session.deckname=req.body.value
20 + return
21 + }
22 + DataCheck()
23 + .then(Set)
24 + .then(()=>{
25 + res.status(200).json({message:'complete setting opponent class'})
26 + })
27 + .catch((err)=>{
28 + res.status(500).json(err||err.message)
29 + })
30 +}
...\ No newline at end of file ...\ No newline at end of file
1 +const puppeteer=require('puppeteer')
2 +const cheerio=require('cheerio')
3 +const fs=require('fs')
4 +const ejs=require('ejs')
5 +
6 +exports.getDeckname=(req,res)=>{
7 + const deckname=req.session.deckname
8 + const winRate=req.session.winRate
9 + const mulName=req.session.mulName
10 + const mulwinRate=req.session.mulwinRate
11 + try{
12 + fs.readFile('./views/ejs/prob_result.ejs','utf-8',(err,data)=>{
13 + res.writeHead(200,{'Content-Type':'text/html'})
14 + res.end(ejs.render(data,{
15 + deckName : deckname || [],
16 + winRate:winRate || [0],
17 + mulNames:mulName || ["", "", "", ""],
18 + mulwinRate:mulwinRate || [0, 0, 0, 0]
19 + }))
20 + })
21 + }finally{}
22 +}
...\ No newline at end of file ...\ No newline at end of file
...@@ -2,7 +2,15 @@ const express=require('express') ...@@ -2,7 +2,15 @@ const express=require('express')
2 const router=express.Router() 2 const router=express.Router()
3 3
4 const newDeck=require('./newDeck') 4 const newDeck=require('./newDeck')
5 -
6 router.post('/newdeck',newDeck.NewDeck) 5 router.post('/newdeck',newDeck.NewDeck)
7 6
7 +const getdeckname=require('./getdeckname')
8 +router.post('/getdeckname',getdeckname.getDeckname)
9 +
10 +const getdeckname1=require('./getdeckname1')
11 +router.post('/getdeckname1',getdeckname1.getDeckname)
12 +
13 +const getdeckname2=require('./getdeckname2')
14 +router.post('/getdeckname2',getdeckname2.getDeckname)
15 +
8 module.exports=router 16 module.exports=router
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -43,7 +43,7 @@ app.use(session({ ...@@ -43,7 +43,7 @@ app.use(session({
43 })) 43 }))
44 44
45 app.get('/',(req,res)=>{ 45 app.get('/',(req,res)=>{
46 - res.redirect('/decklist') 46 + res.redirect('/login')
47 }) 47 })
48 48
49 49
...@@ -171,14 +171,15 @@ app.get('/score_result_',(req,res)=>{ ...@@ -171,14 +171,15 @@ app.get('/score_result_',(req,res)=>{
171 } 171 }
172 }) 172 })
173 173
174 -app.get('/prob_result/:deckId',(req,res)=>{ 174 +const getdeckname=require('./api/deck/getdeckname2')
175 +
176 +app.get('/prob_result',(req,res)=>{
175 if(!req.session.sid) 177 if(!req.session.sid)
176 res.redirect('/login') 178 res.redirect('/login')
177 else{ 179 else{
178 - fs.readFile('./views/html/prob_result.html',(err,data)=>{ 180 + (async ()=>{
179 - res.writeHead(200,{'Content-Type':'text/html'}) 181 + await getdeckname.getDeckname(req,res)
180 - res.end(data) 182 + })()
181 - })
182 } 183 }
183 }) 184 })
184 185
......
...@@ -32,12 +32,157 @@ ...@@ -32,12 +32,157 @@
32 } 32 }
33 }) 33 })
34 }) 34 })
35 - for ( var i=0;i<decks.length;i++) { 35 + $('#value_1').click(function () {
36 - $('#delButton_'+(i+1)).click(function () { 36 + let obj = new Object()
37 - let sql = "select * from deck" 37 + obj.value = $('#value_1').val()
38 - 38 + const stringData = JSON.stringify(obj)
39 + $.ajax({
40 + type:'POST',
41 + url:'/api/deck/getdeckname1',
42 + data:stringData,
43 + async:false,
44 + dataType:'JSON',
45 + contentType:'application/json; charset=utf-8',
46 + traditional:true,
47 + processdata:false,
48 + success:function(result){
49 + window.location.href='/prob_result'
50 + },
51 + error:function(request,status,error){
52 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
53 + }
54 + })
55 + })
56 + $('#value_2').click(function () {
57 + let obj = new Object()
58 + obj.value = $('#value_2').val()
59 + const stringData = JSON.stringify(obj)
60 + $.ajax({
61 + type:'POST',
62 + url:'/api/deck/getdeckname1',
63 + data:stringData,
64 + async:false,
65 + dataType:'JSON',
66 + contentType:'application/json; charset=utf-8',
67 + traditional:true,
68 + processdata:false,
69 + success:function(result){
70 + window.location.href='/prob_result'
71 + },
72 + error:function(request,status,error){
73 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
74 + }
75 + })
76 + })
77 + $('#value_3').click(function () {
78 + let obj = new Object()
79 + obj.value = $('#value_3').val()
80 + const stringData = JSON.stringify(obj)
81 + $.ajax({
82 + type:'POST',
83 + url:'/api/deck/getdeckname1',
84 + data:stringData,
85 + async:false,
86 + dataType:'JSON',
87 + contentType:'application/json; charset=utf-8',
88 + traditional:true,
89 + processdata:false,
90 + success:function(result){
91 + window.location.href='/prob_result'
92 + },
93 + error:function(request,status,error){
94 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
95 + }
96 + })
97 + })
98 + $('#value_4').click(function () {
99 + let obj = new Object()
100 + obj.value = $('#value_4').val()
101 + const stringData = JSON.stringify(obj)
102 + $.ajax({
103 + type:'POST',
104 + url:'/api/deck/getdeckname1',
105 + data:stringData,
106 + async:false,
107 + dataType:'JSON',
108 + contentType:'application/json; charset=utf-8',
109 + traditional:true,
110 + processdata:false,
111 + success:function(result){
112 + window.location.href='/prob_result'
113 + },
114 + error:function(request,status,error){
115 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
116 + }
117 + })
118 + })
119 + $('#value_5').click(function () {
120 + let obj = new Object()
121 + obj.value = $('#value_5').val()
122 + const stringData = JSON.stringify(obj)
123 + $.ajax({
124 + type:'POST',
125 + url:'/api/deck/getdeckname1',
126 + data:stringData,
127 + async:false,
128 + dataType:'JSON',
129 + contentType:'application/json; charset=utf-8',
130 + traditional:true,
131 + processdata:false,
132 + success:function(result){
133 + window.location.href='/prob_result'
134 + },
135 + error:function(request,status,error){
136 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
137 + }
138 + })
139 + })
140 + $('#value_6').click(function () {
141 + let obj = new Object()
142 + obj.value = $('#value_6').val()
143 + const stringData = JSON.stringify(obj)
144 + $.ajax({
145 + type:'POST',
146 + url:'/api/deck/getdeckname1',
147 + data:stringData,
148 + async:false,
149 + dataType:'JSON',
150 + contentType:'application/json; charset=utf-8',
151 + traditional:true,
152 + processdata:false,
153 + success:function(result){
154 + window.location.href='/prob_result'
155 + },
156 + error:function(request,status,error){
157 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
158 + }
159 + })
160 + })
161 +
162 + /*for ( var i=0;i<decks.length;i++) {
163 + $('#value_'+(i+1)).click(function () {
164 + let obj = new Object()
165 + obj.value = $('#value_' + (i+1)).val()
166 + const stringData = JSON.stringify(obj)
167 + $.ajax({
168 + type:'POST',
169 + url:'/api/deck/getdeckname',
170 + data:stringData,
171 + async:false,
172 + //dataType:'JSON',
173 + contentType:'application/json; charset=utf-8',
174 + traditional:true,
175 + processdata:false,
176 + success:function(result){
177 + alert('검색 성공')
178 + window.location.href='/prob_result'
179 + },
180 + error:function(request,status,error){
181 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
182 + }
183 + })
39 }) 184 })
40 - } 185 + }*/
41 }) 186 })
42 187
43 </script> 188 </script>
...@@ -75,8 +220,7 @@ ...@@ -75,8 +220,7 @@
75 <table class="table" style="width:100%"> 220 <table class="table" style="width:100%">
76 <% for ( var i=0;i<decks.length;i++) { %> 221 <% for ( var i=0;i<decks.length;i++) { %>
77 <tr id="rm<%=(i+1)%>"> 222 <tr id="rm<%=(i+1)%>">
78 - <td style="text-align: center; width:500px"><a class="list-group-item" href="/prob_result/<%= decks[i].id %>"><%= decks[i].deckTitle %></a></td> 223 + <td><input type=button style="text-align: center; width:100%; height:42px" id ="value_<%= (i+1)%>" value ="<%= decks[i].deckTitle %>"></input></td>
79 - <td><input type="button" class="btn btn-lg btn-info" style="width:100px; height:42px" value=삭제 id ="delButton_<%= (i+1)%> "/></td>
80 </tr> 224 </tr>
81 <% } %> 225 <% } %>
82 </table> 226 </table>
......
...@@ -32,6 +32,32 @@ ...@@ -32,6 +32,32 @@
32 } 32 }
33 }) 33 })
34 }) 34 })
35 + $('#show_prob').click(function(){
36 + var obj = new Object()
37 + obj.value1 = $('#Btn1').val()
38 + obj.value2 = $('#Btn2').val()
39 + obj.value3 = $('#Btn3').val()
40 + obj.value4 = $('#Btn4').val()
41 + const stringData = JSON.stringify(obj)
42 + let temp
43 + $.ajax({
44 + type:'POST',
45 + url:'/api/deck/getdeckname',
46 + data:stringData,
47 + async:false,
48 + //dataType:'JSON',
49 + contentType:'application/json; charset=utf-8',
50 + traditional:true,
51 + processdata:false,
52 + success:function(result){
53 + alert('검색 성공')
54 + window.location.href='/prob_result'
55 + },
56 + error:function(request,status,error){
57 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
58 + }
59 + })
60 + })
35 }) 61 })
36 </script> 62 </script>
37 </head> 63 </head>
...@@ -67,12 +93,10 @@ ...@@ -67,12 +93,10 @@
67 <td>승률</td> 93 <td>승률</td>
68 </thead> 94 </thead>
69 <tbody> 95 <tbody>
70 - <% for(var i=0;i<decks.length;i++){%>
71 <tr> 96 <tr>
72 - <td><a class="list-group-item"><%= decks[i].deckTitle %></a></td> 97 + <td><a class="list-group-item"><%= deckName %></a></td>
73 - <td><a class="list-group-item"><%= decks[i].deckWinRate %></a></td> 98 + <td><a class="list-group-item"><%= winRate %></a></td>
74 </tr> 99 </tr>
75 - <%}%>
76 </tbody> 100 </tbody>
77 </table> 101 </table>
78 </div> 102 </div>
...@@ -80,23 +104,31 @@ ...@@ -80,23 +104,31 @@
80 <br> 104 <br>
81 <h3 class="form-signin-heading">멀리건 승률</h3> 105 <h3 class="form-signin-heading">멀리건 승률</h3>
82 <div id="yourMulligan"> 106 <div id="yourMulligan">
83 - <form method="get" action="/save.php"> 107 + <table class="table" style="text-align: center;">
84 - <table class="table" style="text-align: center;"> 108 + <thead>
85 - <thead> 109 + <td>카드 이름</td>
86 - <td>카드 이름</td> 110 + <td>멀리건 승률</td>
87 - <td>멀리건 승률</td> 111 + </thead>
88 - </thead> 112 + <tbody>
89 - <tbody> 113 + <tr>
90 - <% for(var i=0;i<cards.length;i++){%> 114 + <td><input type="text" class="btn-block" id='Btn1' name="keyword" style="height:42px; text-align:center;" value="<%=mulNames[0]%>"/></td>
91 - <tr> 115 + <td><a class="list-group-item" id='Text1' ><%= mulwinRate[0] %></a></td>
92 - <td><input type="text" class="btn-block" name="keyword" style="height:42px; text-align:center;"/></td> 116 + </tr>
93 - <td><a class="list-group-item"><%= cards[i].cardWinRate %></a></td> 117 + <tr>
94 - </tr> 118 + <td><input type="text" class="btn-block" id='Btn2' name="keyword" style="height:42px; text-align:center;" value="<%=mulNames[1]%>"/></td>
95 - <%}%> 119 + <td><a class="list-group-item" id='Text2'><%= mulwinRate[1] %></a></td>
96 - </tbody> 120 + </tr>
97 - </table> 121 + <tr>
122 + <td><input type="text" class="btn-block" id='Btn3' name="keyword" style="height:42px; text-align:center;" value="<%=mulNames[2]%>"/></td>
123 + <td><a class="list-group-item" id='Text3'><%= mulwinRate[2] %></a></td>
124 + </tr>
125 + <tr>
126 + <td><input type="text" class="btn-block" id='Btn4' name="keyword" style="height:42px; text-align:center;" value="<%=mulNames[3]%>"/></td>
127 + <td><a class="list-group-item" id='Text4'><%= mulwinRate[3] %></a></td>
128 + </tr>
129 + </tbody>
130 + </table>
98 <button type="submit" class="btn btn-primary btn-block" id="show_prob">멀리건 승률 표출하기</button> 131 <button type="submit" class="btn btn-primary btn-block" id="show_prob">멀리건 승률 표출하기</button>
99 - </form>
100 </div> 132 </div>
101 <br> 133 <br>
102 <br> 134 <br>
......
...@@ -38,17 +38,19 @@ ...@@ -38,17 +38,19 @@
38 obj.value2 = $('#btn2').val() 38 obj.value2 = $('#btn2').val()
39 obj.value3 = $('#btn3').val() 39 obj.value3 = $('#btn3').val()
40 const stringData = JSON.stringify(obj) 40 const stringData = JSON.stringify(obj)
41 + let temp
41 $.ajax({ 42 $.ajax({
42 type:'POST', 43 type:'POST',
43 - url:'/api/card/setopponentclass', 44 + url:'/api/card/getresultmine',
44 data:stringData, 45 data:stringData,
45 - dataType:'JSON', 46 + async:false,
47 + //dataType:'JSON',
46 contentType:'application/json; charset=utf-8', 48 contentType:'application/json; charset=utf-8',
47 traditional:true, 49 traditional:true,
48 processdata:false, 50 processdata:false,
49 success:function(result){ 51 success:function(result){
50 alert('검색 성공') 52 alert('검색 성공')
51 - window.location.href='/score_result_' 53 + window.location.href='/score_result'
52 }, 54 },
53 error:function(request,status,error){ 55 error:function(request,status,error){
54 alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error); 56 alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
...@@ -106,16 +108,16 @@ ...@@ -106,16 +108,16 @@
106 </thead> 108 </thead>
107 <tbody> 109 <tbody>
108 <tr> 110 <tr>
109 - <td><input type="text" class="btn-block" id="btn1" name="keyword" style="height:42px; text-align:center;" /></td> 111 + <td><input type="text" class="btn-block" id="btn1" name="keyword" style="height:42px; text-align:center;" value= "<%=Names[0]%>" /></td>
110 - <td><a class="list-group-item">카드</a></td> 112 + <td><a class="list-group-item" id='text1'><%= decks[0] %></a></td>
111 </tr> 113 </tr>
112 <tr> 114 <tr>
113 - <td><input type="text" class="btn-block" id="btn2" name="keyword" style="height:42px; text-align:center;" /></td> 115 + <td><input type="text" class="btn-block" id="btn2" name="keyword" style="height:42px; text-align:center;" value="<%= Names[1] %>" /></td>
114 - <td><a class="list-group-item">이름</a></td> 116 + <td><a class="list-group-item" id='text2'><%= decks[1] %></a></td>
115 </tr> 117 </tr>
116 <tr> 118 <tr>
117 - <td><input type="text" class="btn-block" id="btn3" name="keyword" style="height:42px; text-align:center;" /></td> 119 + <td><input type="text" class="btn-block" id="btn3" name="keyword" style="height:42px; text-align:center;" value="<%= Names[2] %>" /></td>
118 - <td><a class="list-group-item">입력!!</a></td> 120 + <td><a class="list-group-item" id='text3'><%= decks[2] %></a></td>
119 </tr> 121 </tr>
120 </tbody> 122 </tbody>
121 </table> 123 </table>
......
...@@ -32,28 +32,31 @@ ...@@ -32,28 +32,31 @@
32 } 32 }
33 }) 33 })
34 }) 34 })
35 - $('#show_prob').click(function(){ 35 + $('#showprob').click(function(){
36 - var Data = new Object() 36 + var obj = new Object()
37 - Data.value1 = $('#btn1').val() 37 + obj.value1 = $('#btn1').val()
38 - Data.value2 = $('#btn2').val() 38 + obj.value2 = $('#btn2').val()
39 - Data.value3 = $('#btn3').val() 39 + obj.value3 = $('#btn3').val()
40 - const stringData = JSON.stringify(Data) 40 + obj.MinClass = $('#mineclass').val()
41 - alert('검색중입니다!') 41 + obj.MinClass1 = $('#mineclass1').val()
42 + const stringData = JSON.stringify(obj)
42 $.ajax({ 43 $.ajax({
43 - typ:'GET', 44 + type:'POST',
44 - url:'/api/card/getResultMine', 45 + url:'/api/card/getresultmine',
45 data:stringData, 46 data:stringData,
46 - dataType:'JSON', 47 + async:false,
48 + //dataType:'JSON',
47 contentType:'application/json; charset=utf-8', 49 contentType:'application/json; charset=utf-8',
48 traditional:true, 50 traditional:true,
49 processdata:false, 51 processdata:false,
50 success:function(result){ 52 success:function(result){
51 - alert('검색 성공!') 53 + alert('검색 성공')
54 + //let temp = JSON.stringify(result)
55 + //$('text1').text(temp)
52 }, 56 },
53 - error:function(result){ 57 + error:function(request,status,error){
54 - alert('검색 실패!') 58 + alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
55 - return false 59 + }
56 - }
57 }) 60 })
58 }) 61 })
59 }) 62 })
...@@ -100,31 +103,27 @@ ...@@ -100,31 +103,27 @@
100 <br> 103 <br>
101 <h3 class="form-signin-heading">투기장 카드 점수</h3> 104 <h3 class="form-signin-heading">투기장 카드 점수</h3>
102 <div id="yourMulligan"> 105 <div id="yourMulligan">
103 - <form method="get" action="/save.php"> 106 + <table class="table" style="text-align: center;">
104 - <!-- method - 통신 방식의 메소드를 결정하며 get/post에서 선택함 107 + <thead>
105 - action - 값을 전달할 서버 페이지 위치 --> 108 + <td>카드 이름</td>
106 - <table class="table" style="text-align: center;"> 109 + <td>카드 점수</td>
107 - <thead> 110 + </thead>
108 - <td>카드 이름</td> 111 + <tbody>
109 - <td>카드 점수</td> 112 + <tr>
110 - </thead> 113 + <td><input type="text" class="btn-block" id="btn1" name="keyword" style="height:42px; text-align:center;" /></td>
111 - <tbody> 114 + <td><a class="list-group-item">0</a></td>
112 - <tr> 115 + </tr>
113 - <td><input type="text" class="btn-block" id="btn1" name="keyword" style="height:42px; text-align:center;" /></td> 116 + <tr>
114 - <td><a class="list-group-item">0</a></td> 117 + <td><input type="text" class="btn-block" id="btn2" name="keyword" style="height:42px; text-align:center;" /></td>
115 - </tr> 118 + <td><a class="list-group-item">0</a></td>
116 - <tr> 119 + </tr>
117 - <td><input type="text" class="btn-block" id="btn2" name="keyword" style="height:42px; text-align:center;" /></td> 120 + <tr>
118 - <td><a class="list-group-item">0</a></td> 121 + <td><input type="text" class="btn-block" id="btn3" name="keyword" style="height:42px; text-align:center;" /></td>
119 - </tr> 122 + <td><a class="list-group-item">0</a></td>
120 - <tr> 123 + </tr>
121 - <td><input type="text" class="btn-block" id="btn3" name="keyword" style="height:42px; text-align:center;" /></td> 124 + </tbody>
122 - <td><a class="list-group-item">0</a></td> 125 + </table>
123 - </tr> 126 + <button type="submit" class="btn btn-primary btn-block" id="show_prob">카드 점수 표출하기</button>
124 - </tbody>
125 - </table>
126 - <button type="submit" class="btn btn-primary btn-block" id="show_prob">카드 점수 표출하기</button>
127 - </form>
128 </div> 127 </div>
129 <br> 128 <br>
130 <br> 129 <br>
......