|
|
@@ -0,0 +1,138 @@ |
|
|
<!DOCTYPE html> |
|
|
<html> |
|
|
<head> |
|
|
<link href="/assets/css/bootstrap.min.css" rel="stylesheet"> |
|
|
<link href="/assets/css/blackjack.css" rel="stylesheet"> |
|
|
<link href="/assets/css/custom.css" rel="stylesheet"> |
|
|
<script type="text/javascript" src="/assets/webjars/jquery/2.1.3/jquery.js"></script> |
|
|
</head> |
|
|
<body> |
|
|
<div class="well"><h3>Welcome to BlackJack. Good Luck!</h3></div> |
|
|
<div id="dealer"><p><h4>Dealer</h4></p> |
|
|
<div id="dealer_cards"></div> |
|
|
</div> |
|
|
<br> |
|
|
<br> |
|
|
<div id="player"><p><h4>Player</h4></p> |
|
|
<div id="player_cards"></div> |
|
|
</div> |
|
|
<br> |
|
|
<br> |
|
|
<button type="button" class="btn btn-success" id="hitButton">Hit</button> |
|
|
<button type="button" class="btn btn-success" id="stayButton">Stay</button> |
|
|
<button type="button" class="btn btn-success" id="ddButton">Double Down</button> |
|
|
<button type="button" class="btn btn-success" id="splitButton">Split</button> |
|
|
|
|
|
<button type="button" class="btn btn-danger" id="restartButton">Restart</button> |
|
|
|
|
|
|
|
|
<br> |
|
|
<div class="jumbotron"> |
|
|
<p><a class="btn btn-primary btn-lg" |
|
|
href="https://www.youtube.com/watch?v=tQJGbbk3WUs" role="button"> |
|
|
Learn how to play |
|
|
</a></p> |
|
|
</div> |
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
var game; |
|
|
|
|
|
function display(game) { |
|
|
console.log(game); |
|
|
|
|
|
if(game.error == true){ |
|
|
alert("Invalid move."); |
|
|
} |
|
|
|
|
|
$( '.columnOfCards .cardLocation' ).html(""); |
|
|
|
|
|
$.each(game.cols[0], function( key, val ) { |
|
|
$( '#c0 .l'+key ).html(val.value + val.suit); |
|
|
}); |
|
|
|
|
|
$.each(game.cols[1], function( key, val ) { |
|
|
$( '#c1 .l'+key ).html(val.value + val.suit); |
|
|
}); |
|
|
|
|
|
$.each(game.cols[2], function( key, val ) { |
|
|
$( '#c2 .l'+key ).html(val.value + val.suit); |
|
|
}); |
|
|
|
|
|
$.each(game.cols[3], function( key, val ) { |
|
|
$( '#c3 .l'+key ).html(val.value + val.suit); |
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
$.getJSON("http://localhost:8080/game", function( data ) { |
|
|
display(data); |
|
|
game = data; |
|
|
}); |
|
|
|
|
|
|
|
|
$("#hitButton").click(function(){ |
|
|
$.ajax({ |
|
|
type: "POST", |
|
|
url: "/hit", |
|
|
data: JSON.stringify(game), |
|
|
success: function(data, status){console.log("Data: " + data + "\nStatus: " + status); |
|
|
game = data; |
|
|
display(data);}, |
|
|
contentType:"application/json; charset=utf-8", |
|
|
dataType:"json", |
|
|
}); |
|
|
}); |
|
|
|
|
|
$("#stayButton").click(function(){ |
|
|
$.ajax({ |
|
|
type: "POST", |
|
|
url: "/stay", |
|
|
data: JSON.stringify(game), |
|
|
success: function(data, status){console.log("Data: " + data + "\nStatus: " + status); |
|
|
game = data; |
|
|
display(data);}, |
|
|
contentType:"application/json; charset=utf-8", |
|
|
dataType:"json", |
|
|
}); |
|
|
}); |
|
|
|
|
|
$("#ddButton").click(function(){ |
|
|
$.ajax({ |
|
|
type: "POST", |
|
|
url: "/dd", |
|
|
data: JSON.stringify(game), |
|
|
success: function(data, status){console.log("Data: " + data + "\nStatus: " + status); |
|
|
game = data; |
|
|
display(data);}, |
|
|
contentType:"application/json; charset=utf-8", |
|
|
dataType:"json", |
|
|
}); |
|
|
}); |
|
|
|
|
|
$("#splitButton").click(function(){ |
|
|
$.ajax({ |
|
|
type: "POST", |
|
|
url: "/split", |
|
|
data: JSON.stringify(game), |
|
|
success: function(data, status){console.log("Data: " + data + "\nStatus: " + status); |
|
|
game = data; |
|
|
display(data);}, |
|
|
contentType:"application/json; charset=utf-8", |
|
|
dataType:"json", |
|
|
}); |
|
|
}); |
|
|
|
|
|
$("#restartButton").click(function(){ |
|
|
location.reload(); |
|
|
}); |
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
</body> |
|
|
</html> |