Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -1,3 +1,12 @@
/* Add additional stylesheets below
-------------------------------------------------- */
.well{

text-align:center;
}


.columnOfCards{
text-align:center;

}
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

@@ -0,0 +1,13 @@
// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
require('../../js/transition.js')
require('../../js/alert.js')
require('../../js/button.js')
require('../../js/carousel.js')
require('../../js/collapse.js')
require('../../js/dropdown.js')
require('../../js/modal.js')
require('../../js/tooltip.js')
require('../../js/popover.js')
require('../../js/scrollspy.js')
require('../../js/tab.js')
require('../../js/affix.js')
@@ -25,18 +25,18 @@
public class Routes implements ApplicationRoutes {

@Override
public void init(Router router) {
router.GET().route("/").with(ApplicationController.class, "index");
public void init(Router router) {

router.GET().route("/").with(ApplicationController.class, "blackjack");
router.GET().route("/hello_world.json").with(ApplicationController.class, "helloWorldJson");


///////////////////////////////////////////////////////////////////////
// Assets (pictures / javascript)
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
router.GET().route("/assets/webjars/{fileName: .*}").with(AssetsController.class, "serveWebJars");
router.GET().route("/assets/{fileName: .*}").with(AssetsController.class, "serveStatic");

///////////////////////////////////////////////////////////////////////
// Index / Catchall shows index page
///////////////////////////////////////////////////////////////////////
@@ -14,13 +14,13 @@ application.name=ninja demo application

application.cookie.prefix=NINJA

#ISO Language Code, optionally followed by a valid ISO Country Code.
#ISO Language Code, optionally followed by a valid ISO Country Code.
application.languages=en

application.session.expire_time_in_seconds=3600
application.session.send_only_if_changed=true
application.session.transferred_over_https_only=false

# enable ssl with self-signed cert in dev & test modes
ninja.ssl.port=8443
#ninja.ssl.port=8443
application.secret = vCe1YM1M2QYdtgE1TVccA88dzMhMubswHuP3MtemQLDTJjzWGpYQMtsX67kmZD7e
@@ -30,19 +30,22 @@ public Result index() {
return Results.html();

}

public Result blackjack() {
return Results.html().template("views/blackjack/blackjack.flt.html");
}

public Result helloWorldJson() {

SimplePojo simplePojo = new SimplePojo();
simplePojo.content = "Hello World! Hello Json!";

return Results.json().render(simplePojo);

}

public static class SimplePojo {

public String content;

}
}
@@ -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>
@@ -27,36 +27,35 @@
import static org.junit.Assert.assertThat;

public class ApiControllerDocTesterTest extends NinjaDocTester {

String URL_INDEX = "/";
String URL_HELLO_WORLD_JSON = "/hello_world.json";

@Test
public void testGetIndex() {

Response response = makeRequest(
Request.GET().url(
testServerUrl().path(URL_INDEX)));

assertThat(response.payload, containsString("Hello World!"));
assertThat(response.payload, containsString("BAM!"));
assertThat(response.payload, containsString("BlackJack"));


}

@Test
public void testGetHelloWorldJson() {

Response response = makeRequest(
Request.GET().url(
testServerUrl().path(URL_HELLO_WORLD_JSON)));

ApplicationController.SimplePojo simplePojo
ApplicationController.SimplePojo simplePojo
= response.payloadJsonAs(ApplicationController.SimplePojo.class);

assertThat(simplePojo.content, CoreMatchers.equalTo("Hello World! Hello Json!"));


}

}