Showing
16 changed files
with
710 additions
and
127 deletions
... | @@ -2,11 +2,16 @@ const puppeteer=require('puppeteer'); | ... | @@ -2,11 +2,16 @@ const puppeteer=require('puppeteer'); |
2 | const cheerio=require('cheerio'); | 2 | const cheerio=require('cheerio'); |
3 | 3 | ||
4 | exports.getDecks=(cardIds)=>{ | 4 | exports.getDecks=(cardIds)=>{ |
5 | - | 5 | + console.log('cardIds in crawlerMulligan ',cardIds) |
6 | - let idInQuery=cardIds[0] | 6 | + cardIds=JSON.stringify(cardIds) |
7 | - for(let i=1;i<cardIds.length;i++){ | 7 | + cardIds=JSON.parse(cardIds) |
8 | - idInQuery+= '%2C'+cardIds[i] | 8 | + console.log('stringified cardIds in crawlerMulligan ',cardIds) |
9 | + console.log(cardIds[0]) | ||
10 | + let idInQuery=cardIds[0].cardId | ||
11 | + for(let i=1;i<cardIds.length && i<10;i++){ | ||
12 | + idInQuery+= '%2C'+cardIds[i].cardId | ||
9 | } | 13 | } |
14 | + console.log('idInQuery in crawlerMulligan ',idInQuery) | ||
10 | const getContent=()=>{ | 15 | const getContent=()=>{ |
11 | return new Promise((resolve,reject)=>{ | 16 | return new Promise((resolve,reject)=>{ |
12 | const asyncFunc=async ()=>{ | 17 | const asyncFunc=async ()=>{ |
... | @@ -30,51 +35,58 @@ exports.getDecks=(cardIds)=>{ | ... | @@ -30,51 +35,58 @@ exports.getDecks=(cardIds)=>{ |
30 | } | 35 | } |
31 | 36 | ||
32 | const getDeckHref=(content)=>{ | 37 | const getDeckHref=(content)=>{ |
33 | - const $=cheerio.load(content) | 38 | + return new Promise((resolve,reject)=>{ |
34 | - let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a') | 39 | + const $=cheerio.load(content) |
35 | - const deckHref=$(deck).attr('href') | 40 | + let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a') |
36 | - return deckHref | 41 | + const deckHref=$(deck).attr('href') |
42 | + console.log('deckHref in crawlerMulligan :',deckHref) | ||
43 | + resolve(deckHref) | ||
44 | + }) | ||
37 | } | 45 | } |
38 | - const getDeckConetent=(href)=>{ | 46 | + const getDeckContent=(href)=>{ |
39 | - const asyncFunc=async ()=>{ | 47 | + return new Promise((resolve,reject)=>{ |
40 | - const browser=await puppeteer.launch() | 48 | + const asyncFunc=async ()=>{ |
41 | - try{ | 49 | + const browser=await puppeteer.launch() |
42 | - const page=await browser.newPage() | 50 | + try{ |
43 | - await page.setViewport({width:1366,height:768}) | 51 | + const page=await browser.newPage() |
44 | - await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'}) | 52 | + await page.setViewport({width:1366,height:768}) |
45 | - const content=await page.content() | 53 | + await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'}) |
46 | - browser.close() | 54 | + const content=await page.content() |
47 | - return content | 55 | + browser.close() |
48 | - } | 56 | + return content |
49 | - catch(err) | 57 | + } |
50 | - { | 58 | + catch(err) |
51 | - console.log(err) | 59 | + { |
52 | - browser.close() | 60 | + console.log(err) |
61 | + browser.close() | ||
62 | + } | ||
53 | } | 63 | } |
54 | - } | 64 | + resolve(asyncFunc()) |
55 | - return asyncFunc() | 65 | + }) |
56 | } | 66 | } |
57 | const getMulligan=(content)=>{ | 67 | const getMulligan=(content)=>{ |
58 | - const $=cheerio.load(content) | 68 | + return new Promise((resolve,reject)=>{ |
59 | - let cardNames=$('.card-name') | 69 | + const $=cheerio.load(content) |
60 | - let cardWinRates=$('.table-cell') | 70 | + let cardNames=$('.card-name') |
61 | - let cards=[] | 71 | + let cardWinRates=$('.table-cell') |
62 | - for(let i=0;i<cardNames.length;i++){ | 72 | + let cards=[] |
63 | - let cardName=$(cardNames[i]).text() | 73 | + for(let i=0;i<cardNames.length;i++){ |
64 | - let cardWinRate=$(cardWinRates[6*i]).text() | 74 | + let cardName=$(cardNames[i]).text() |
65 | - cardWinRate=cardWinRate.replace('▼','') | 75 | + let cardWinRate=$(cardWinRates[6*i]).text() |
66 | - cardWinRate=cardWinRate.replace('▲','') | 76 | + cardWinRate=cardWinRate.replace('▼','') |
67 | - cardWinRate=cardWinRate.replace('%','') | 77 | + cardWinRate=cardWinRate.replace('▲','') |
68 | - cards.push({cardName:cardName,cardWinRate:cardWinRate}) | 78 | + cardWinRate=cardWinRate.replace('%','') |
69 | - } | 79 | + cards.push({cardName:cardName,cardWinRate:cardWinRate}) |
70 | - cards.sort((a,b)=>{ | 80 | + } |
71 | - return a.cardWinRate<b.cardWinRate ? 1:-1 | 81 | + cards.sort((a,b)=>{ |
82 | + return a.cardWinRate<b.cardWinRate ? 1:-1 | ||
83 | + }) | ||
84 | + console.log(cards) | ||
85 | + resolve(cards) | ||
72 | }) | 86 | }) |
73 | - console.log(cards) | ||
74 | - | ||
75 | } | 87 | } |
76 | getContent() | 88 | getContent() |
77 | .then(getDeckHref) | 89 | .then(getDeckHref) |
78 | - .then(getDeckConetent) | 90 | + .then(getDeckContent) |
79 | .then(getMulligan) | 91 | .then(getMulligan) |
80 | } | 92 | } | ... | ... |
... | @@ -26,17 +26,19 @@ exports.getDecks=(opponentClass)=>{ | ... | @@ -26,17 +26,19 @@ exports.getDecks=(opponentClass)=>{ |
26 | } | 26 | } |
27 | 27 | ||
28 | const getDeckInfo=(content)=>{ | 28 | const getDeckInfo=(content)=>{ |
29 | - const $=cheerio.load(content) | 29 | + return new Promise((resolve,reject)=>{ |
30 | - let deckNames=$('.deck-name') | 30 | + const $=cheerio.load(content) |
31 | - let deckGames=$('.game-count') | 31 | + let deckNames=$('.deck-name') |
32 | - let decks=[] | 32 | + let deckGames=$('.game-count') |
33 | - for(let i=0;i<3;i++){ | 33 | + let decks=[] |
34 | - let deckName=$(deckNames[i]).text() | 34 | + for(let i=0;i<3;i++){ |
35 | - let deckGame=$(deckGames[i]).text() | 35 | + let deckName=$(deckNames[i]).text() |
36 | - decks.push({deckTitle:deckName,deckGame:deckGame}) | 36 | + let deckGame=$(deckGames[i]).text() |
37 | - } | 37 | + decks.push({deckTitle:deckName,deckGame:deckGame}) |
38 | - console.log(decks) | 38 | + } |
39 | - return decks | 39 | + console.log(decks) |
40 | + resolve(decks) | ||
41 | + }) | ||
40 | } | 42 | } |
41 | getContent() | 43 | getContent() |
42 | .then(getDeckInfo) | 44 | .then(getDeckInfo) | ... | ... |
1 | const crawler=require('./crawlerMulligan') | 1 | const crawler=require('./crawlerMulligan') |
2 | const getCardId=require('./getCardId') | 2 | const getCardId=require('./getCardId') |
3 | +const puppeteer=require('puppeteer') | ||
4 | +const cheerio=require('cheerio') | ||
5 | + | ||
3 | 6 | ||
4 | exports.GetMulligan=(req,res)=>{ | 7 | exports.GetMulligan=(req,res)=>{ |
5 | const deckId=req.session.deckId || 113 | 8 | const deckId=req.session.deckId || 113 |
6 | - const opponentClass=req.body.class || 'PALADIN' | 9 | + console.log('deckId in getMulligan',deckId) |
10 | + const opponentClass=req.session.opponentClass || 'PALADIN' | ||
11 | + console.log('opponentClass in getMulligan',opponentClass) | ||
7 | const DataCheck=()=>{ | 12 | const DataCheck=()=>{ |
8 | return new Promise((resolve,reject)=>{ | 13 | return new Promise((resolve,reject)=>{ |
9 | if (!deckId || !opponentClass){ | 14 | if (!deckId || !opponentClass){ |
... | @@ -21,13 +26,101 @@ exports.GetMulligan=(req,res)=>{ | ... | @@ -21,13 +26,101 @@ exports.GetMulligan=(req,res)=>{ |
21 | const CrawlerMulligan=(cardIds)=>{ | 26 | const CrawlerMulligan=(cardIds)=>{ |
22 | return crawler.getDecks(cardIds) | 27 | return crawler.getDecks(cardIds) |
23 | } | 28 | } |
29 | + | ||
30 | + const GetContent=(cardIds)=>{ | ||
31 | + cardIds=JSON.stringify(cardIds) | ||
32 | + cardIds=JSON.parse(cardIds) | ||
33 | + let idInQuery=cardIds[0].cardId | ||
34 | + for(let i=1;i<cardIds.length ;i++){ | ||
35 | + idInQuery+= '%2C'+cardIds[i].cardId | ||
36 | + } | ||
37 | + console.log('idInQuery in crawlerMulligan ',idInQuery) | ||
38 | + return new Promise((resolve,reject)=>{ | ||
39 | + const asyncFunc=async ()=>{ | ||
40 | + const browser=await puppeteer.launch() | ||
41 | + try{ | ||
42 | + const page=await browser.newPage() | ||
43 | + await page.setViewport({width:1366,height:768}) | ||
44 | + await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=${idInQuery}`,{waitUntil: 'networkidle2'}) | ||
45 | + const content=await page.content() | ||
46 | + browser.close() | ||
47 | + return content | ||
48 | + } | ||
49 | + catch(err) | ||
50 | + { | ||
51 | + console.log(err) | ||
52 | + browser.close() | ||
53 | + } | ||
54 | + } | ||
55 | + resolve(asyncFunc()) | ||
56 | + }) | ||
57 | + } | ||
58 | + | ||
59 | + const GetDeckHref=(content)=>{ | ||
60 | + return new Promise((resolve,reject)=>{ | ||
61 | + const $=cheerio.load(content) | ||
62 | + let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a') | ||
63 | + const deckHref=$(deck).attr('href') | ||
64 | + console.log('deckHref in crawlerMulligan :',deckHref) | ||
65 | + resolve(deckHref) | ||
66 | + }) | ||
67 | + } | ||
68 | + const GetDeckContent=(href)=>{ | ||
69 | + return new Promise((resolve,reject)=>{ | ||
70 | + const asyncFunc=async ()=>{ | ||
71 | + const browser=await puppeteer.launch() | ||
72 | + try{ | ||
73 | + const page=await browser.newPage() | ||
74 | + await page.setViewport({width:1366,height:768}) | ||
75 | + await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'}) | ||
76 | + const content=await page.content() | ||
77 | + browser.close() | ||
78 | + return content | ||
79 | + } | ||
80 | + catch(err) | ||
81 | + { | ||
82 | + console.log(err) | ||
83 | + browser.close() | ||
84 | + } | ||
85 | + } | ||
86 | + resolve(asyncFunc()) | ||
87 | + }) | ||
88 | + } | ||
89 | + const GetMulligan=(content)=>{ | ||
90 | + return new Promise((resolve,reject)=>{ | ||
91 | + const $=cheerio.load(content) | ||
92 | + let cardNames=$('.card-name') | ||
93 | + let cardWinRates=$('.table-cell') | ||
94 | + let cards=[] | ||
95 | + for(let i=0;i<cardNames.length;i++){ | ||
96 | + let cardName=$(cardNames[i]).text() | ||
97 | + let cardWinRate=$(cardWinRates[6*i]).text() | ||
98 | + cardWinRate=cardWinRate.replace('▼','') | ||
99 | + cardWinRate=cardWinRate.replace('▲','') | ||
100 | + cardWinRate=cardWinRate.replace('%','') | ||
101 | + cards.push({cardName:cardName,cardWinRate:cardWinRate}) | ||
102 | + } | ||
103 | + cards.sort((a,b)=>{ | ||
104 | + return a.cardWinRate<b.cardWinRate ? 1:-1 | ||
105 | + }) | ||
106 | + console.log(cards) | ||
107 | + resolve(cards) | ||
108 | + }) | ||
109 | + } | ||
24 | DataCheck() | 110 | DataCheck() |
25 | .then(GetCardId) | 111 | .then(GetCardId) |
26 | - .then(CrawlerMulligan) | 112 | + //.then(CrawlerMulligan) |
113 | + .then(GetContent) | ||
114 | + .then(GetDeckHref) | ||
115 | + .then(GetDeckContent) | ||
116 | + .then(GetMulligan) | ||
27 | .then((cards)=>{ | 117 | .then((cards)=>{ |
28 | - res.status(200).json(cards) | 118 | + return new Promise((resolve,reject)=>{ |
119 | + console.log('cards in getMulligan : ',cards) | ||
120 | + resolve(cards) | ||
121 | + }) | ||
29 | }) | 122 | }) |
30 | .catch((err)=>{ | 123 | .catch((err)=>{ |
31 | - res.status(500).json(err) | 124 | + console.log(err) |
32 | }) | 125 | }) |
33 | } | 126 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | -const request=require('request') | ||
2 | -const iconv=require('iconv-lite') | ||
3 | -const charset=require('charset') | ||
4 | const crawler=require('./crawlerOpponent') | 1 | const crawler=require('./crawlerOpponent') |
2 | +const puppeteer=require('puppeteer') | ||
3 | +const cheerio=require('cheerio') | ||
5 | 4 | ||
6 | exports.GetOpponent=(req,res)=>{ | 5 | exports.GetOpponent=(req,res)=>{ |
7 | - const opponentClass=req.body.class | 6 | + const opponentClass=req.session.opponentClass |
8 | const DataCheck=()=>{ | 7 | const DataCheck=()=>{ |
9 | return new Promise((resolve,reject)=>{ | 8 | return new Promise((resolve,reject)=>{ |
10 | if(!opponentClass){ | 9 | if(!opponentClass){ |
... | @@ -16,15 +15,57 @@ exports.GetOpponent=(req,res)=>{ | ... | @@ -16,15 +15,57 @@ exports.GetOpponent=(req,res)=>{ |
16 | resolve() | 15 | resolve() |
17 | }) | 16 | }) |
18 | } | 17 | } |
19 | - const CralwerOpponent=()=>{ | 18 | + const CrawlerOpponent=()=>{ |
20 | return crawler.getDecks(opponentClass) | 19 | return crawler.getDecks(opponentClass) |
21 | } | 20 | } |
22 | - DataCheck | 21 | + const GetContent=()=>{ |
23 | - .then(CralwerOpponent) | 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/decks/#timeRange=LAST_30_DAYS&playerClasses=${opponentClass}?hl=ko`,{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 | + | ||
43 | + const GetDeckInfo=(content)=>{ | ||
44 | + return new Promise((resolve,reject)=>{ | ||
45 | + const $=cheerio.load(content) | ||
46 | + let deckNames=$('.deck-name') | ||
47 | + let deckGames=$('.game-count') | ||
48 | + let decks=[] | ||
49 | + for(let i=0;i<3;i++){ | ||
50 | + let deckName=$(deckNames[i]).text() | ||
51 | + let deckGame=$(deckGames[i]).text() | ||
52 | + decks.push({deckTitle:deckName,deckGame:deckGame}) | ||
53 | + } | ||
54 | + console.log(decks) | ||
55 | + resolve(decks) | ||
56 | + }) | ||
57 | + } | ||
58 | + DataCheck() | ||
59 | + //.then(CrawlerOpponent) | ||
60 | + .then(GetContent) | ||
61 | + .then(GetDeckInfo) | ||
24 | .then((decks)=>{ | 62 | .then((decks)=>{ |
25 | - res.status(200).json(decks) | 63 | + return new Promise((resolve,reject)=>{ |
64 | + console.log('decks in getOpponent: ',decks) | ||
65 | + resolve(decks) | ||
66 | + }) | ||
26 | }) | 67 | }) |
27 | .catch((err)=>{ | 68 | .catch((err)=>{ |
28 | - res.status(500).json(err) | 69 | + console.log(err) |
29 | }) | 70 | }) |
30 | } | 71 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
api/card/getResult.js
0 → 100644
1 | +const crawler=require('./crawlerMulligan') | ||
2 | +const getCardId=require('./getCardId') | ||
3 | +const puppeteer=require('puppeteer') | ||
4 | +const cheerio=require('cheerio') | ||
5 | +const fs=require('fs') | ||
6 | +const ejs=require('ejs') | ||
7 | +let globalMulligan | ||
8 | +let globalDecks | ||
9 | +exports.GetResult=(req,res)=>{ | ||
10 | + const deckId=req.session.deckId || 113 | ||
11 | + console.log('deckId in getMulligan',deckId) | ||
12 | + const opponentClass=req.session.opponentClass || 'PALADIN' | ||
13 | + console.log('opponentClass in getMulligan',opponentClass) | ||
14 | + const DataCheck=()=>{ | ||
15 | + return new Promise((resolve,reject)=>{ | ||
16 | + if (!deckId || !opponentClass){ | ||
17 | + return reject({ | ||
18 | + code:'query_error', | ||
19 | + message:'query error', | ||
20 | + }) | ||
21 | + } | ||
22 | + resolve() | ||
23 | + }) | ||
24 | + } | ||
25 | + const GetCardId=()=>{ | ||
26 | + return getCardId.GetCardId(deckId) | ||
27 | + } | ||
28 | + | ||
29 | + const GetMulContent=(cardIds)=>{ | ||
30 | + cardIds=JSON.stringify(cardIds) | ||
31 | + cardIds=JSON.parse(cardIds) | ||
32 | + let idInQuery=cardIds[0].cardId | ||
33 | + for(let i=1;i<cardIds.length ;i++){ | ||
34 | + idInQuery+= '%2C'+cardIds[i].cardId | ||
35 | + } | ||
36 | + console.log('idInQuery in crawlerMulligan ',idInQuery) | ||
37 | + return new Promise((resolve,reject)=>{ | ||
38 | + const asyncFunc=async ()=>{ | ||
39 | + const browser=await puppeteer.launch() | ||
40 | + try{ | ||
41 | + const page=await browser.newPage() | ||
42 | + await page.setViewport({width:1366,height:768}) | ||
43 | + await page.goto(`https://hsreplay.net/decks/#timeRange=LAST_30_DAYS&includedCards=${idInQuery}`,{waitUntil: 'networkidle2'}) | ||
44 | + const content=await page.content() | ||
45 | + browser.close() | ||
46 | + return content | ||
47 | + } | ||
48 | + catch(err) | ||
49 | + { | ||
50 | + console.log(err) | ||
51 | + browser.close() | ||
52 | + } | ||
53 | + } | ||
54 | + resolve(asyncFunc()) | ||
55 | + }) | ||
56 | + } | ||
57 | + | ||
58 | + const GetDeckHref=(content)=>{ | ||
59 | + return new Promise((resolve,reject)=>{ | ||
60 | + const $=cheerio.load(content) | ||
61 | + let deck=$('#decks-container > div > main > div.deck-list > ul > li:nth-child(2)').find('a') | ||
62 | + const deckHref=$(deck).attr('href') | ||
63 | + console.log('deckHref in crawlerMulligan :',deckHref) | ||
64 | + resolve(deckHref) | ||
65 | + }) | ||
66 | + } | ||
67 | + const GetDeckContent=(href)=>{ | ||
68 | + return new Promise((resolve,reject)=>{ | ||
69 | + const asyncFunc=async ()=>{ | ||
70 | + const browser=await puppeteer.launch() | ||
71 | + try{ | ||
72 | + const page=await browser.newPage() | ||
73 | + await page.setViewport({width:1366,height:768}) | ||
74 | + await page.goto(`https://hsreplay.net${href}?hl=ko`,{waitUntil: 'networkidle2'}) | ||
75 | + const content=await page.content() | ||
76 | + browser.close() | ||
77 | + return content | ||
78 | + } | ||
79 | + catch(err) | ||
80 | + { | ||
81 | + console.log(err) | ||
82 | + browser.close() | ||
83 | + } | ||
84 | + } | ||
85 | + resolve(asyncFunc()) | ||
86 | + }) | ||
87 | + } | ||
88 | + const GetMulligan=(content)=>{ | ||
89 | + return new Promise((resolve,reject)=>{ | ||
90 | + const $=cheerio.load(content) | ||
91 | + let cardNames=$('.card-name') | ||
92 | + let cardWinRates=$('.table-cell') | ||
93 | + let cards=[] | ||
94 | + for(let i=0;i<cardNames.length;i++){ | ||
95 | + let cardName=$(cardNames[i]).text() | ||
96 | + let cardWinRate=$(cardWinRates[6*i]).text() | ||
97 | + cardWinRate=cardWinRate.replace('▼','') | ||
98 | + cardWinRate=cardWinRate.replace('▲','') | ||
99 | + cardWinRate=cardWinRate.replace('%','') | ||
100 | + cards.push({cardName:cardName,cardWinRate:cardWinRate}) | ||
101 | + } | ||
102 | + cards.sort((a,b)=>{ | ||
103 | + return a.cardWinRate<b.cardWinRate ? 1:-1 | ||
104 | + }) | ||
105 | + resolve(cards) | ||
106 | + }) | ||
107 | + } | ||
108 | + const GetOppContent=()=>{ | ||
109 | + return new Promise((resolve,reject)=>{ | ||
110 | + const asyncFunc=async ()=>{ | ||
111 | + const browser=await puppeteer.launch() | ||
112 | + try{ | ||
113 | + const page=await browser.newPage() | ||
114 | + await page.setViewport({width:1366,height:768}) | ||
115 | + await page.goto(`https://hsreplay.net/decks/#playerClasses=${opponentClass}`,{waitUntil: 'networkidle2'}) | ||
116 | + const content=await page.content() | ||
117 | + browser.close() | ||
118 | + return content | ||
119 | + } | ||
120 | + catch(err) | ||
121 | + { | ||
122 | + console.log(err) | ||
123 | + browser.close() | ||
124 | + } | ||
125 | + } | ||
126 | + resolve(asyncFunc()) | ||
127 | + }) | ||
128 | + } | ||
129 | + | ||
130 | + const GetDeckInfo=(content)=>{ | ||
131 | + return new Promise((resolve,reject)=>{ | ||
132 | + const $=cheerio.load(content) | ||
133 | + let deckNames=$('.deck-name') | ||
134 | + let deckGames=$('.game-count') | ||
135 | + let decks=[] | ||
136 | + for(let i=0;decks.length<3;i++) { | ||
137 | + let deckName = $(deckNames[i]).text() | ||
138 | + let deckGame = $(deckGames[i]).text() | ||
139 | + let j=0 | ||
140 | + for(;j<decks.length;j++){ | ||
141 | + if(deckName===decks[j].deckTitle) | ||
142 | + break | ||
143 | + } | ||
144 | + if(j===decks.length){ | ||
145 | + decks.push({deckTitle:deckName,deckGame:deckGame}) | ||
146 | + } | ||
147 | + } | ||
148 | + console.log(decks) | ||
149 | + resolve(decks) | ||
150 | + }) | ||
151 | + } | ||
152 | + DataCheck() | ||
153 | + .then(GetCardId) | ||
154 | + //.then(CrawlerMulligan) | ||
155 | + .then(GetMulContent) | ||
156 | + .then(GetDeckHref) | ||
157 | + .then(GetDeckContent) | ||
158 | + .then(GetMulligan) | ||
159 | + .then((cards)=>{ | ||
160 | + return new Promise((resolve,reject)=>{ | ||
161 | + globalMulligan=cards | ||
162 | + resolve() | ||
163 | + }) | ||
164 | + }) | ||
165 | + .then(GetOppContent) | ||
166 | + .then(GetDeckInfo) | ||
167 | + .then((decks)=>{ | ||
168 | + return new Promise((resolve,reject)=>{ | ||
169 | + globalDecks=decks | ||
170 | + resolve() | ||
171 | + }) | ||
172 | + }) | ||
173 | + .then(()=>{ | ||
174 | + return new Promise((resolve,reject)=>{ | ||
175 | + let result={} | ||
176 | + result.cards=globalMulligan | ||
177 | + result.decks=globalDecks | ||
178 | + resolve(result) | ||
179 | + }) | ||
180 | + }) | ||
181 | + .then((result)=>{ | ||
182 | + console.log('result: ',result) | ||
183 | + fs.readFile('./views/ejs/result.ejs','utf-8',(err,data)=>{ | ||
184 | + res.writeHead(200,{'Content-Type':'text/html'}) | ||
185 | + res.end(ejs.render(data,{ | ||
186 | + cards:globalMulligan || [], | ||
187 | + decks:globalDecks || [], | ||
188 | + })) | ||
189 | + }) | ||
190 | + }) | ||
191 | + .catch((err)=>{ | ||
192 | + console.log(err) | ||
193 | + }) | ||
194 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -2,7 +2,11 @@ const express=require('express') | ... | @@ -2,7 +2,11 @@ const express=require('express') |
2 | const router=express.Router() | 2 | const router=express.Router() |
3 | 3 | ||
4 | const getMulligan=require('./getMulligan') | 4 | const getMulligan=require('./getMulligan') |
5 | +const getOpponent=require('./getOpponent') | ||
6 | +const setOpponentClass=require('./setOpponentClass') | ||
5 | 7 | ||
6 | -router.post('/getmulligan',getMulligan.GetMulligan) | 8 | +router.get('/getmulligan',getMulligan.GetMulligan) |
9 | +router.get('/getopponent',getOpponent.GetOpponent) | ||
10 | +router.post('/setopponentclass',setOpponentClass.SetOpponentClass) | ||
7 | 11 | ||
8 | module.exports=router | 12 | module.exports=router |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
api/card/setOpponentClass.js
0 → 100644
1 | +exports.SetOpponentClass=(req,res)=>{ | ||
2 | + const opponentClass=req.body.opponentClass | ||
3 | + const DataCheck=()=>{ | ||
4 | + return new Promise((resolve,reject)=>{ | ||
5 | + if(!opponentClass){ | ||
6 | + reject(({ | ||
7 | + query:'request_body_error' | ||
8 | + })) | ||
9 | + } | ||
10 | + else resolve() | ||
11 | + }) | ||
12 | + } | ||
13 | + const Set=()=>{ | ||
14 | + req.session.opponentClass=req.body.opponentClass | ||
15 | + return | ||
16 | + } | ||
17 | + DataCheck() | ||
18 | + .then(Set) | ||
19 | + .then(()=>{ | ||
20 | + res.status(200).json({message:'complete setting opponent class'}) | ||
21 | + }) | ||
22 | + .catch((err)=>{ | ||
23 | + res.status(500).json(err||err.message) | ||
24 | + }) | ||
25 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -46,20 +46,9 @@ app.use(session({ | ... | @@ -46,20 +46,9 @@ app.use(session({ |
46 | })) | 46 | })) |
47 | 47 | ||
48 | app.get('/',(req,res)=>{ | 48 | app.get('/',(req,res)=>{ |
49 | - res.redirect('/main') | 49 | + res.redirect('/decklist') |
50 | }) | 50 | }) |
51 | 51 | ||
52 | -app.get('/main',(req,res)=>{ | ||
53 | - console.log(`GET /main\ncurrent sid : ${req.session.sid}`) | ||
54 | - if(!req.session.sid) | ||
55 | - res.redirect('/login') | ||
56 | - else { | ||
57 | - fs.readFile('./views/html/main.html',(err,data)=>{ | ||
58 | - res.writeHead(200, {'Content-Type': 'text/html'}) | ||
59 | - res.end(data) | ||
60 | - }) | ||
61 | - } | ||
62 | -}) | ||
63 | 52 | ||
64 | app.get('/signup',(req,res)=>{ | 53 | app.get('/signup',(req,res)=>{ |
65 | fs.readFile('./views/html/signup.html',(err,data)=>{ | 54 | fs.readFile('./views/html/signup.html',(err,data)=>{ |
... | @@ -77,6 +66,7 @@ app.get('/login',(req,res)=>{ | ... | @@ -77,6 +66,7 @@ app.get('/login',(req,res)=>{ |
77 | 66 | ||
78 | app.post('/logout',(req,res)=>{ | 67 | app.post('/logout',(req,res)=>{ |
79 | console.log('logout') | 68 | console.log('logout') |
69 | + delete req.session.deckId | ||
80 | delete req.session.sid | 70 | delete req.session.sid |
81 | res.status(200).json({result:'Logout Successful'}) | 71 | res.status(200).json({result:'Logout Successful'}) |
82 | }) | 72 | }) |
... | @@ -106,10 +96,11 @@ app.get('/decklist',(req,res)=>{ | ... | @@ -106,10 +96,11 @@ app.get('/decklist',(req,res)=>{ |
106 | 96 | ||
107 | }) | 97 | }) |
108 | 98 | ||
109 | -app.get('/ingame',(req,res)=>{ | 99 | +app.get('/ingame/:deckId',(req,res)=>{ |
110 | if(!req.session.sid) | 100 | if(!req.session.sid) |
111 | res.redirect('/login') | 101 | res.redirect('/login') |
112 | else{ | 102 | else{ |
103 | + req.session.deckId=req.params.deckId | ||
113 | fs.readFile('./views/html/ingame.html',(err,data)=>{ | 104 | fs.readFile('./views/html/ingame.html',(err,data)=>{ |
114 | res.writeHead(200,{'Content-Type':'text/html'}) | 105 | res.writeHead(200,{'Content-Type':'text/html'}) |
115 | res.end(data) | 106 | res.end(data) |
... | @@ -127,7 +118,56 @@ app.get('/newdeck',(req,res)=>{ | ... | @@ -127,7 +118,56 @@ app.get('/newdeck',(req,res)=>{ |
127 | res.end(data) | 118 | res.end(data) |
128 | }) | 119 | }) |
129 | } | 120 | } |
121 | +}) | ||
122 | + | ||
123 | +const getMulligan=require('./api/card/getMulligan') | ||
124 | +const getOpponent=require('./api/card/getOpponent') | ||
125 | +const getResult=require('./api/card/getResult') | ||
130 | 126 | ||
127 | +app.get('/result',(req,res)=>{ | ||
128 | + if(!req.session.sid) | ||
129 | + res.redirect('/login') | ||
130 | + else{ | ||
131 | + let mulligan | ||
132 | + let opponentDecks; | ||
133 | + (async ()=>{ | ||
134 | + const result=await getResult.GetResult(req,res) | ||
135 | + console.log('hsreplay.net에서 받아오는 중') | ||
136 | + /*setTimeout(function(){ | ||
137 | + console.log('result: ',result) | ||
138 | + fs.readFile('./views/html/result.ejs',(err,data)=>{ | ||
139 | + res.writeHead(200,{'Content-Type':'text/html'}) | ||
140 | + res.end(ejs.render(data,{ | ||
141 | + cards:result.cards || [], | ||
142 | + decks:result.decks || [], | ||
143 | + })) | ||
144 | + }) | ||
145 | + },30000)*/ | ||
146 | + })() | ||
147 | + const GetInfo=async ()=>{ | ||
148 | + return getResult.GetResult(req,res) | ||
149 | + } | ||
150 | + const GetCards=()=>{ | ||
151 | + return getMulligan.GetMulligan(req,res) | ||
152 | + } | ||
153 | + const GetDecks=(cards)=>{ | ||
154 | + mulligan=cards | ||
155 | + return getOpponent.GetOpponent(req,res) | ||
156 | + } | ||
157 | + const Render=async (result)=>{ | ||
158 | + mulligan=result.cards | ||
159 | + opponentDecks=result.decks | ||
160 | + setTimeout(function(){ | ||
161 | + fs.readFile('./views/html/result.ejs',(err,data)=>{ | ||
162 | + res.writeHead(200,{'Content-Type':'text/html'}) | ||
163 | + res.end(ejs.render(data,{ | ||
164 | + cards:mulligan || [], | ||
165 | + decks:opponentDecks || [], | ||
166 | + })) | ||
167 | + }) | ||
168 | + },1000) | ||
169 | + } | ||
170 | + } | ||
131 | }) | 171 | }) |
132 | 172 | ||
133 | app.listen(process.env.SERVER_PORT || 3000,()=>{ | 173 | app.listen(process.env.SERVER_PORT || 3000,()=>{ | ... | ... |
... | @@ -24,7 +24,7 @@ | ... | @@ -24,7 +24,7 @@ |
24 | url:'/logout', | 24 | url:'/logout', |
25 | success:function(result){ | 25 | success:function(result){ |
26 | alert('로그아웃 성공!') | 26 | alert('로그아웃 성공!') |
27 | - window.location.href='/main' | 27 | + window.location.href='/' |
28 | }, | 28 | }, |
29 | error:function(result){ | 29 | error:function(result){ |
30 | alert('로그아웃 실패!') | 30 | alert('로그아웃 실패!') |
... | @@ -67,7 +67,7 @@ | ... | @@ -67,7 +67,7 @@ |
67 | <br> | 67 | <br> |
68 | <table class="table"> | 68 | <table class="table"> |
69 | <% for ( var i=0;i<decks.length;i++) { %> | 69 | <% for ( var i=0;i<decks.length;i++) { %> |
70 | - <tr><td style="text-align: center;"><a class="list-group-item" href="/ingame?deck=<%= decks[i].id %>"><%= decks[i].deckTitle %></a></td></tr> | 70 | + <tr><td style="text-align: center;"><a class="list-group-item" href="/ingame/<%= decks[i].id %>"><%= decks[i].deckTitle %></a></td></tr> |
71 | <% } %> | 71 | <% } %> |
72 | </table> | 72 | </table> |
73 | </div> | 73 | </div> | ... | ... |
... | @@ -15,7 +15,6 @@ | ... | @@ -15,7 +15,6 @@ |
15 | <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | 15 | <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> |
16 | <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | 16 | <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> |
17 | <![endif]--> | 17 | <![endif]--> |
18 | - | ||
19 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | 18 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
20 | <script> | 19 | <script> |
21 | $(document).ready(function(){ | 20 | $(document).ready(function(){ |
... | @@ -33,53 +32,89 @@ | ... | @@ -33,53 +32,89 @@ |
33 | } | 32 | } |
34 | }) | 33 | }) |
35 | }) | 34 | }) |
35 | + $('#backToSelectOpponent').click(function(){ | ||
36 | + window.history.back() | ||
37 | + }) | ||
36 | }) | 38 | }) |
37 | </script> | 39 | </script> |
38 | </head> | 40 | </head> |
39 | <body> | 41 | <body> |
40 | -<nav class="navbar-default navbar-fixed-top"> | 42 | + <nav class="navbar-default navbar-fixed-top"> |
41 | - <div class="container"> | 43 | + <div class="container"> |
42 | - <div class="navbar-header"> | 44 | + <div class="navbar-header"> |
43 | - <button class="navbar-toggle collapsed" aria-expanded="false" aria-controls="navbar" type="button" data-toggle="collapse" data-target="#navbar"> | 45 | + <button class="navbar-toggle collapsed" aria-expanded="false" aria-controls="navbar" type="button" data-toggle="collapse" data-target="#navbar"> |
44 | - <span class="sr-only">Toggle navigation</span> | 46 | + <span class="sr-only">Toggle navigation</span> |
45 | - <span class="icon-bar"></span> | 47 | + <span class="icon-bar"></span> |
46 | - <span class="icon-bar"></span> | 48 | + <span class="icon-bar"></span> |
47 | - <span class="icon-bar"></span> | 49 | + <span class="icon-bar"></span> |
48 | - </button> | 50 | + </button> |
49 | - <a class="navbar-brand" href="/main">Who Are You?</a> | 51 | + <a class="navbar-brand" href="/">Who Are You?</a> |
50 | - </div> | 52 | + </div> |
51 | - <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> | 53 | + <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> |
52 | - <ul class="nav navbar-nav"> | 54 | + <ul class="nav navbar-nav"> |
53 | - </ul> | 55 | + </ul> |
54 | - <div class="navbar-right"> | 56 | + <div class="navbar-right"> |
55 | - <input type="button" class="btn navbar-btn" id="logoutButton" style="color:#000;" value="로그아웃" /> | 57 | + <input type="button" class="btn navbar-btn" id="logoutButton" style="color:#000;" value="로그아웃" /> |
58 | + </div> | ||
56 | </div> | 59 | </div> |
57 | </div> | 60 | </div> |
58 | - </div> | 61 | + </nav> |
59 | -</nav> | ||
60 | 62 | ||
61 | -<div class="container show-grid" style="height:50%;"> | 63 | + <div class="container show-grid" > |
62 | - <div class="padding"></div> | 64 | + <div class="padding" style="width:100px"></div> |
63 | - <h3 class="form-signin-heading">실행할 메뉴를 선택해 주세요</h3> | ||
64 | - <div class="col-md-6 "> | ||
65 | - <br> | ||
66 | - <br> | ||
67 | - <a href="/decklist"><input class="btn btn-lg btn-primary btn-block" type="button" id="goMyDecks" value="덱 확인"/></a> | ||
68 | <br> | 65 | <br> |
69 | <br> | 66 | <br> |
70 | - </div> | 67 | + <h3 class="form-signin-heading">상대편의 주요 덱</h3> |
71 | - <div class="col-md-6 "> | 68 | + <div id="opponentDecks"> |
69 | + <table class="table" style="text-align: center;"> | ||
70 | + <thead> | ||
71 | + <td>덱 이름</td> | ||
72 | + <td>플레이 수</td> | ||
73 | + </thead> | ||
74 | + <tbody > | ||
75 | + <% for(var i=0;i<decks.length;i++){%> | ||
76 | + <tr> | ||
77 | + <td><a class="list-group-item"><%= decks[i].deckTitle %></a></td> | ||
78 | + <td><a class="list-group-item"><%= decks[i].deckGame %></a></td> | ||
79 | + </tr> | ||
80 | + <%}%> | ||
81 | + </tbody> | ||
82 | + </table> | ||
83 | + </div> | ||
72 | <br> | 84 | <br> |
73 | <br> | 85 | <br> |
74 | - <a href="/ingame"><input class="btn btn-lg btn-primary btn-block" type="button" id="goGame" value="게임 시작"/></a> | 86 | + <h3 class="form-signin-heading">내 덱의 추천 멀리건</h3> |
87 | + <div id="yourMulligan"> | ||
88 | + <table class="table" style="text-align: center;"> | ||
89 | + <thead> | ||
90 | + <td>카드 이름</td> | ||
91 | + <td>멀리건 승률</td> | ||
92 | + </thead> | ||
93 | + <tbody> | ||
94 | + <% for(var i=0;i<cards.length;i++){%> | ||
95 | + <tr> | ||
96 | + <td><a class="list-group-item"><%= cards[i].cardName %></a></td> | ||
97 | + <td><a class="list-group-item"><%= cards[i].cardWinRate %></a></td> | ||
98 | + </tr> | ||
99 | + <%}%> | ||
100 | + </tbody> | ||
101 | + </table> | ||
102 | + </div> | ||
75 | <br> | 103 | <br> |
76 | <br> | 104 | <br> |
105 | + <div class="row"> | ||
106 | + <div class="col-md-6"> | ||
107 | + <a href="/decklist"><input class="btn btn-lg btn-primary btn-block" type="button" id="backToDeckList" value="덱 선택으로 돌아가기" /></a> | ||
108 | + </div> | ||
109 | + <div class="col-md-6"> | ||
110 | + <input class="btn btn-lg btn-primary btn-block" type="button" id="backToSelectOpponent" value="상대편 직업 선택으로 돌아가기"/> | ||
111 | + </div> | ||
112 | + </div> | ||
77 | </div> | 113 | </div> |
78 | -</div> | ||
79 | 114 | ||
80 | -<!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) --> | 115 | + <!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) --> |
81 | -<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> | 116 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> |
82 | -<!-- 모든 컴파일된 플러그인을 포함합니다 (아래), 원하지 않는다면 필요한 각각의 파일을 포함하세요 --> | 117 | + <!-- 모든 컴파일된 플러그인을 포함합니다 (아래), 원하지 않는다면 필요한 각각의 파일을 포함하세요 --> |
83 | -<script src="../../static/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script> | 118 | + <script src="../../static/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script> |
84 | </body> | 119 | </body> |
85 | </html> | 120 | </html> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -24,7 +24,7 @@ | ... | @@ -24,7 +24,7 @@ |
24 | url:'/logout', | 24 | url:'/logout', |
25 | success:function(result){ | 25 | success:function(result){ |
26 | alert('로그아웃 성공!') | 26 | alert('로그아웃 성공!') |
27 | - window.location.href='/main' | 27 | + window.location.href='/' |
28 | }, | 28 | }, |
29 | error:function(result){ | 29 | error:function(result){ |
30 | alert('로그아웃 실패!') | 30 | alert('로그아웃 실패!') |
... | @@ -45,7 +45,7 @@ | ... | @@ -45,7 +45,7 @@ |
45 | <span class="icon-bar"></span> | 45 | <span class="icon-bar"></span> |
46 | <span class="icon-bar"></span> | 46 | <span class="icon-bar"></span> |
47 | </button> | 47 | </button> |
48 | - <a class="navbar-brand" href="/main">Who Are You?</a> | 48 | + <a class="navbar-brand" href="/">Who Are You?</a> |
49 | </div> | 49 | </div> |
50 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> | 50 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> |
51 | <ul class="nav navbar-nav"> | 51 | <ul class="nav navbar-nav"> | ... | ... |
... | @@ -24,7 +24,7 @@ | ... | @@ -24,7 +24,7 @@ |
24 | url:'/logout', | 24 | url:'/logout', |
25 | success:function(result){ | 25 | success:function(result){ |
26 | alert('로그아웃 성공!') | 26 | alert('로그아웃 성공!') |
27 | - window.location.href='/main' | 27 | + window.location.href='/' |
28 | }, | 28 | }, |
29 | error:function(result){ | 29 | error:function(result){ |
30 | alert('로그아웃 실패!') | 30 | alert('로그아웃 실패!') |
... | @@ -33,7 +33,27 @@ | ... | @@ -33,7 +33,27 @@ |
33 | }) | 33 | }) |
34 | }) | 34 | }) |
35 | $('#submitButton').click(function(){ | 35 | $('#submitButton').click(function(){ |
36 | - | 36 | + let data=new Object() |
37 | + let opponentClass=$('input[name="checkOpponent"]:checked').val() | ||
38 | + data.opponentClass=opponentClass | ||
39 | + const stringData=JSON.stringify(data) | ||
40 | + alert('잠시 기다리시겠습니까?') | ||
41 | + $.ajax({ | ||
42 | + type:'POST', | ||
43 | + url:'/api/card/setopponentclass', | ||
44 | + data:stringData, | ||
45 | + dataType:'JSON', | ||
46 | + contentType:'application/json; charset=utf-8', | ||
47 | + traditional:true, | ||
48 | + processdata:false, | ||
49 | + success:function(){ | ||
50 | + window.location.href='/result' | ||
51 | + }, | ||
52 | + error:function(){ | ||
53 | + alert('상대 직업 선택 실패!') | ||
54 | + return false | ||
55 | + } | ||
56 | + }) | ||
37 | }) | 57 | }) |
38 | }) | 58 | }) |
39 | </script> | 59 | </script> |
... | @@ -48,7 +68,7 @@ | ... | @@ -48,7 +68,7 @@ |
48 | <span class="icon-bar"></span> | 68 | <span class="icon-bar"></span> |
49 | <span class="icon-bar"></span> | 69 | <span class="icon-bar"></span> |
50 | </button> | 70 | </button> |
51 | - <a class="navbar-brand" href="/main">Who Are You?</a> | 71 | + <a class="navbar-brand" href="/">Who Are You?</a> |
52 | </div> | 72 | </div> |
53 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> | 73 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> |
54 | <ul class="nav navbar-nav"> | 74 | <ul class="nav navbar-nav"> |
... | @@ -89,7 +109,7 @@ | ... | @@ -89,7 +109,7 @@ |
89 | <div class="col-md-4"> | 109 | <div class="col-md-4"> |
90 | <img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/4/4d/Uther_Lightbringer%28257%29.png?version=b45ade5ac3fdd2579160fe5d7b7c1b20" style="width:150px;height:200px;"/> | 110 | <img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/4/4d/Uther_Lightbringer%28257%29.png?version=b45ade5ac3fdd2579160fe5d7b7c1b20" style="width:150px;height:200px;"/> |
91 | <br> | 111 | <br> |
92 | - <input type="radio" name="checkOpponent" value="PALADIN"/>성기사 | 112 | + <input type="radio" name="checkOpponent" value="PALADIN"/>성기사 |
93 | </div> | 113 | </div> |
94 | <div class="col-md-4"> | 114 | <div class="col-md-4"> |
95 | <img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/a/a0/Rexxar%28484%29.png?version=c21b57837db15d20cc814f2bf45682b6" style="width:150px;height:200px;"/> | 115 | <img src="https://d1u5p3l4wpay3k.cloudfront.net/hearthstone_gamepedia/a/a0/Rexxar%28484%29.png?version=c21b57837db15d20cc814f2bf45682b6" style="width:150px;height:200px;"/> | ... | ... |
... | @@ -33,7 +33,7 @@ | ... | @@ -33,7 +33,7 @@ |
33 | processdata:false, | 33 | processdata:false, |
34 | success:function(result){ | 34 | success:function(result){ |
35 | alert('로그인 성공!') | 35 | alert('로그인 성공!') |
36 | - window.location.href='/main' | 36 | + window.location.href='/decklist' |
37 | }, | 37 | }, |
38 | error:function(result){ | 38 | error:function(result){ |
39 | alert(`로그인 실패!\nmessage:${result['message']}`) | 39 | alert(`로그인 실패!\nmessage:${result['message']}`) |
... | @@ -58,7 +58,7 @@ | ... | @@ -58,7 +58,7 @@ |
58 | <span class="icon-bar"></span> | 58 | <span class="icon-bar"></span> |
59 | <span class="icon-bar"></span> | 59 | <span class="icon-bar"></span> |
60 | </button> | 60 | </button> |
61 | - <a class="navbar-brand" href="/main">Who Are You?</a> | 61 | + <a class="navbar-brand" href="/">Who Are You?</a> |
62 | </div> | 62 | </div> |
63 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> | 63 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> |
64 | <ul class="nav navbar-nav"> | 64 | <ul class="nav navbar-nav"> | ... | ... |
... | @@ -24,7 +24,7 @@ | ... | @@ -24,7 +24,7 @@ |
24 | url:'/logout', | 24 | url:'/logout', |
25 | success:function(result){ | 25 | success:function(result){ |
26 | alert('로그아웃 성공!') | 26 | alert('로그아웃 성공!') |
27 | - window.location.href='/main' | 27 | + window.location.href='/' |
28 | }, | 28 | }, |
29 | error:function(result){ | 29 | error:function(result){ |
30 | alert('로그아웃 실패!') | 30 | alert('로그아웃 실패!') |
... | @@ -38,6 +38,7 @@ | ... | @@ -38,6 +38,7 @@ |
38 | data.deckCode=$('#deckCode').val() | 38 | data.deckCode=$('#deckCode').val() |
39 | const stringData=JSON.stringify(data) | 39 | const stringData=JSON.stringify(data) |
40 | console.log(stringData) | 40 | console.log(stringData) |
41 | + alert('잠시 기다리시겠습니까?') | ||
41 | $.ajax({ | 42 | $.ajax({ |
42 | type:'POST', | 43 | type:'POST', |
43 | url:'/api/deck/newdeck', | 44 | url:'/api/deck/newdeck', |
... | @@ -69,7 +70,7 @@ | ... | @@ -69,7 +70,7 @@ |
69 | <span class="icon-bar"></span> | 70 | <span class="icon-bar"></span> |
70 | <span class="icon-bar"></span> | 71 | <span class="icon-bar"></span> |
71 | </button> | 72 | </button> |
72 | - <a class="navbar-brand" href="/main">Who Are You?</a> | 73 | + <a class="navbar-brand" href="/">Who Are You?</a> |
73 | </div> | 74 | </div> |
74 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> | 75 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> |
75 | <ul class="nav navbar-nav"> | 76 | <ul class="nav navbar-nav"> | ... | ... |
views/html/result.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<html lang="ko"> | ||
3 | +<head> | ||
4 | + <meta charset="utf-8"> | ||
5 | + <meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
6 | + <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
7 | + <title>Who Are You? - 하스스톤 멀리건 도우미</title> | ||
8 | + | ||
9 | + <!-- 부트스트랩 --> | ||
10 | + <link href="../../static/bootstrap-3.3.2-dist/css/bootstrap.min.css?ver=1" rel="stylesheet"> | ||
11 | + <link href="../../static/main.css" rel="stylesheet"> | ||
12 | + <!-- IE8 에서 HTML5 요소와 미디어 쿼리를 위한 HTML5 shim 와 Respond.js --> | ||
13 | + <!-- WARNING: Respond.js 는 당신이 file:// 을 통해 페이지를 볼 때는 동작하지 않습니다. --> | ||
14 | + <!--[if lt IE 9]> | ||
15 | + <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> | ||
16 | + <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> | ||
17 | + <![endif]--> | ||
18 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> | ||
19 | + <script> | ||
20 | + $(document).ready(function(){ | ||
21 | + let mulligan,opponentDecks | ||
22 | + $.ajax({ | ||
23 | + type:'GET', | ||
24 | + url:'/api/card/getmulligan', | ||
25 | + success:function(result){ | ||
26 | + mulligan=result | ||
27 | + $('#yourMulligan').add('<ul>') | ||
28 | + for(let i=0;i<mulligan.length;i++){ | ||
29 | + $('#yourMulligan').add(`<li><h4>카드 이름:${mulligan[i]['cardName']}</h4><br><h5>멀리건 승률:${mulligan[i]['cardWinRate']}</h5></li>`) | ||
30 | + } | ||
31 | + $('#yourMulligan').add('</ul>') | ||
32 | + } | ||
33 | + }) | ||
34 | + $.ajax({ | ||
35 | + type:'GET', | ||
36 | + url:'/api/card/getopponent', | ||
37 | + success:function(result){ | ||
38 | + opponentDecks=result | ||
39 | + $('#opponentDecks').add('<ul>') | ||
40 | + for(let i=0;i<opponentDecks.length;i++){ | ||
41 | + $('#opponentDecks').add(`<li><h4>덱 이름:${opponentDecks[i]['deckTitle']}</h4><br><h5>30일간 플레이 수:${opponentDecks[i]['deckGame']}</h5></li>`) | ||
42 | + } | ||
43 | + $('#opponentDecks').add('</ul>') | ||
44 | + } | ||
45 | + }) | ||
46 | + | ||
47 | + $('#logoutButton').click(function(){ | ||
48 | + $.ajax({ | ||
49 | + type:'POST', | ||
50 | + url:'/logout', | ||
51 | + success:function(result){ | ||
52 | + alert('로그아웃 성공!') | ||
53 | + window.location.href='/' | ||
54 | + }, | ||
55 | + error:function(result){ | ||
56 | + alert('로그아웃 실패!') | ||
57 | + return false | ||
58 | + } | ||
59 | + }) | ||
60 | + }) | ||
61 | + $('#backToSelectOpponent').click(function(){ | ||
62 | + window.history.back() | ||
63 | + }) | ||
64 | + }) | ||
65 | + </script> | ||
66 | +</head> | ||
67 | +<body> | ||
68 | + <nav class="navbar-default navbar-fixed-top"> | ||
69 | + <div class="container"> | ||
70 | + <div class="navbar-header"> | ||
71 | + <button class="navbar-toggle collapsed" aria-expanded="false" aria-controls="navbar" type="button" data-toggle="collapse" data-target="#navbar"> | ||
72 | + <span class="sr-only">Toggle navigation</span> | ||
73 | + <span class="icon-bar"></span> | ||
74 | + <span class="icon-bar"></span> | ||
75 | + <span class="icon-bar"></span> | ||
76 | + </button> | ||
77 | + <a class="navbar-brand" href="/">Who Are You?</a> | ||
78 | + </div> | ||
79 | + <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> | ||
80 | + <ul class="nav navbar-nav"> | ||
81 | + </ul> | ||
82 | + <div class="navbar-right"> | ||
83 | + <input type="button" class="btn navbar-btn" id="logoutButton" style="color:#000;" value="로그아웃" /> | ||
84 | + </div> | ||
85 | + </div> | ||
86 | + </div> | ||
87 | + </nav> | ||
88 | + | ||
89 | + <div class="container show-grid" > | ||
90 | + <div class="padding" style="width:100px"></div> | ||
91 | + <br> | ||
92 | + <br> | ||
93 | + <h3 class="form-signin-heading">상대편의 주요 덱</h3> | ||
94 | + <div id="opponentDecks"></div> | ||
95 | + <br> | ||
96 | + <br> | ||
97 | + <h3 class="form-signin-heading">내 덱의 추천 멀리건</h3> | ||
98 | + <div id="yourMulligan"></div> | ||
99 | + <br> | ||
100 | + <br> | ||
101 | + <div class="row"> | ||
102 | + <div class="col-md-6"> | ||
103 | + <a href="/decklist"><input class="btn btn-lg btn-primary btn-block" type="button" id="backToDeckList" value="덱 선택으로 돌아가기" /></a> | ||
104 | + </div> | ||
105 | + <div class="col-md-6"> | ||
106 | + <input class="btn btn-lg btn-primary btn-block" type="button" id="backToSelectOpponent" value="상대편 직업 선택으로 돌아가기"/> | ||
107 | + </div> | ||
108 | + </div> | ||
109 | + </div> | ||
110 | + | ||
111 | + <!-- jQuery (부트스트랩의 자바스크립트 플러그인을 위해 필요합니다) --> | ||
112 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> | ||
113 | + <!-- 모든 컴파일된 플러그인을 포함합니다 (아래), 원하지 않는다면 필요한 각각의 파일을 포함하세요 --> | ||
114 | + <script src="../../static/bootstrap-3.3.2-dist/js/bootstrap.min.js"></script> | ||
115 | +</body> | ||
116 | +</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -62,7 +62,7 @@ | ... | @@ -62,7 +62,7 @@ |
62 | <span class="icon-bar"></span> | 62 | <span class="icon-bar"></span> |
63 | <span class="icon-bar"></span> | 63 | <span class="icon-bar"></span> |
64 | </button> | 64 | </button> |
65 | - <a class="navbar-brand" href="/main">Who Are You?</a> | 65 | + <a class="navbar-brand" href="/">Who Are You?</a> |
66 | </div> | 66 | </div> |
67 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> | 67 | <div class="navbar-collapse collapse" id="navbar" aria-expanded="false" style="height: 1px;"> |
68 | <ul class="nav navbar-nav"> | 68 | <ul class="nav navbar-nav"> | ... | ... |
-
Please register or login to post a comment