MP11
1
.gitignore
vendored
@ -25,3 +25,4 @@
|
|||||||
/Assignments/JavaScript/lab14js_CalebFontenot/nbproject/private/
|
/Assignments/JavaScript/lab14js_CalebFontenot/nbproject/private/
|
||||||
>>>>>>> Stashed changes
|
>>>>>>> Stashed changes
|
||||||
/Assignments/JavaScript/lab15js_CalebFontenot/nbproject/private/
|
/Assignments/JavaScript/lab15js_CalebFontenot/nbproject/private/
|
||||||
|
/Assignments/JavaScript/MP11_CalebFontenot/nbproject/private/
|
||||||
|
3
Assignments/JavaScript/MP11_CalebFontenot/.bowerrc
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"directory": "public_html/bower_components"
|
||||||
|
}
|
9
Assignments/JavaScript/MP11_CalebFontenot/Gruntfile.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/Gruntfile.js to edit this template
|
||||||
|
*/
|
||||||
|
module.exports = function (grunt) {
|
||||||
|
// Project configuration.
|
||||||
|
grunt.initConfig({
|
||||||
|
});
|
||||||
|
};
|
13
Assignments/JavaScript/MP11_CalebFontenot/bower.json
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "MP11_CalebFontenot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "path/to/main.css",
|
||||||
|
"ignore": [
|
||||||
|
".jshintrc",
|
||||||
|
"**/*.txt"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
}
|
||||||
|
}
|
10
Assignments/JavaScript/MP11_CalebFontenot/gulpfile.js
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
/*
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
* Click nbfs://nbhost/SystemFileSystem/Templates/ClientSide/gulpfile.js to edit this template
|
||||||
|
*/
|
||||||
|
|
||||||
|
var gulp = require('gulp');
|
||||||
|
|
||||||
|
gulp.task('default', function () {
|
||||||
|
// place code for your default task here
|
||||||
|
});
|
@ -0,0 +1,5 @@
|
|||||||
|
file.reference.MP11_CalebFontenot-public_html=public_html
|
||||||
|
file.reference.MP11_CalebFontenot-test=test
|
||||||
|
files.encoding=UTF-8
|
||||||
|
site.root.folder=${file.reference.MP11_CalebFontenot-public_html}
|
||||||
|
test.folder=${file.reference.MP11_CalebFontenot-test}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://www.netbeans.org/ns/project/1">
|
||||||
|
<type>org.netbeans.modules.web.clientproject</type>
|
||||||
|
<configuration>
|
||||||
|
<data xmlns="http://www.netbeans.org/ns/clientside-project/1">
|
||||||
|
<name>MP11_CalebFontenot</name>
|
||||||
|
</data>
|
||||||
|
</configuration>
|
||||||
|
</project>
|
8
Assignments/JavaScript/MP11_CalebFontenot/package.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"name": "MP11_CalebFontenot",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"keywords": ["util", "functional", "server", "client", "browser"],
|
||||||
|
"author": "caleb",
|
||||||
|
"contributors": [],
|
||||||
|
"dependencies": {}
|
||||||
|
}
|
After Width: | Height: | Size: 53 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 45 KiB |
After Width: | Height: | Size: 49 KiB |
After Width: | Height: | Size: 23 KiB |
After Width: | Height: | Size: 19 KiB |
After Width: | Height: | Size: 20 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 28 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 24 KiB |
After Width: | Height: | Size: 26 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 29 KiB |
After Width: | Height: | Size: 32 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 33 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 47 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 50 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 42 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 380 KiB |
After Width: | Height: | Size: 39 KiB |
After Width: | Height: | Size: 203 KiB |
After Width: | Height: | Size: 34 KiB |
After Width: | Height: | Size: 210 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 255 KiB |
After Width: | Height: | Size: 40 KiB |
After Width: | Height: | Size: 242 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 257 KiB |
After Width: | Height: | Size: 36 KiB |
After Width: | Height: | Size: 260 KiB |
After Width: | Height: | Size: 43 KiB |
After Width: | Height: | Size: 273 KiB |
After Width: | Height: | Size: 41 KiB |
After Width: | Height: | Size: 197 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 279 KiB |
After Width: | Height: | Size: 38 KiB |
After Width: | Height: | Size: 191 KiB |
After Width: | Height: | Size: 46 KiB |
After Width: | Height: | Size: 238 KiB |
After Width: | Height: | Size: 44 KiB |
After Width: | Height: | Size: 201 KiB |
After Width: | Height: | Size: 40 KiB |
135
Assignments/JavaScript/MP11_CalebFontenot/public_html/greg.css
Executable file
@ -0,0 +1,135 @@
|
|||||||
|
body {
|
||||||
|
background-color: #000040;
|
||||||
|
background-image: url(background.gif);
|
||||||
|
color: #88ffff;
|
||||||
|
font-family: Verdana, Arial, sans-serif;
|
||||||
|
}
|
||||||
|
#container {
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
width:80%;
|
||||||
|
min-width:700px;
|
||||||
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 10%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#logo {
|
||||||
|
text-align:center;
|
||||||
|
margin: 0;
|
||||||
|
font-family: Geneva, Arial, Helvetica, sans-serif;
|
||||||
|
padding-top: 30px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
|
||||||
|
}
|
||||||
|
#nav {
|
||||||
|
float: left;
|
||||||
|
width: 200px;
|
||||||
|
padding-top: 10px;
|
||||||
|
text-align:left;
|
||||||
|
color: #88FFFF;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
#nav a {
|
||||||
|
text-decoration:none;
|
||||||
|
margin: 15px;
|
||||||
|
display: block;
|
||||||
|
color: #88FFFF;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
#content {
|
||||||
|
margin-left: 150px;
|
||||||
|
padding: 30px;
|
||||||
|
overflow:auto;
|
||||||
|
border: medium groove #88FFFF;
|
||||||
|
line-height: 135%;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.floatright {
|
||||||
|
padding-left:20px;
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
|
.floatleft {
|
||||||
|
float:left;
|
||||||
|
padding: 30px 0px 20px;
|
||||||
|
}
|
||||||
|
#footer {
|
||||||
|
font-size: .60em;
|
||||||
|
font-style: italic;
|
||||||
|
text-align: center;
|
||||||
|
border-top: 2px double #000040;
|
||||||
|
padding-top: 20px;
|
||||||
|
padding-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
h2 {
|
||||||
|
text-transform: uppercase;
|
||||||
|
color: #88ffff;
|
||||||
|
font-size: 1.2em;
|
||||||
|
border-bottom: 1px none;
|
||||||
|
margin-right: 20px;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
color: #88ffff;
|
||||||
|
font-size: 1.2em;
|
||||||
|
border-bottom: 1px solid #000000;
|
||||||
|
margin-right: auto;
|
||||||
|
text-align: left;
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-right: 20px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
padding-left: 20px;
|
||||||
|
line-height: 120%;
|
||||||
|
}
|
||||||
|
.details {
|
||||||
|
padding-left:20%;
|
||||||
|
padding-right:20%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
img {
|
||||||
|
border:0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
.content {
|
||||||
|
margin: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
height: 3700px;
|
||||||
|
width: 500px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
text-decoration:none;
|
||||||
|
margin: 15px;
|
||||||
|
display: block;
|
||||||
|
color: #88FFFF;
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
color: #000040;
|
||||||
|
background-color: #88ffff;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
font-size: 20px;
|
||||||
|
font-weight: bold;
|
||||||
|
font-family: "Courier New", Courier, mono;
|
||||||
|
color: #88ffff;
|
||||||
|
background-position: center center;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse
|
||||||
|
}
|
||||||
|
td {
|
||||||
|
border: 2px solid #88ffff;
|
||||||
|
width: 5em;
|
||||||
|
color: #88ffff;
|
||||||
|
}
|
||||||
|
.nobdr {
|
||||||
|
border: none;
|
||||||
|
cell-padding: 5px;
|
||||||
|
}
|
237
Assignments/JavaScript/MP11_CalebFontenot/public_html/index.html
Normal file
@ -0,0 +1,237 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
|
||||||
|
Click nbfs://nbhost/SystemFileSystem/Templates/Other/html.html to edit this template
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Greg's Gambits | Game of 21</title>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<link href="greg.css" rel="stylesheet" type="text/css">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<label id="start">Hello! Welcome to Greg's Gambits! Press "Start Game" to start! <br></label>
|
||||||
|
<label id="cpuGamesWon">Dealer cards:</label> <br>
|
||||||
|
<label id="cpuPoints"></label><br>
|
||||||
|
<label id="cpuCards"></label> <label id="hiddenCard"><img src="cards/hidden.png"></label><br>
|
||||||
|
<label id="playerGamesWon">Your cards:</label><br>
|
||||||
|
<label id="playerPoints"></label><br>
|
||||||
|
<label id="playerCards"></label><br>
|
||||||
|
<label id="cardsInPlay"></label>
|
||||||
|
<input type="button" id="startButton" onclick="startGame()" value="Start Game">
|
||||||
|
<input type="button" id="continueButton" onclick="draw()" value="Continue Round">
|
||||||
|
<input type="button" id="endButton" onclick="endRound()" value="End Round">
|
||||||
|
<script>
|
||||||
|
var cpuPoints = 0, playerPoints = 0;
|
||||||
|
var cpuCards = 0, playerCards = 0;
|
||||||
|
var totalCpuPoints = 0, totalPlayerPoints = 0;
|
||||||
|
var cpuTimesWon = 0;
|
||||||
|
playerTimesWon = 0;
|
||||||
|
var isStarted = false;
|
||||||
|
// Card array. This will allow us to remember if a card is in play.
|
||||||
|
var rows = 12;
|
||||||
|
var cols = 3;
|
||||||
|
var cardArray = Array.from({length: rows}, () =>
|
||||||
|
Array.from({length: cols}, () => false)
|
||||||
|
);
|
||||||
|
hiddenCard.hidden = true;
|
||||||
|
continueButton.hidden = true;
|
||||||
|
endButton.hidden = true;
|
||||||
|
function checkEntireArray() {
|
||||||
|
var numOfBools = (cardArray.length * cardArray[0].length);
|
||||||
|
console.log("Number of bools: " + numOfBools);
|
||||||
|
var trueCount = 0;
|
||||||
|
var returnBool = false;
|
||||||
|
for (let i = 0; i < cardArray.length; i++) {
|
||||||
|
for (let j = 0; j < cardArray[i].length; j++) {
|
||||||
|
if (cardArray[i][j]) {
|
||||||
|
trueCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("Number of bools set to true: " + trueCount);
|
||||||
|
if (trueCount == numOfBools) {
|
||||||
|
returnBool = true;
|
||||||
|
}
|
||||||
|
return returnBool;
|
||||||
|
}
|
||||||
|
function getCardNumber() {
|
||||||
|
let exitLoop = false;
|
||||||
|
let cardNumber = 0; //prompt("Card Number:");
|
||||||
|
let cardType = 0; //prompt("Card Type: ");
|
||||||
|
do {
|
||||||
|
console.log(cardType + " " + cardNumber);
|
||||||
|
if (checkEntireArray()) {
|
||||||
|
console.log('Ran out of cards in deck! Breaking!');
|
||||||
|
alert("Cannot draw more cards!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!cardArray[cardNumber][cardType]) {
|
||||||
|
cardArray[cardNumber][cardType] = true;
|
||||||
|
exitLoop = true;
|
||||||
|
} else {
|
||||||
|
cardNumber = Math.trunc((Math.random() * 12));
|
||||||
|
cardType = Math.trunc((Math.random() * 3));
|
||||||
|
console.log("Ran into existing card, generating new numbers! " + cardType + " " + cardNumber);
|
||||||
|
exitLoop = false;
|
||||||
|
}
|
||||||
|
} while (!exitLoop);
|
||||||
|
printArray();
|
||||||
|
checkEntireArray();
|
||||||
|
return [cardNumber, cardType];
|
||||||
|
|
||||||
|
}
|
||||||
|
function printArray() {
|
||||||
|
document.getElementById("cardsInPlay").innerHTML = "";
|
||||||
|
for (let i = 0; i < cardArray.length; i++) {
|
||||||
|
for (let j = 0; j < cardArray[i].length; j++) {
|
||||||
|
document.getElementById("cardsInPlay").innerHTML += cardArray[i][j] + " ";
|
||||||
|
}
|
||||||
|
document.getElementById("cardsInPlay").innerHTML += "<br>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function drawCards(player, cardNumber, cardType, isHidden) {
|
||||||
|
if (!isHidden) {
|
||||||
|
if (player == 'cpu') {
|
||||||
|
hiddenCard.hidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
let cardBuilder = "cards/";
|
||||||
|
switch (cardNumber) {
|
||||||
|
case 0:
|
||||||
|
cardBuilder += "ace_of_";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
cardBuilder += "2_of_";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
cardBuilder += "3_of_";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
cardBuilder += "4_of_";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
cardBuilder += "5_of_";
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
cardBuilder += "6_of_";
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
cardBuilder += "7_of_";
|
||||||
|
break;
|
||||||
|
case 7:
|
||||||
|
cardBuilder += "8_of_";
|
||||||
|
break;
|
||||||
|
case 8:
|
||||||
|
cardBuilder += "9_of_";
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
cardBuilder += "10_of_";
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
cardBuilder += "jack_of_";
|
||||||
|
cardNumber = 9;
|
||||||
|
break;
|
||||||
|
case 11:
|
||||||
|
cardBuilder += "queen_of_";
|
||||||
|
cardNumber = 9;
|
||||||
|
break;
|
||||||
|
case 12:
|
||||||
|
cardBuilder += "king_of_";
|
||||||
|
cardNumber = 9;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (cardType) {
|
||||||
|
case 0:
|
||||||
|
cardBuilder += "clubs.png"
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
cardBuilder += "diamonds.png"
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
cardBuilder += "diamonds.png"
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
cardBuilder += "spades.png"
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (player == "cpu") {
|
||||||
|
cpuCards = cardNumber + 1;
|
||||||
|
} else if (player == "player") {
|
||||||
|
playerCards = cardNumber + 1;
|
||||||
|
}
|
||||||
|
document.getElementById(player + "Cards").innerHTML += "<img src=\"" + cardBuilder + "\"> ";
|
||||||
|
} else {
|
||||||
|
hiddenCard.hidden = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
function updatePoints() {
|
||||||
|
document.getElementById("playerPoints").innerHTML = "This round: " + playerPoints + "; ";
|
||||||
|
document.getElementById("playerPoints").innerHTML += "Total Points: " + totalPlayerPoints;
|
||||||
|
document.getElementById("playerGamesWon").innerHTML = "Your cards: (times won: " + playerTimesWon + ")";
|
||||||
|
|
||||||
|
document.getElementById("cpuPoints").innerHTML = "This round: " + cpuPoints + "; ";
|
||||||
|
document.getElementById("cpuPoints").innerHTML += "Total Points: " + totalCpuPoints;
|
||||||
|
document.getElementById("cpuGamesWon").innerHTML = "Dealer cards: (times won: " + cpuTimesWon + ")";
|
||||||
|
}
|
||||||
|
function startGame() {
|
||||||
|
// Dealer and player have two cards.
|
||||||
|
if (!isStarted) {
|
||||||
|
document.getElementById("playerCards").innerHTML = "";
|
||||||
|
document.getElementById("cpuCards").innerHTML = "";
|
||||||
|
cpuPoints = 0;
|
||||||
|
playerPoints = 0;
|
||||||
|
var [cardNumber, cardType] = getCardNumber();
|
||||||
|
|
||||||
|
drawCards('cpu', cardNumber, cardType, false);
|
||||||
|
cpuPoints += cpuCards;
|
||||||
|
drawCards('cpu', 0, 0, true);
|
||||||
|
for (let i = 0; i < 2; i++) {
|
||||||
|
var [cardNumber, cardType] = getCardNumber();
|
||||||
|
drawCards('player', cardNumber, cardType, false);
|
||||||
|
playerPoints += playerCards + 1;
|
||||||
|
}
|
||||||
|
isStarted = true;
|
||||||
|
startButton.hidden = true;
|
||||||
|
continueButton.hidden = false;
|
||||||
|
endButton.hidden = false;
|
||||||
|
start.hidden = true;
|
||||||
|
}
|
||||||
|
updatePoints();
|
||||||
|
}
|
||||||
|
function draw() {
|
||||||
|
var [cardNumber, cardType] = getCardNumber();
|
||||||
|
// if ((playerPoints + cardNumber) < 21)
|
||||||
|
{
|
||||||
|
drawCards('player', cardNumber, cardType, false);
|
||||||
|
playerPoints += playerCards + 1;
|
||||||
|
updatePoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
function endRound() {
|
||||||
|
var [cardNumber, cardType] = getCardNumber();
|
||||||
|
drawCards('cpu', cardNumber, cardType, false);
|
||||||
|
cpuPoints += cpuCards + 1;
|
||||||
|
updatePoints();
|
||||||
|
startButton.hidden = false;
|
||||||
|
continueButton.hidden = true;
|
||||||
|
endButton.hidden = true
|
||||||
|
isStarted = false;
|
||||||
|
// Determine winner
|
||||||
|
if (playerPoints <= 21 & (cpuPoints < playerPoints)) {
|
||||||
|
totalPlayerPoints += playerPoints;
|
||||||
|
playerTimesWon++;
|
||||||
|
} else {
|
||||||
|
totalCpuPoints += cpuPoints;
|
||||||
|
cpuTimesWon++;
|
||||||
|
}
|
||||||
|
updatePoints();
|
||||||
|
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|