정주희

Rearrange files

1 -const express = require('express');
2 -const fs = require('fs');
3 -const path = require('path');
4 -const HTTPS = require('https');
5 -
6 -const app = express();
7 -const domain = "2020105636.oss-2021.tk"
8 -const sslport = 23023;
9 -
10 -app.use(express.static(__dirname));
11 -
12 -app.get('/', function(req, res){
13 - res.sendFile(__dirname + '/main.html');
14 -});
15 -
16 -app.get('/main.html', function(req, res){
17 - res.sendFile(__dirname + '/main.html');
18 -});
19 -
20 -app.get('/introduction.html', function(req, res){
21 - res.sendFile(__dirname + '/introduction.html');
22 -});
23 -
24 -app.get('/calendar.html', function(req, res){
25 - res.sendFile(__dirname + '/calendar.html');
26 -});
27 -
28 -
29 -app.get('/simulation.html', function(req, res){
30 - res.sendFile(__dirname + '/simulation.html');
31 -});
32 -
33 -try {
34 - const option = {
35 - ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
36 - key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
37 - cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
38 - };
39 -
40 - HTTPS.createServer(option, app).listen(sslport, () => {
41 - console.log(`[HTTPS] Server is started on port ${sslport}`);
42 - });
43 -} catch (error) {
44 - console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
45 - console.log(error);
46 -}
...\ No newline at end of file ...\ No newline at end of file
1 -body{
2 - background-image:url(https://t1.daumcdn.net/cfile/blog/155A204A5026656D0E);
3 - background-repeat: no-repeat;
4 - background-size: cover;
5 -}
6 -.container1{
7 - display:flex;
8 - justify-content: center;
9 - align-items: baseline;
10 - padding:50px 0px 0px 0px;
11 -}
12 -.logo{
13 - font-size:40px;
14 - color:white;
15 -}
16 -*{
17 - margin: 0;
18 - padding: 0;
19 - box-sizing: border-box;
20 - font-family: sans-serif;
21 -}
22 -
23 -#menu{
24 - margin:60px 250px 0px 250px;
25 - height:90px;
26 - width:1000px;
27 -}
28 -#menu ul li{
29 - list-style:none;
30 - color:white;
31 - background-color:#011638;
32 - float:left;
33 - line-height:30px;
34 - vertical-align:middle;
35 - text-align:center;
36 - display:inline;
37 -}
38 -#menu .me{
39 - text-decoration:none;
40 - color:white;
41 - display:inline-block;
42 - width:250px;
43 - font-size:20px;
44 - font-weight:bold;
45 - font-family: "Trebuchet MS", Dotum, Arial;
46 -}
47 -#menu .me:hover{
48 - color:#D499B9;
49 - background-color: #2E294E;
50 -}
51 -
52 -.row{
53 - display:flex;
54 - justify-content: space-evenly;
55 - padding: 0px 0px 50px 0px;
56 -}
1 -<!DOCTYPE html>
2 -<html>
3 -<head>
4 - <title> Calendar </title>
5 - <link rel="stylesheet" type="text/css"href="calendar.css">
6 -</head>
7 -<body>
8 - <div class="container1">
9 - <span class="logo">Welcome to Baseball Simulator</span>
10 - </div>
11 - <nav id="menu">
12 - <ul>
13 - <li>
14 - <a class="me" href="main.html">Home</a>
15 - </li>
16 - <li>
17 - <a class="me" href="introduction.html">Introduction</a>
18 - </li>
19 - <li>
20 - <a class="me" href="calendar.html">Calendar</a>
21 - </li>
22 - <li>
23 - <a class="me" href="simulation.html">Simulation</a>
24 - </li>
25 - </ul>
26 - </nav>
27 - <div class="container2">
28 - <div class="row row1">
29 - <span class="item1">
30 - <a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=%EC%82%BC%EC%84%B1">
31 - <img src="pngs/samsung.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
32 - </a>
33 - </span>
34 - <span class="item2">
35 - <a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=NC">
36 - <img src="pngs/nc.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
37 - </a>
38 - </span>
39 - <span class="item3">
40 - <a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=LG">
41 - <img src="pngs/LG.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
42 - </a>
43 - </span>
44 - <span class="item4">
45 - <a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=KT">
46 - <img src="pngs/kt.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
47 - </a>
48 - </span>
49 - <span class="item5">
50 - <a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=SSG">
51 - <img src="pngs/ssg.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
52 - </a>
53 - </span>
54 - </div>
55 - <div class="row row2">
56 - <span class="item6">
57 - <a href="http://www.statiz.co.kr/team.php?cteam=%EB%91%90%EC%82%B0%2BOB&year=2021&opt=0&sopt=1">
58 - <img src="pngs/dusan.png" style="display:block; margin:0 auto; width:150px; height:150px;"alt="">
59 - </a>
60 - </span>
61 - <span class="item7">
62 - <a href="http://www.statiz.co.kr/team.php?cteam=%ED%9E%88%EC%96%B4%EB%A1%9C%EC%A6%88&year=2021&opt=0&sopt=1">
63 - <img src="pngs/kiwoom.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
64 - </a>
65 - </span>
66 - <span class="item8">
67 - <a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=KIA">
68 - <img src="pngs/kia.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
69 - </a>
70 - </span>
71 - <span class="item9">
72 - <a href="http://www.statiz.co.kr/team.php?cteam=%ED%95%9C%ED%99%94%2B%EB%B9%99%EA%B7%B8%EB%A0%88&year=2021&opt=0&sopt=1">
73 - <img src="pngs/hanhwa.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
74 - </a>
75 - </span>
76 - <span class="item10">
77 - <a href="http://www.statiz.co.kr/team.php?cteam=%EB%A1%AF%EB%8D%B0&year=2021&opt=0&sopt=1">
78 - <img src="pngs/Lotte.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
79 - </a>
80 - </span>
81 - </div>
82 - </div>
83 -</body>
84 -</html>
1 -body{
2 - background-image:url(https://t1.daumcdn.net/cfile/blog/155A204A5026656D0E);
3 - background-repeat: no-repeat;
4 - -webkit-background-size: cover;
5 - -moz-background-size: cover;
6 - -o-background-size: cover;
7 - background-size: cover;
8 -}
9 -.container1{
10 - display:flex;
11 - justify-content: center;
12 - align-items: baseline;
13 - padding:50px 0px 0px 0px;
14 -}
15 -.logo{
16 - font-size:40px;
17 - color:white;
18 -}
19 -*{
20 - margin: 0;
21 - padding: 0;
22 - box-sizing: border-box;
23 - font-family: sans-serif;
24 -}
25 -
26 -#menu{
27 - margin:60px 250px 0px 250px;
28 - height:90px;
29 - width:1000px;
30 -}
31 -#menu ul li{
32 - list-style:none;
33 - color:white;
34 - background-color:#011638;
35 - float:left;
36 - line-height:30px;
37 - vertical-align:middle;
38 - text-align:center;
39 - display:inline;
40 -}
41 -#menu .me{
42 - text-decoration:none;
43 - color:white;
44 - display:inline-block;
45 - width:250px;
46 - font-size:20px;
47 - font-weight:bold;
48 - font-family: "Trebuchet MS", Dotum, Arial;
49 -}
50 -#menu .me:hover{
51 - color:#D499B9;
52 - background-color: #2E294E;
53 -}
...\ No newline at end of file ...\ No newline at end of file
1 -<!DOCTYPE html>
2 -<html>
3 -<head>
4 - <title> Introduction </title>
5 - <link rel="stylesheet" type="text/css"href="introduction.css">
6 -</head>
7 -<body>
8 - <div class="container1">
9 - <span class="logo">Welcome to Baseball Simulator</span>
10 - </div>
11 - <nav id="menu">
12 - <ul>
13 - <li>
14 - <a class="me" href="main.html">Home</a>
15 - </li>
16 - <li>
17 - <a class="me" href="introduction.html">Introduction</a>
18 - </li>
19 - <li>
20 - <a class="me" href="calendar.html">Calendar</a>
21 - </li>
22 - <li>
23 - <a class="me" href="simulation.html">Simulation</a>
24 - </li>
25 - </ul>
26 - </nav>
27 -
28 -</body>
29 -</html>
1 -body{
2 - background-image:url(https://t1.daumcdn.net/cfile/blog/155A204A5026656D0E);
3 - background-repeat: no-repeat;
4 - -webkit-background-size: cover;
5 - -moz-background-size: cover;
6 - -o-background-size: cover;
7 - background-size: cover;
8 -}
9 -.container1{
10 - display:flex;
11 - justify-content: center;
12 - align-items: baseline;
13 - padding:50px 0px 0px 0px;
14 -}
15 -.logo{
16 - font-size:40px;
17 - color:white;
18 -}
19 -*{
20 - margin: 0;
21 - padding: 0;
22 - box-sizing: border-box;
23 - font-family: sans-serif;
24 -}
25 -
26 -#menu{
27 - margin:60px 250px 0px 250px;
28 - height:90px;
29 - width:1000px;
30 -}
31 -#menu ul li{
32 - list-style:none;
33 - color:white;
34 - background-color:#011638;
35 - float:left;
36 - line-height:30px;
37 - vertical-align:middle;
38 - text-align:center;
39 - display:inline;
40 -}
41 -#menu .me{
42 - text-decoration:none;
43 - color:white;
44 - display:inline-block;
45 - width:250px;
46 - font-size:20px;
47 - font-weight:bold;
48 - font-family: "Trebuchet MS", Dotum, Arial;
49 -}
50 -#menu .me:hover{
51 - color:#D499B9;
52 - background-color: #2E294E;
53 -}
54 -.container2{
55 - width:50%;
56 - height:600px;
57 - float:left;
58 -}
59 -.container3{
60 - width:50%;
61 - height:200px;
62 - float:left;
63 -}
64 -.container4{
65 - width:20%;
66 - height:400px;
67 - float:left;
68 -}
69 -.container5{
70 - width:30%;
71 - height:400px;
72 - float:left;
73 -}
...\ No newline at end of file ...\ No newline at end of file
1 -<!DOCTYPE html>
2 -<html>
3 -<head>
4 - <title> Baseball Simulator </title>
5 - <link rel="stylesheet" type="text/css"href="main.css">
6 -</head>
7 -<body>
8 - <div class="container1">
9 - <span class="logo">Welcome to Baseball Simulator</span>
10 - </div>
11 - <nav id="menu">
12 - <ul>
13 - <li>
14 - <a class="me" href="main.html">Home</a>
15 - </li>
16 - <li>
17 - <a class="me" href="introduction.html">Introduction</a>
18 - </li>
19 - <li>
20 - <a class="me" href="calendar.html">Calendar</a>
21 - </li>
22 - <li>
23 - <a class="me" href="simulation.html">Simulation</a>
24 - </li>
25 - </ul>
26 - </nav>
27 - <div class="container2">
28 - <a href="https://sports.news.naver.com/kbaseball/record/index.nhn?category=kbo&year=2021"><img src="pngs/rank.jpg" style="display:block; margin:0 auto; width:600px; height:400px;"></a>
29 - </div>
30 - <div class="container3">
31 - <a href="https://sports.news.naver.com/kbaseball/schedule/index.nhn"><img src="pngs/today.jpg" style="display:block; margin:0 auto; width:655px; height:150px;"></a>
32 - </div>
33 - <div class="container4">
34 - <img src="pngs/1.jpg" style="display:block; margin:0 auto; width:200px; height:100px;">
35 - </div>
36 - <div class="container5">
37 - <iframe width="400" height="200" src="https://www.youtube.com/embed/dL_79KkHmQE" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
38 - </div>
39 -</body>
40 -</html>
This diff is collapsed. Click to expand it.
1 -{
2 - "name": "homework",
3 - "version": "1.0.0",
4 - "description": "",
5 - "main": "server.js",
6 - "scripts": {
7 - "test": "echo \"Error: no test specified\" && exit 1"
8 - },
9 - "author": "",
10 - "license": "ISC",
11 - "dependencies": {
12 - "express": "^4.17.1"
13 - }
14 -}
This diff is collapsed. Click to expand it.
1 -const express = require('express');
2 -const app = express();
3 -app.use(express.static(__dirname));
4 -
5 -app.listen(8080, function(){
6 - console.log('listening on 8080');
7 -});
8 -
9 -app.get('/', function(req, res){
10 - res.sendFile(__dirname + '/main.html');
11 -});
12 -
13 -app.get('/main.html', function(req, res){
14 - res.sendFile(__dirname + '/main.html');
15 -});
16 -
17 -app.get('/introduction.html', function(req, res){
18 - res.sendFile(__dirname + '/introduction.html');
19 -});
20 -
21 -app.get('/calendar.html', function(req, res){
22 - res.sendFile(__dirname + '/calendar.html');
23 -});
24 -
25 -
26 -app.get('/simulation.html', function(req, res){
27 - res.sendFile(__dirname + '/simulation.html');
28 -});
29 -
1 -body{
2 - background-image:url(https://t1.daumcdn.net/cfile/blog/155A204A5026656D0E);
3 - background-repeat: no-repeat;
4 - -webkit-background-size: cover;
5 - -moz-background-size: cover;
6 - -o-background-size: cover;
7 - background-size: cover;
8 -}
9 -.container1{
10 - display:flex;
11 - justify-content: center;
12 - align-items: baseline;
13 - padding:50px 0px 0px 0px;
14 -}
15 -.logo{
16 - font-size:40px;
17 - color:white;
18 -}
19 -*{
20 - margin: 0;
21 - padding: 0;
22 - box-sizing: border-box;
23 - font-family: sans-serif;
24 -}
25 -
26 -#menu{
27 - margin:60px 250px 0px 250px;
28 - height:90px;
29 - width:1000px;
30 -}
31 -#menu ul li{
32 - list-style:none;
33 - color:white;
34 - background-color:#011638;
35 - float:left;
36 - line-height:30px;
37 - vertical-align:middle;
38 - text-align:center;
39 - display:inline;
40 -}
41 -#menu .me{
42 - text-decoration:none;
43 - color:white;
44 - display:inline-block;
45 - width:250px;
46 - font-size:20px;
47 - font-weight:bold;
48 - font-family: "Trebuchet MS", Dotum, Arial;
49 -}
50 -#menu .me:hover{
51 - color:#D499B9;
52 - background-color: #2E294E;
53 -}
54 -.container2{
55 - width:25%;
56 - height:800px;
57 - float:left;
58 -}
59 -.team{
60 - font-size:24px;
61 - color:white;
62 - font-family: sans-serif;
63 - text-align:center;
64 -}
65 -.a{
66 - height:50px;
67 -}
68 -.selection{
69 - padding:0px 10px 15px 10px;
70 - height:80px;
71 -}
72 -.t1{
73 - width:50px;
74 - height:30px;
75 - color: #6AAFE6;
76 - border: 1px solid #6AAFE6;
77 - background: white;
78 - font-size:15px;
79 - border-radius:5px;
80 -}
81 -.row{
82 - display:flex;
83 - justify-content: space-evenly;
84 - padding: 0px 5px 10px 0px;
85 -}
86 -.container3{
87 - width:50%;
88 - height:800px;
89 - float:left;
90 -}
91 -.container4{
92 - width:25%;
93 - height:800px;
94 - float:left;
95 -}
96 -.t2{
97 - width:50px;
98 - height:30px;
99 - color: #6f2108;
100 - border: 1px solid #6f2108;
101 - background: white;
102 - font-size:15px;
103 - border-radius:5px;
104 -}
105 -.l{
106 - width:33%;
107 - height:200px;
108 - float:left;
109 -}
110 -
111 -.vs{
112 - width:200px;
113 - height:200px;
114 -}
115 -#vss{
116 - font-size:40px;
117 - color:white;
118 - text-align:center;
119 -}
120 -.simul{
121 - height:150px;
122 - display:flex;
123 - float:left;
124 - margin-top:50px;
125 - margin-left:250px;
126 -}
127 -.but{
128 - height:150px;
129 - margin: 0px auto;
130 -}
131 -.simulbtr{
132 - width:250px;
133 - height:50px;
134 - color: #c9d6de;
135 - border: 1px solid #c9d6de;
136 - background: black;
137 - font-size:30px;
138 - border-radius:5px;
139 -}
140 -.tb{
141 - padding: 10px 0px 0px 90px;
142 -}
143 -table{
144 - border: 1px solid #444444;
145 - background-color:white;
146 - border-collapse:collapse;
147 -}
148 -td{
149 - border:1px solid #444444;
150 - padding: 10px;
151 -}
152 -#jstest{
153 - width:100%;
154 - height:300px;
155 - overflow-y: scroll;
156 - overflow-x: auto;
157 - background-color:white;
158 -}
...\ No newline at end of file ...\ No newline at end of file
1 -<!DOCTYPE html>
2 -<html>
3 -<head>
4 - <title> Simulation </title>
5 - <link rel="stylesheet" type="text/css"href="simulation.css">
6 - <script src = "player.js"></script>
7 - <script src = "temp_algorithm.js"></script>
8 - <script src = "simulation.js"></script>
9 -</head>
10 -<body>
11 - <div class="container1">
12 - <span class="logo">Welcome to Baseball Simulator</span>
13 - </div>
14 - <nav id="menu">
15 - <ul>
16 - <li>
17 - <a class="me" href="main.html">Home</a>
18 - </li>
19 - <li>
20 - <a class="me" href="introduction.html">Introduction</a>
21 - </li>
22 - <li>
23 - <a class="me" href="calendar.html">Calendar</a>
24 - </li>
25 - <li>
26 - <a class="me" href="simulation.html">Simulation</a>
27 - </li>
28 - </ul>
29 - </nav>
30 - <div class="container2">
31 - <div class="a">
32 - <p class="team">원정팀</p>
33 - </div>
34 - <div class="selection">
35 - <div class="row row1">
36 - <button type="submit" onclick="imgchange1(1); w(1);" class="t1">삼성</button>
37 - <button type="submit" onclick="imgchange1(2); w(2);" class="t1">NC</button>
38 - <button type="submit" onclick="imgchange1(3); w(3);" class="t1">LG</button>
39 - <button type="submit" onclick="imgchange1(4); w(4);" class="t1">KT</button>
40 - <button type="submit" onclick="imgchange1(5); w(5);" class="t1">SSG</button>
41 - </div>
42 - <div class="row row2">
43 - <button type="submit" onclick="imgchange1(6); w(6);" class="t1">두산</button>
44 - <button type="submit" onclick="imgchange1(7); w(7);" class="t1">키움</button>
45 - <button type="submit" onclick="imgchange1(8); w(8);" class="t1">KIA</button>
46 - <button type="submit" onclick="imgchange1(9); w(9);" class="t1">한화</button>
47 - <button type="submit" onclick="imgchange1(10); w(10);" class="t1">롯데</button>
48 - </div>
49 - </div>
50 - <div class="tb">
51 - <table>
52 - <tbody>
53 - <tr>
54 - <td>1번 타자</td>
55 - <td><select name="won" id="won1" onclick="hitter1list_append(1,this.value);">
56 - <option value="">선택</option>
57 - </select></td>
58 - </tr>
59 - <tr>
60 - <td>2번 타자</td>
61 - <td><select name="won" id="won2" onclick="hitter1list_append(2,this.value);">
62 - <option value="">선택</option>
63 - </select></td>
64 - </tr>
65 - <tr>
66 - <td>3번 타자</td>
67 - <td><select name="won" id="won3" onclick="hitter1list_append(3,this.value);">
68 - <option value="">선택</option>
69 - </select></td>
70 - </tr>
71 - <tr>
72 - <td>4번 타자</td>
73 - <td><select name="won" id="won4" onclick="hitter1list_append(4,this.value);">
74 - <option value="">선택</option>
75 - </select></td>
76 - </tr>
77 - <tr>
78 - <td>5번 타자</td>
79 - <td><select name="won" id="won5" onclick="hitter1list_append(5,this.value);">
80 - <option value="">선택</option>
81 - </select></td>
82 - </tr>
83 - <tr>
84 - <td>6번 타자</td>
85 - <td><select name="won" id="won6" onclick="hitter1list_append(6,this.value);">
86 - <option value="">선택</option>
87 - </select></td>
88 - </tr>
89 - <tr>
90 - <td>7번 타자</td>
91 - <td><select name="won" id="won7" onclick="hitter1list_append(7,this.value);">
92 - <option value="">선택</option>
93 - </select></td>
94 - </tr>
95 - <tr>
96 - <td>8번 타자</td>
97 - <td><select name="won" id="won8" onclick="hitter1list_append(8,this.value);">
98 - <option value="">선택</option>
99 - </select></td>
100 - </tr>
101 - <tr>
102 - <td>9번 타자</td>
103 - <td><select name="won" id="won9" onclick="hitter1list_append(9,this.value);">
104 - <option value="">선택</option>
105 - </select></td>
106 - </tr>
107 - <tr>
108 - <td>선발 투수</td>
109 - <td><select name="won" id="won" onclick="pitcher1list_append(this.value);">
110 - <option value="">선택</option>
111 - </select></td>
112 - </tr>
113 - </tbody>
114 - </table>
115 - </div>
116 - </div>
117 - <div class="container3">
118 - <div class="l">
119 - <img src="pngs/kia.png" id="wonjung" class="vs" style="margin:0px 0px 0px 50px;">
120 - </div>
121 - <div class="l">
122 - <p id="vss">VS</p>
123 - </div>
124 - <div class="l">
125 - <img src="pngs/dusan.png" id="home" class="vs">
126 - </div>
127 - <div class="simul">
128 - <div class="but">
129 - <input type="button" onclick="pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2);" class="simulbtr" value="시뮬레이션">
130 - </div>
131 - <div class="result">
132 -
133 - </div>
134 - </div>
135 - <div id="jstest"></div>
136 - </div>
137 - <div class="container4">
138 - <div class="a">
139 - <p class="team">홈팀</p>
140 - </div>
141 - <div class="selection">
142 - <div class="row row1">
143 - <button type="submit" onclick="imgchange2(1);" class="t2">삼성</button>
144 - <button type="submit" onclick="imgchange2(2);" class="t2">NC</button>
145 - <button type="submit" onclick="imgchange2(3);" class="t2">LG</button>
146 - <button type="submit" onclick="imgchange2(4);" class="t2">KT</button>
147 - <button type="submit" onclick="imgchange2(5);" class="t2">SSG</button>
148 - </div>
149 - <div class="row row2">
150 - <button type="submit" onclick="imgchange2(6);" class="t2">두산</button>
151 - <button type="submit" onclick="imgchange2(7);" class="t2">키움</button>
152 - <button type="submit" onclick="imgchange2(8);" class="t2">KIA</button>
153 - <button type="submit" onclick="imgchange2(9);" class="t2">한화</button>
154 - <button type="submit" onclick="imgchange2(10);" class="t2">롯데</button>
155 - </div>
156 - </div>
157 - <div class="tb">
158 - <table>
159 - <tbody>
160 - <tr>
161 - <td>1번 타자</td>
162 - <td><select name="hom" id="hom1" onclick="hitter2list_append(1,this.value);">
163 - <option value="">선택</option>
164 - </select></td>
165 - </tr>
166 - <tr>
167 - <td>2번 타자</td>
168 - <td><select name="hom" id="hom2" onclick="hitter2list_append(2,this.value);">
169 - <option value="">선택</option>
170 - </select></td>
171 - </tr>
172 - <tr>
173 - <td>3번 타자</td>
174 - <td><select name="hom" id="hom3" onclick="hitter2list_append(3,this.value);">
175 - <option value="">선택</option>
176 - </select></td>
177 - </tr>
178 - <tr>
179 - <td>4번 타자</td>
180 - <td><select name="hom" id="hom4" onclick="hitter2list_append(4,this.value);">
181 - <option value="">선택</option>
182 - </select></td>
183 - </tr>
184 - <tr>
185 - <td>5번 타자</td>
186 - <td><select name="hom" id="hom5" onclick="hitter2list_append(5,this.value);">
187 - <option value="">선택</option>
188 - </select></td>
189 - </tr>
190 - <tr>
191 - <td>6번 타자</td>
192 - <td><select name="hom" id="hom6" onclick="hitter2list_append(6,this.value);">
193 - <option value="">선택</option>
194 - </select></td>
195 - </tr>
196 - <tr>
197 - <td>7번 타자</td>
198 - <td><select name="hom" id="hom7" onclick="hitter2list_append(7,this.value);">
199 - <option value="">선택</option>
200 - </select></td>
201 - </tr>
202 - <tr>
203 - <td>8번 타자</td>
204 - <td><select name="hom" id="hom8" onclick="hitter2list_append(8,this.value);">
205 - <option value="">선택</option>
206 - </select></td>
207 - </tr>
208 - <tr>
209 - <td>9번 타자</td>
210 - <td><select name="hom" id="hom9" onclick="hitter2list_append(9,this.value);">
211 - <option value="">선택</option>
212 - </select></td>
213 - </tr>
214 - <tr>
215 - <td>선발 투수</td>
216 - <td><select name="hom" id="hom" onclick="pitcher2list_append(this.value);">
217 - <option value="">선택</option>
218 - </select></td>
219 - </tr>
220 - </tbody>
221 - </table>
222 - </div>
223 - </div>
224 -</body>
225 -</html>
This diff is collapsed. Click to expand it.
1 -function pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2){//algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2) => html에서 가지고와야 한다.
2 - var base1 = 0; var base2 = 0; var base3 = 0; //1이면 주자 있고 0이면 비어있는것
3 - var out = 0; var ining = 1; var home_away = 1;//아웃카운트, 이닝, home이면 1이고 away이면 2.
4 - var score1 = 0; var score2 = 0;
5 - var hitter_num1 = 1; var hitter_num2 = 1;
6 - var hit=false;
7 - document.getElementById('jstest').innerHTML="";
8 - while(true){
9 - if(ining == 9 && home_away == 2 && score1 < score2){//9회 초 후 home팀이 이기고 있을 때!
10 - break;
11 - }
12 - else if(ining==10 && home_away==1 && score1>score2 && hit==false){//9회 말 후 home팀이 이기고 있을 때!
13 - break;
14 - }
15 - else if(ining>9 && score1 < score2){//9회 말 후 home팀이 이기고 있을 때!
16 - break;
17 - }
18 - else if(ining>=11 && home_away==1 && hit==false && score1>score2){//연장 이후 원정팀이 이기고 있을 때!
19 - break;
20 - }
21 - else if(ining>=10 && home_away==2 && hit==true && score1<score2){//끝내기
22 - break;
23 - }
24 - else if(ining==13 && score1==score2){//무승부
25 - break;
26 - }
27 -
28 - if(home_away == 1){
29 - var hitter = hitter_list1[hitter_num1]; //hitter = hitter_list1[hitter_number1%9]
30 - var pitcher = pitcher2; //pitcher = pitcher1
31 - document.getElementById('jstest').innerHTML+=(ining+ "회 초"+ "<br\><br\>");
32 - }
33 - else if(home_away == 2){
34 - var hitter = hitter_list2[hitter_num2]; //hitter = hitter_list2[hitter_number2%9]
35 - var pitcher = pitcher1; //pitcher = pitcher2
36 - document.getElementById('jstest').innerHTML+=(ining+ "회 말"+ "<br\><br\>");
37 - }
38 -
39 - var num = Math.random();
40 - //hitter_number1 = hitter_number(kia); hitter_number2 = hitter_number(dusan);
41 - if(home_away == 1){
42 - document.getElementById('jstest').innerHTML+=(hitter_num1+"번 타자: "+hitter[0]+ "<br\><br\>");
43 - }
44 - else if(home_away == 2){
45 - document.getElementById('jstest').innerHTML+=(hitter_num2+"번 타자: "+hitter[0]+ "<br\><br\>");
46 - }
47 - var one = 0; var two = 0; var three = 0; var homerun = 0;
48 - one = pitcher[2] * (hitter[2] - hitter[3] - hitter[4] - hitter[5])/hitter[2];
49 - two = pitcher[2] * hitter[3]/hitter[2];
50 - three = pitcher[2] * hitter[4]/hitter[2];
51 - homerun = pitcher[2] * hitter[5]/hitter[2];
52 - hit=true;
53 - if(num <= one){ //안타
54 - var num1 = Math.random();
55 - if(num1 <= 0.5){
56 - switch(home_away){
57 - case 1:
58 - score1 = score1 + base3;
59 - break;
60 - case 2:
61 - score2 = score2 + base3;
62 - break;
63 - }
64 - base3 = base2;
65 - base2 = base1;
66 - base1 = 1;
67 - document.getElementById('jstest').innerHTML+=("1루타!");
68 -
69 - }
70 - else{
71 - switch(home_away){
72 - case 1:
73 - score1 = score1 + base3 + base2;
74 - break;
75 - case 2:
76 - score2 = score2 + base3 + base2;
77 - break;
78 - }
79 - base3 = base1;
80 - base2 = 0;
81 - base1 = 1;
82 - document.getElementById('jstest').innerHTML+=("1루타!");
83 -
84 - }
85 -
86 - }
87 - else if((one < num) && (num <= one + two)){//2루타
88 - var num2 = Math.random();
89 - if(num2 <= 0.4){
90 - switch(home_away){
91 - case 1:
92 - score1 = score1 + base3 + base2;
93 - break;
94 - case 2:
95 - score2 = score2 + base3 + base2;
96 - break;
97 - }
98 - base3 = base1;
99 - base2 = 1;
100 - base1 = 0;
101 - document.getElementById('jstest').innerHTML+=("2루타!");
102 -
103 - }
104 - else if(0.4 < num2 && num2 <=0.7){
105 - switch(home_away){
106 - case 1:
107 - score1 = score1 + base3 + base2 + base1;
108 - break;
109 - case 2:
110 - score2 = score2 + base3 + base2 + base1;
111 - break;
112 - }
113 - base3 = 0;
114 - base2 = 1;
115 - base1 = 0;
116 - document.getElementById('jstest').innerHTML+=("2루타!");
117 -
118 - }
119 - else{
120 - switch(home_away){
121 - case 1:
122 - score1 = score1 + base3 + base2;
123 - break;
124 - case 2:
125 - score2 = score2 + base3 + base2;
126 - break;
127 - }
128 - base3 = 0;
129 - base2 = 1;
130 - base1 = 0;
131 -
132 - document.getElementById('jstest').innerHTML+=("2루타!");
133 -
134 - }
135 -
136 - }
137 - else if((one + two < num) && (num <= one + two + three)){//3루타
138 - switch(home_away){
139 - case 1:
140 - score1 = score1 + base3 + base2 + base1;
141 - break;
142 - case 2:
143 - score2 = score2 + base3 + base2 + base1;
144 - break;
145 - }
146 - base3 = 1;
147 - base2 = 0;
148 - base1 = 0;
149 - document.getElementById('jstest').innerHTML+=("3루타!");
150 -
151 - }
152 - else if(one + two + three < num && num <= one + two + three + homerun){//홈런
153 - switch(home_away){
154 - case 1:
155 - score1 = score1 + base3 + base2 + base1 + 1;
156 - break;
157 - case 2:
158 - score2 = score2 + base3 + base2 + base1 + 1;
159 - break;
160 - }
161 - base3 = 0;
162 - base2 = 0;
163 - base1 = 0;
164 - document.getElementById('jstest').innerHTML+=("홈런!");
165 -
166 - }
167 -
168 -
169 - else if( pitcher[2] < num && (num <= pitcher[2] +pitcher[1]*0.01)){//볼넷
170 - if(base1==1 && base2==1 && base3==1){//만루 밀어내기 득점 -> 스코어 ++
171 - if(home_away==1){
172 - score1++;
173 - }
174 - else{
175 - score2++;
176 - }
177 - }
178 - else{//스코어 추가되지 않는 경우
179 - if((base2==1 && base1==0 )||(base3==1 && base1==0)||(base2==1&&base3==1&&base1==0)){//2루만 채워져있거나 3루만 채워져있거나 2,3루만 채워져있거나
180 - base1=1;
181 - }
182 - else if(base1==1 && base3==1 && base2==0){//1루 3루 채워져있고 2루 비워져있거나
183 - base2=base1;
184 - base1=1;
185 - }
186 - else{
187 - base3 = base2;
188 - base2 = base1;
189 - base1 = 1;
190 - }
191 - }
192 - document.getElementById('jstest').innerHTML+=("볼넷!");
193 - }
194 -
195 - else{//아웃
196 - out++;
197 - document.getElementById('jstest').innerHTML+=("아웃!");
198 -
199 - }
200 -
201 - document.getElementById('jstest').innerHTML+=("베이스 상태"+"<br\>"+ "1루 " + base1 + "<br\>"+"2루 " + base2 + "<br\>"+
202 - "3루 " + base3 + "<br\><br\>");///////////////////////////
203 - document.getElementById('jstest').innerHTML+=("score: "+score1 +"vs"+score2+ "<br\>");
204 - document.getElementById('jstest').innerHTML+=("아웃카운트: "+out+"<br\><br\>");
205 - if(out >= 3){
206 - switch(home_away){
207 - case 1:
208 - home_away = 2;
209 - hit=false;
210 - break;
211 - case 2:
212 - home_away = 1;
213 - ining++;
214 - hit=false;
215 - break;
216 - }
217 - out=0;
218 - base1=0; base2=0; base3=0;
219 - }
220 - else{
221 - if(home_away == 1){
222 - hitter_num1++;
223 - if(hitter_num1>=10){
224 - hitter_num1=1;
225 - }
226 - }
227 - else if(home_away == 2){
228 - hitter_num2++;
229 - if(hitter_num2>=10){
230 - hitter_num2=1;
231 - }
232 - }
233 - }
234 -
235 - }
236 - document.getElementById('jstest').innerHTML+=("<br\><br\>"+"최종스코어 : "+score1+"vs"+score2);
237 -}
...\ No newline at end of file ...\ No newline at end of file