정주희

Rearrange Files

const express = require('express');
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
const app = express();
const domain = "2020105636.oss-2021.tk"
const sslport = 23023;
app.use(express.static(__dirname));
app.get('/', function(req, res){
res.sendFile(__dirname + '/main.html');
});
app.get('/main.html', function(req, res){
res.sendFile(__dirname + '/main.html');
});
app.get('/introduction.html', function(req, res){
res.sendFile(__dirname + '/introduction.html');
});
app.get('/calendar.html', function(req, res){
res.sendFile(__dirname + '/calendar.html');
});
app.get('/simulation.html', function(req, res){
res.sendFile(__dirname + '/simulation.html');
});
try {
const option = {
ca: fs.readFileSync('/etc/letsencrypt/live/' + domain +'/fullchain.pem'),
key: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/privkey.pem'), 'utf8').toString(),
cert: fs.readFileSync(path.resolve(process.cwd(), '/etc/letsencrypt/live/' + domain +'/cert.pem'), 'utf8').toString(),
};
HTTPS.createServer(option, app).listen(sslport, () => {
console.log(`[HTTPS] Server is started on port ${sslport}`);
});
} catch (error) {
console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
console.log(error);
}
\ No newline at end of file
body{
background-image:url(https://t1.daumcdn.net/cfile/blog/155A204A5026656D0E);
background-repeat: no-repeat;
background-size: cover;
}
.container1{
display:flex;
justify-content: center;
align-items: baseline;
padding:50px 0px 0px 0px;
}
.logo{
font-size:40px;
color:white;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
#menu{
margin:60px 250px 0px 250px;
height:90px;
width:1000px;
}
#menu ul li{
list-style:none;
color:white;
background-color:#011638;
float:left;
line-height:30px;
vertical-align:middle;
text-align:center;
display:inline;
}
#menu .me{
text-decoration:none;
color:white;
display:inline-block;
width:250px;
font-size:20px;
font-weight:bold;
font-family: "Trebuchet MS", Dotum, Arial;
}
#menu .me:hover{
color:#D499B9;
background-color: #2E294E;
}
.row{
display:flex;
justify-content: space-evenly;
padding: 0px 0px 50px 0px;
}
<!DOCTYPE html>
<html>
<head>
<title> Calendar </title>
<link rel="stylesheet" type="text/css"href="calendar.css">
</head>
<body>
<div class="container1">
<span class="logo">Welcome to Baseball Simulator</span>
</div>
<nav id="menu">
<ul>
<li>
<a class="me" href="main.html">Home</a>
</li>
<li>
<a class="me" href="introduction.html">Introduction</a>
</li>
<li>
<a class="me" href="calendar.html">Calendar</a>
</li>
<li>
<a class="me" href="simulation.html">Simulation</a>
</li>
</ul>
</nav>
<div class="container2">
<div class="row row1">
<span class="item1">
<a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=%EC%82%BC%EC%84%B1">
<img src="pngs/samsung.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
<span class="item2">
<a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=NC">
<img src="pngs/nc.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
<span class="item3">
<a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=LG">
<img src="pngs/LG.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
<span class="item4">
<a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=KT">
<img src="pngs/kt.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
<span class="item5">
<a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=SSG">
<img src="pngs/ssg.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
</div>
<div class="row row2">
<span class="item6">
<a href="http://www.statiz.co.kr/team.php?cteam=%EB%91%90%EC%82%B0%2BOB&year=2021&opt=0&sopt=1">
<img src="pngs/dusan.png" style="display:block; margin:0 auto; width:150px; height:150px;"alt="">
</a>
</span>
<span class="item7">
<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">
<img src="pngs/kiwoom.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
<span class="item8">
<a href="http://www.statiz.co.kr/team.php?opt=0&sopt=1&year=2021&team=KIA">
<img src="pngs/kia.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
<span class="item9">
<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">
<img src="pngs/hanhwa.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
<span class="item10">
<a href="http://www.statiz.co.kr/team.php?cteam=%EB%A1%AF%EB%8D%B0&year=2021&opt=0&sopt=1">
<img src="pngs/Lotte.png" style="display:block; margin:0 auto; width:150px; height:150px;" alt="">
</a>
</span>
</div>
</div>
</body>
</html>
body{
background-image:url(https://t1.daumcdn.net/cfile/blog/155A204A5026656D0E);
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.container1{
display:flex;
justify-content: center;
align-items: baseline;
padding:50px 0px 0px 0px;
}
.logo{
font-size:40px;
color:white;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
#menu{
margin:60px 250px 0px 250px;
height:90px;
width:1000px;
}
#menu ul li{
list-style:none;
color:white;
background-color:#011638;
float:left;
line-height:30px;
vertical-align:middle;
text-align:center;
display:inline;
}
#menu .me{
text-decoration:none;
color:white;
display:inline-block;
width:250px;
font-size:20px;
font-weight:bold;
font-family: "Trebuchet MS", Dotum, Arial;
}
#menu .me:hover{
color:#D499B9;
background-color: #2E294E;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title> Introduction </title>
<link rel="stylesheet" type="text/css"href="introduction.css">
</head>
<body>
<div class="container1">
<span class="logo">Welcome to Baseball Simulator</span>
</div>
<nav id="menu">
<ul>
<li>
<a class="me" href="main.html">Home</a>
</li>
<li>
<a class="me" href="introduction.html">Introduction</a>
</li>
<li>
<a class="me" href="calendar.html">Calendar</a>
</li>
<li>
<a class="me" href="simulation.html">Simulation</a>
</li>
</ul>
</nav>
</body>
</html>
body{
background-image:url(https://t1.daumcdn.net/cfile/blog/155A204A5026656D0E);
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.container1{
display:flex;
justify-content: center;
align-items: baseline;
padding:50px 0px 0px 0px;
}
.logo{
font-size:40px;
color:white;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
#menu{
margin:60px 250px 0px 250px;
height:90px;
width:1000px;
}
#menu ul li{
list-style:none;
color:white;
background-color:#011638;
float:left;
line-height:30px;
vertical-align:middle;
text-align:center;
display:inline;
}
#menu .me{
text-decoration:none;
color:white;
display:inline-block;
width:250px;
font-size:20px;
font-weight:bold;
font-family: "Trebuchet MS", Dotum, Arial;
}
#menu .me:hover{
color:#D499B9;
background-color: #2E294E;
}
.container2{
width:50%;
height:600px;
float:left;
}
.container3{
width:50%;
height:200px;
float:left;
}
.container4{
width:20%;
height:400px;
float:left;
}
.container5{
width:30%;
height:400px;
float:left;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title> Baseball Simulator </title>
<link rel="stylesheet" type="text/css"href="main.css">
</head>
<body>
<div class="container1">
<span class="logo">Welcome to Baseball Simulator</span>
</div>
<nav id="menu">
<ul>
<li>
<a class="me" href="main.html">Home</a>
</li>
<li>
<a class="me" href="introduction.html">Introduction</a>
</li>
<li>
<a class="me" href="calendar.html">Calendar</a>
</li>
<li>
<a class="me" href="simulation.html">Simulation</a>
</li>
</ul>
</nav>
<div class="container2">
<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>
</div>
<div class="container3">
<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>
</div>
<div class="container4">
<img src="pngs/1.jpg" style="display:block; margin:0 auto; width:200px; height:100px;">
</div>
<div class="container5">
<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>
</div>
</body>
</html>
This diff is collapsed. Click to expand it.
{
"name": "homework",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
}
}
This diff is collapsed. Click to expand it.
const express = require('express');
const app = express();
app.use(express.static(__dirname));
app.listen(8080, function(){
console.log('listening on 8080');
});
app.get('/', function(req, res){
res.sendFile(__dirname + '/main.html');
});
app.get('/main.html', function(req, res){
res.sendFile(__dirname + '/main.html');
});
app.get('/introduction.html', function(req, res){
res.sendFile(__dirname + '/introduction.html');
});
app.get('/calendar.html', function(req, res){
res.sendFile(__dirname + '/calendar.html');
});
app.get('/simulation.html', function(req, res){
res.sendFile(__dirname + '/simulation.html');
});
body{
background-image:url(https://t1.daumcdn.net/cfile/blog/155A204A5026656D0E);
background-repeat: no-repeat;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
.container1{
display:flex;
justify-content: center;
align-items: baseline;
padding:50px 0px 0px 0px;
}
.logo{
font-size:40px;
color:white;
}
*{
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: sans-serif;
}
#menu{
margin:60px 250px 0px 250px;
height:90px;
width:1000px;
}
#menu ul li{
list-style:none;
color:white;
background-color:#011638;
float:left;
line-height:30px;
vertical-align:middle;
text-align:center;
display:inline;
}
#menu .me{
text-decoration:none;
color:white;
display:inline-block;
width:250px;
font-size:20px;
font-weight:bold;
font-family: "Trebuchet MS", Dotum, Arial;
}
#menu .me:hover{
color:#D499B9;
background-color: #2E294E;
}
.container2{
width:25%;
height:800px;
float:left;
}
.team{
font-size:24px;
color:white;
font-family: sans-serif;
text-align:center;
}
.a{
height:50px;
}
.selection{
padding:0px 10px 15px 10px;
height:80px;
}
.t1{
width:50px;
height:30px;
color: #6AAFE6;
border: 1px solid #6AAFE6;
background: white;
font-size:15px;
border-radius:5px;
}
.row{
display:flex;
justify-content: space-evenly;
padding: 0px 5px 10px 0px;
}
.container3{
width:50%;
height:800px;
float:left;
}
.container4{
width:25%;
height:800px;
float:left;
}
.t2{
width:50px;
height:30px;
color: #6f2108;
border: 1px solid #6f2108;
background: white;
font-size:15px;
border-radius:5px;
}
.l{
width:33%;
height:200px;
float:left;
}
.vs{
width:200px;
height:200px;
}
#vss{
font-size:40px;
color:white;
text-align:center;
}
.simul{
height:150px;
display:flex;
float:left;
margin-top:50px;
margin-left:250px;
}
.but{
height:150px;
margin: 0px auto;
}
.simulbtr{
width:250px;
height:50px;
color: #c9d6de;
border: 1px solid #c9d6de;
background: black;
font-size:30px;
border-radius:5px;
}
.tb{
padding: 10px 0px 0px 90px;
}
table{
border: 1px solid #444444;
background-color:white;
border-collapse:collapse;
}
td{
border:1px solid #444444;
padding: 10px;
}
#jstest{
width:100%;
height:300px;
overflow-y: scroll;
overflow-x: auto;
background-color:white;
}
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<title> Simulation </title>
<link rel="stylesheet" type="text/css"href="simulation.css">
<script src = "player.js"></script>
<script src = "temp_algorithm.js"></script>
<script src = "simulation.js"></script>
</head>
<body>
<div class="container1">
<span class="logo">Welcome to Baseball Simulator</span>
</div>
<nav id="menu">
<ul>
<li>
<a class="me" href="main.html">Home</a>
</li>
<li>
<a class="me" href="introduction.html">Introduction</a>
</li>
<li>
<a class="me" href="calendar.html">Calendar</a>
</li>
<li>
<a class="me" href="simulation.html">Simulation</a>
</li>
</ul>
</nav>
<div class="container2">
<div class="a">
<p class="team">원정팀</p>
</div>
<div class="selection">
<div class="row row1">
<button type="submit" onclick="imgchange1(1); w(1);" class="t1">삼성</button>
<button type="submit" onclick="imgchange1(2); w(2);" class="t1">NC</button>
<button type="submit" onclick="imgchange1(3); w(3);" class="t1">LG</button>
<button type="submit" onclick="imgchange1(4); w(4);" class="t1">KT</button>
<button type="submit" onclick="imgchange1(5); w(5);" class="t1">SSG</button>
</div>
<div class="row row2">
<button type="submit" onclick="imgchange1(6); w(6);" class="t1">두산</button>
<button type="submit" onclick="imgchange1(7); w(7);" class="t1">키움</button>
<button type="submit" onclick="imgchange1(8); w(8);" class="t1">KIA</button>
<button type="submit" onclick="imgchange1(9); w(9);" class="t1">한화</button>
<button type="submit" onclick="imgchange1(10); w(10);" class="t1">롯데</button>
</div>
</div>
<div class="tb">
<table>
<tbody>
<tr>
<td>1번 타자</td>
<td><select name="won" id="won1" onclick="hitter1list_append(1,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>2번 타자</td>
<td><select name="won" id="won2" onclick="hitter1list_append(2,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>3번 타자</td>
<td><select name="won" id="won3" onclick="hitter1list_append(3,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>4번 타자</td>
<td><select name="won" id="won4" onclick="hitter1list_append(4,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>5번 타자</td>
<td><select name="won" id="won5" onclick="hitter1list_append(5,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>6번 타자</td>
<td><select name="won" id="won6" onclick="hitter1list_append(6,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>7번 타자</td>
<td><select name="won" id="won7" onclick="hitter1list_append(7,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>8번 타자</td>
<td><select name="won" id="won8" onclick="hitter1list_append(8,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>9번 타자</td>
<td><select name="won" id="won9" onclick="hitter1list_append(9,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>선발 투수</td>
<td><select name="won" id="won" onclick="pitcher1list_append(this.value);">
<option value="">선택</option>
</select></td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="container3">
<div class="l">
<img src="pngs/kia.png" id="wonjung" class="vs" style="margin:0px 0px 0px 50px;">
</div>
<div class="l">
<p id="vss">VS</p>
</div>
<div class="l">
<img src="pngs/dusan.png" id="home" class="vs">
</div>
<div class="simul">
<div class="but">
<input type="button" onclick="pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2);" class="simulbtr" value="시뮬레이션">
</div>
<div class="result">
</div>
</div>
<div id="jstest"></div>
</div>
<div class="container4">
<div class="a">
<p class="team">홈팀</p>
</div>
<div class="selection">
<div class="row row1">
<button type="submit" onclick="imgchange2(1);" class="t2">삼성</button>
<button type="submit" onclick="imgchange2(2);" class="t2">NC</button>
<button type="submit" onclick="imgchange2(3);" class="t2">LG</button>
<button type="submit" onclick="imgchange2(4);" class="t2">KT</button>
<button type="submit" onclick="imgchange2(5);" class="t2">SSG</button>
</div>
<div class="row row2">
<button type="submit" onclick="imgchange2(6);" class="t2">두산</button>
<button type="submit" onclick="imgchange2(7);" class="t2">키움</button>
<button type="submit" onclick="imgchange2(8);" class="t2">KIA</button>
<button type="submit" onclick="imgchange2(9);" class="t2">한화</button>
<button type="submit" onclick="imgchange2(10);" class="t2">롯데</button>
</div>
</div>
<div class="tb">
<table>
<tbody>
<tr>
<td>1번 타자</td>
<td><select name="hom" id="hom1" onclick="hitter2list_append(1,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>2번 타자</td>
<td><select name="hom" id="hom2" onclick="hitter2list_append(2,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>3번 타자</td>
<td><select name="hom" id="hom3" onclick="hitter2list_append(3,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>4번 타자</td>
<td><select name="hom" id="hom4" onclick="hitter2list_append(4,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>5번 타자</td>
<td><select name="hom" id="hom5" onclick="hitter2list_append(5,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>6번 타자</td>
<td><select name="hom" id="hom6" onclick="hitter2list_append(6,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>7번 타자</td>
<td><select name="hom" id="hom7" onclick="hitter2list_append(7,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>8번 타자</td>
<td><select name="hom" id="hom8" onclick="hitter2list_append(8,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>9번 타자</td>
<td><select name="hom" id="hom9" onclick="hitter2list_append(9,this.value);">
<option value="">선택</option>
</select></td>
</tr>
<tr>
<td>선발 투수</td>
<td><select name="hom" id="hom" onclick="pitcher2list_append(this.value);">
<option value="">선택</option>
</select></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>
This diff is collapsed. Click to expand it.
function pre_algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2){//algorithm(hitter_list1, hitter_list2, pitcher1, pitcher2) => html에서 가지고와야 한다.
var base1 = 0; var base2 = 0; var base3 = 0; //1이면 주자 있고 0이면 비어있는것
var out = 0; var ining = 1; var home_away = 1;//아웃카운트, 이닝, home이면 1이고 away이면 2.
var score1 = 0; var score2 = 0;
var hitter_num1 = 1; var hitter_num2 = 1;
var hit=false;
document.getElementById('jstest').innerHTML="";
while(true){
if(ining == 9 && home_away == 2 && score1 < score2){//9회 초 후 home팀이 이기고 있을 때!
break;
}
else if(ining==10 && home_away==1 && score1>score2 && hit==false){//9회 말 후 home팀이 이기고 있을 때!
break;
}
else if(ining>9 && score1 < score2){//9회 말 후 home팀이 이기고 있을 때!
break;
}
else if(ining>=11 && home_away==1 && hit==false && score1>score2){//연장 이후 원정팀이 이기고 있을 때!
break;
}
else if(ining>=10 && home_away==2 && hit==true && score1<score2){//끝내기
break;
}
else if(ining==13 && score1==score2){//무승부
break;
}
if(home_away == 1){
var hitter = hitter_list1[hitter_num1]; //hitter = hitter_list1[hitter_number1%9]
var pitcher = pitcher2; //pitcher = pitcher1
document.getElementById('jstest').innerHTML+=(ining+ "회 초"+ "<br\><br\>");
}
else if(home_away == 2){
var hitter = hitter_list2[hitter_num2]; //hitter = hitter_list2[hitter_number2%9]
var pitcher = pitcher1; //pitcher = pitcher2
document.getElementById('jstest').innerHTML+=(ining+ "회 말"+ "<br\><br\>");
}
var num = Math.random();
//hitter_number1 = hitter_number(kia); hitter_number2 = hitter_number(dusan);
if(home_away == 1){
document.getElementById('jstest').innerHTML+=(hitter_num1+"번 타자: "+hitter[0]+ "<br\><br\>");
}
else if(home_away == 2){
document.getElementById('jstest').innerHTML+=(hitter_num2+"번 타자: "+hitter[0]+ "<br\><br\>");
}
var one = 0; var two = 0; var three = 0; var homerun = 0;
one = pitcher[2] * (hitter[2] - hitter[3] - hitter[4] - hitter[5])/hitter[2];
two = pitcher[2] * hitter[3]/hitter[2];
three = pitcher[2] * hitter[4]/hitter[2];
homerun = pitcher[2] * hitter[5]/hitter[2];
hit=true;
if(num <= one){ //안타
var num1 = Math.random();
if(num1 <= 0.5){
switch(home_away){
case 1:
score1 = score1 + base3;
break;
case 2:
score2 = score2 + base3;
break;
}
base3 = base2;
base2 = base1;
base1 = 1;
document.getElementById('jstest').innerHTML+=("1루타!");
}
else{
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = base1;
base2 = 0;
base1 = 1;
document.getElementById('jstest').innerHTML+=("1루타!");
}
}
else if((one < num) && (num <= one + two)){//2루타
var num2 = Math.random();
if(num2 <= 0.4){
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = base1;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
else if(0.4 < num2 && num2 <=0.7){
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1;
break;
case 2:
score2 = score2 + base3 + base2 + base1;
break;
}
base3 = 0;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
else{
switch(home_away){
case 1:
score1 = score1 + base3 + base2;
break;
case 2:
score2 = score2 + base3 + base2;
break;
}
base3 = 0;
base2 = 1;
base1 = 0;
document.getElementById('jstest').innerHTML+=("2루타!");
}
}
else if((one + two < num) && (num <= one + two + three)){//3루타
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1;
break;
case 2:
score2 = score2 + base3 + base2 + base1;
break;
}
base3 = 1;
base2 = 0;
base1 = 0;
document.getElementById('jstest').innerHTML+=("3루타!");
}
else if(one + two + three < num && num <= one + two + three + homerun){//홈런
switch(home_away){
case 1:
score1 = score1 + base3 + base2 + base1 + 1;
break;
case 2:
score2 = score2 + base3 + base2 + base1 + 1;
break;
}
base3 = 0;
base2 = 0;
base1 = 0;
document.getElementById('jstest').innerHTML+=("홈런!");
}
else if( pitcher[2] < num && (num <= pitcher[2] +pitcher[1]*0.01)){//볼넷
if(base1==1 && base2==1 && base3==1){//만루 밀어내기 득점 -> 스코어 ++
if(home_away==1){
score1++;
}
else{
score2++;
}
}
else{//스코어 추가되지 않는 경우
if((base2==1 && base1==0 )||(base3==1 && base1==0)||(base2==1&&base3==1&&base1==0)){//2루만 채워져있거나 3루만 채워져있거나 2,3루만 채워져있거나
base1=1;
}
else if(base1==1 && base3==1 && base2==0){//1루 3루 채워져있고 2루 비워져있거나
base2=base1;
base1=1;
}
else{
base3 = base2;
base2 = base1;
base1 = 1;
}
}
document.getElementById('jstest').innerHTML+=("볼넷!");
}
else{//아웃
out++;
document.getElementById('jstest').innerHTML+=("아웃!");
}
document.getElementById('jstest').innerHTML+=("베이스 상태"+"<br\>"+ "1루 " + base1 + "<br\>"+"2루 " + base2 + "<br\>"+
"3루 " + base3 + "<br\><br\>");///////////////////////////
document.getElementById('jstest').innerHTML+=("score: "+score1 +"vs"+score2+ "<br\>");
document.getElementById('jstest').innerHTML+=("아웃카운트: "+out+"<br\><br\>");
if(out >= 3){
switch(home_away){
case 1:
home_away = 2;
hit=false;
break;
case 2:
home_away = 1;
ining++;
hit=false;
break;
}
out=0;
base1=0; base2=0; base3=0;
}
else{
if(home_away == 1){
hitter_num1++;
if(hitter_num1>=10){
hitter_num1=1;
}
}
else if(home_away == 2){
hitter_num2++;
if(hitter_num2>=10){
hitter_num2=1;
}
}
}
}
document.getElementById('jstest').innerHTML+=("<br\><br\>"+"최종스코어 : "+score1+"vs"+score2);
}
\ No newline at end of file