Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
127 commits
Select commit Hold shift + click to select a range
4268cca
Dice work but they too random
ToofastTurnip Feb 21, 2018
ab1d061
Finished Game Interface
Feb 21, 2018
1bec87c
Die class complete, passes test, starts on a random face
ToofastTurnip Feb 21, 2018
3a71d6c
Merge pull request #2 from Kain235/GameInterface
AnthonyJordan Feb 21, 2018
40b02af
Merge branch 'master' of https://github.com/Kain235/CR-MacroLabs-OOP-…
ToofastTurnip Feb 21, 2018
c1cddaf
Die done, working on dice manager
ToofastTurnip Feb 21, 2018
239bca2
jk
ToofastTurnip Feb 21, 2018
9cd178c
Die face enum added, changes made to Die class
ToofastTurnip Feb 21, 2018
03ae6d4
Dice and Card game interfaces done
Feb 21, 2018
ed0acb3
Merge pull request #4 from Kain235/CardAndDiceInterface
AnthonyJordan Feb 21, 2018
452402f
Finished Gambling interface
Feb 21, 2018
a864d69
Merge pull request #5 from Kain235/GamblingInterface
AnthonyJordan Feb 21, 2018
a753216
Merge branch 'master' of https://github.com/Kain235/CR-MacroLabs-OOP-…
ToofastTurnip Feb 21, 2018
23562d5
Dice manager tests coming along
ToofastTurnip Feb 21, 2018
f198594
Created abstract Game class
Feb 21, 2018
a2f23c8
Merge pull request #6 from Kain235/GameClass
AnthonyJordan Feb 21, 2018
6b4fa35
All dice features almost complete, just need getDiceArrayTest to pass
ToofastTurnip Feb 21, 2018
40525a1
Started person class
Feb 21, 2018
f8829c1
added tests for card
Feb 21, 2018
9b9bf2e
added test for Deck class
Feb 21, 2018
1f7ab5e
setSpecificDie has a problem
ToofastTurnip Feb 21, 2018
ed471cc
Started Person class
Feb 21, 2018
509473b
Fixed card interface
Feb 21, 2018
5467955
fixes to get tests passing
Feb 21, 2018
91a2977
Merge pull request #1 from ToofastTurnip/dice
ToofastTurnip Feb 21, 2018
db88752
Merge pull request #7 from romerolanguages/Card
AnthonyJordan Feb 21, 2018
2b291a2
Merged and fixed Card game interface
Feb 21, 2018
b14e17c
Fixed card game interface
Feb 21, 2018
187838d
First test cases
Feb 21, 2018
f1f9635
merge Master
Feb 21, 2018
9794738
partially done scoreboard
Feb 21, 2018
5079a1b
THESE DICE DONT LIE BABY
ToofastTurnip Feb 21, 2018
00d6495
last commit of the day, empty test removed, no other updates
ToofastTurnip Feb 21, 2018
bc9fc5a
Merge branch 'master' of https://github.com/ToofastTurnip/CR-MacroLab…
ToofastTurnip Feb 21, 2018
f3a7886
Merge branch 'master' into master
ToofastTurnip Feb 21, 2018
4e32788
Merge pull request #10 from ToofastTurnip/master
AnthonyJordan Feb 22, 2018
7488d11
Merging files
Feb 22, 2018
7e22993
added war files
ToofastTurnip Feb 22, 2018
f9a146b
Merge branch 'master' into war
ToofastTurnip Feb 22, 2018
34afb59
Deck class with rank and suit
Feb 22, 2018
95c9f7f
Tests written for constructors and get name. Person and Dealer class …
Feb 22, 2018
d4beb0f
Tests written for constructors and get name. Person and Dealer class …
Feb 22, 2018
6f78db6
Removed extra files from git errors
Feb 22, 2018
ed1e260
added test to deck test
Feb 22, 2018
6e21aba
Deck and test finished
Feb 22, 2018
aef8620
Deck and Test finished
Feb 22, 2018
3c041c0
War and WarTest started up, THIS VERSION WILL NOT COMPILE DONT USE IT OK
ToofastTurnip Feb 22, 2018
75ed23e
Merge pull request #8 from JoeHendricks415/Deck
AnthonyJordan Feb 22, 2018
5463edc
Merge https://github.com/Kain235/CR-MacroLabs-OOP-Casino into war
ToofastTurnip Feb 22, 2018
107cffd
Commiting to pull deck
Feb 22, 2018
8e9a2ab
Commiting to pull deck
Feb 22, 2018
4d8e415
Dec merged into working project
ToofastTurnip Feb 22, 2018
e40b52d
Finished Wallet and Dealer Wallet with tests
Feb 22, 2018
52853e7
Merge pull request #11 from Kain235/Wallet
AnthonyJordan Feb 22, 2018
30e79f5
Commiting for merge
Feb 22, 2018
fd0c157
Merge https://github.com/Kain235/CR-MacroLabs-OOP-Casino into war
ToofastTurnip Feb 22, 2018
c781476
Edited interfaces and fixed spelling mistakes
Feb 22, 2018
8b5599b
hand and handTest
Feb 22, 2018
e858531
Merge pull request #12 from romerolanguages/Hand
AnthonyJordan Feb 22, 2018
8db20f1
Added hand methods
Feb 22, 2018
72b5dc1
Finished person and dealer class
Feb 22, 2018
0a2589a
Merge pull request #13 from Kain235/PersonClass
AnthonyJordan Feb 22, 2018
06bb514
Start of GoFish
Feb 22, 2018
1b51879
Merge https://github.com/Kain235/CR-MacroLabs-OOP-Casino into war
ToofastTurnip Feb 22, 2018
80f874c
tests mostly finished
Feb 22, 2018
b083107
Almost finished
Feb 23, 2018
4adb1ec
tests all written and all but the last method up and running
Feb 23, 2018
b7c0423
Big war updates, almost playable
ToofastTurnip Feb 23, 2018
f8007b8
Main menu complete, needs the game classes to finish testing
Feb 23, 2018
9d2e529
WAR ALMOST DONE BUT THE DEALER IS BEING MEAN
ToofastTurnip Feb 23, 2018
8a96423
Barely working war, will add sout for current deck size next
ToofastTurnip Feb 23, 2018
61076e8
iDeclareWar breaks when a player has less than 4 cards, debugging
ToofastTurnip Feb 23, 2018
be0be3f
Merge pull request #15 from ToofastTurnip/master
AnthonyJordan Feb 23, 2018
52653b5
Base craps finished. Working on betting.
Feb 23, 2018
f271c6f
revised main menu class and changes to casino class
Feb 24, 2018
cdf7606
Most of craps is done. Need to add a few betting systems
Feb 24, 2018
c1e1a4f
Most of craps is done. Need to add a few betting systems
Feb 24, 2018
040bf5f
created displayGameChoices and chooseGame in MainMenu class and newPl…
Feb 24, 2018
820a1c6
Odds bets are done. Place bets and tweaks left to do
Feb 24, 2018
ed76c2f
Merge pull request #14 from carolynnmarie/MainMenu
AnthonyJordan Feb 24, 2018
c58a955
Finished craps program. Just need to add boot player method
Feb 24, 2018
3b2f0bd
Merged main menu and created menu file
Feb 24, 2018
a90deb8
Craps is finished. Finishing up test cases and squashing bugs
Feb 25, 2018
7e2b672
main changes to Blackjack/Test, some changes to Card/Suit/other files
Feb 25, 2018
00b5b18
Craps is finished. Testing is finished. Bugs fixed
Feb 25, 2018
ce6fc31
Merge pull request #16 from Kain235/Craps
AnthonyJordan Feb 25, 2018
b244a14
Merge pull request #17 from romerolanguages/Blackjack
AnthonyJordan Feb 25, 2018
9495968
Working war, making coin flipper too lol
ToofastTurnip Feb 25, 2018
3e29c54
blackjack/test and gambling money working, one quirk
Feb 25, 2018
1bfac9c
Bug fixing in iDeclareWar and early game quitting and restarting
ToofastTurnip Feb 25, 2018
44cd6fc
commit to GoFish before Finalizing
Feb 25, 2018
e756985
one extra line, trying to pull all changes from remote to my local In…
Feb 25, 2018
662a4d5
Almost finished Saving before merge
Feb 25, 2018
1b97f6f
Saving before pull to branch
Feb 25, 2018
fc480e9
Merge pull request #18 from romerolanguages/Blackjack
AnthonyJordan Feb 26, 2018
dc1885c
commiting changes for merge
Feb 26, 2018
4c6640e
commit for merge
Feb 26, 2018
377dc95
War almost done
ToofastTurnip Feb 26, 2018
5314343
fixed quirk
Feb 26, 2018
60f235a
Merge pull request #19 from romerolanguages/Blackjack
AnthonyJordan Feb 26, 2018
895b14e
War complete with small rare bug, playing with coin flipper now
ToofastTurnip Feb 26, 2018
dffa1fe
Merge https://github.com/Kain235/CR-MacroLabs-OOP-Casino
ToofastTurnip Feb 26, 2018
1d04414
Added blackjack
Feb 26, 2018
584dae9
Merge pull request #20 from ToofastTurnip/master
AnthonyJordan Feb 26, 2018
99692aa
commiting for merge
Feb 26, 2018
571fc5e
merging
Feb 26, 2018
e48d001
Finalized GoFish for now
Feb 26, 2018
0b7b48c
made nextLine comment only, to do pull request again
Feb 26, 2018
0835fe2
Merge pull request #21 from JoeHendricks415/GoFish
AnthonyJordan Feb 26, 2018
7c16ee9
negligible changes to Blackjack/Test
Feb 26, 2018
4f2d151
Merge branch 'master' of https://github.com/Kain235/CR-MacroLabs-OOP-…
AnthonyJordan Feb 26, 2018
edfa778
merging files
AnthonyJordan Feb 26, 2018
f35a69b
merging changes
AnthonyJordan Feb 26, 2018
9e2afa3
Casino is done and working
AnthonyJordan Feb 26, 2018
f5a4876
Coinflipper added
ToofastTurnip Feb 26, 2018
d7229e2
Merge pull request #23 from ToofastTurnip/master
AnthonyJordan Feb 26, 2018
84a0ccb
added coin flipper
AnthonyJordan Feb 26, 2018
c0809f6
Fixed extra coin flip
AnthonyJordan Feb 26, 2018
55fc24c
uncommented war method to end game
AnthonyJordan Feb 26, 2018
dd6b8af
war changed
AnthonyJordan Feb 26, 2018
b491c83
War refactoring dealer and player winning methods
ToofastTurnip Feb 26, 2018
69ebef8
fixed war bug
AnthonyJordan Feb 26, 2018
2a4f336
Small refactors
ToofastTurnip Feb 26, 2018
fe1b23c
Ok
ToofastTurnip Feb 26, 2018
e95ad16
"Bug fix for refactor"
ToofastTurnip Feb 26, 2018
ce9b040
Merge pull request #24 from ToofastTurnip/master
AnthonyJordan Feb 26, 2018
cc8cf03
war bug fix
AnthonyJordan Feb 26, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
1 change: 1 addition & 0 deletions CR-MacroLabs-OOP-Casino
Submodule CR-MacroLabs-OOP-Casino added at fc480e
Binary file added GreatestCasinoUML.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,22 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Binary file added src/.DS_Store
Binary file not shown.
Binary file added src/main/.DS_Store
Binary file not shown.
Binary file added src/main/java/.DS_Store
Binary file not shown.
Binary file added src/main/java/io/.DS_Store
Binary file not shown.
Binary file added src/main/java/io/zipcoder/.DS_Store
Binary file not shown.
356 changes: 356 additions & 0 deletions src/main/java/io/zipcoder/casino/Blackjack.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,356 @@
package io.zipcoder.casino;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Blackjack extends Game implements GameInterface, CardGameInterface, GamblingInterface {

private Person player;
private Hand playerHand;
private Wallet playerWallet;
private int playerChips;

private Dealer dealer;
private Hand dealerHand;
private Wallet dealerWallet;

private Deck deck;

// these 2 args are now in Person constructor for gambling games
public Blackjack(Person player) {
this.player = player;
this.playerHand = player.getHand();
this.playerWallet = player.getWallet();
//playerWallet.addChipsToAmount(chipsToStart); // add chipsToStart is now in Person constructor for gambl games
this.playerChips = playerWallet.checkChipAmount();

this.dealer = new Dealer();
this.dealerHand = dealer.getHand();
this.dealerWallet = dealer.getDealerWallet();

this.deck = new Deck();
}

// can have another constructor that takes a number int of Persons, and places those Persons
// into an array of players and one dealer.

public Person getPlayer() {
return player;
}

public Dealer getDealer() {
return dealer;
}

public Deck getDeck() {
return deck;
}

public int sumOfRanksInHand(Person person) {
int sumOfRanksInHand = 0;
Card aceRank = new Card(Rank.ACE, Suit.CLUBS);
int numberOfAceRankRepetitions = countRankRepetitionsInHand(person, aceRank);

// If there are 2 or more Aces in handArrayList, treat all Aces as = 1
if (numberOfAceRankRepetitions != 1) {
for (Card card : person.getHand().getHandArrayList()) {
if (card.getRank().toInt() == 11 || card.getRank().toInt() == 12
|| card.getRank().toInt() == 13) {
sumOfRanksInHand += 10;
} else {
sumOfRanksInHand += card.getRank().toInt();
}
}
} else { // implement Ace = 1 or Ace = 11 sumOfRanksInHand/difference/choice
int sumWhenAceEqualsOne = 0;
int sumWhenAceEqualsEleven = 0;
for (Card card : person.getHand().getHandArrayList()) {
if (card.getRank().toInt() == 11 || card.getRank().toInt() == 12
|| card.getRank().toInt() == 13) {
sumWhenAceEqualsOne += 10;
sumWhenAceEqualsEleven += 10;
} else if (card.getRank().toInt() == 1) {
sumWhenAceEqualsOne += 1;
sumWhenAceEqualsEleven += 11;
} else {
sumWhenAceEqualsOne += card.getRank().toInt();
sumWhenAceEqualsEleven += card.getRank().toInt();
}
}
if ( (sumWhenAceEqualsOne <= 21) && (sumWhenAceEqualsEleven <= 21) ) {
int greaterOfTwoAceSums = findGreaterOfTwoInts(sumWhenAceEqualsOne, sumWhenAceEqualsEleven);
sumOfRanksInHand = greaterOfTwoAceSums;
} else {
int smallerOfTwoAceSums = findSmallerOfTwoInts(sumWhenAceEqualsOne, sumWhenAceEqualsEleven);
sumOfRanksInHand = smallerOfTwoAceSums;
}
}

return sumOfRanksInHand;
}

public int countRankRepetitionsInHand(Person person, Card cardRankToCount) {
int numberOfRankRepetitions = 0;
for (Card card : person.getHand().getHandArrayList()) {
if (card.getRank().toInt() == cardRankToCount.getRank().toInt()) {
numberOfRankRepetitions++;
}
}
return numberOfRankRepetitions;
}

public int findSmallerOfTwoInts(int number1, int number2) {
if (number1 <= number2) {
return number1;
} else {
return number2;
}
}

public int findGreaterOfTwoInts(int number1, int number2) {
if (number1 >= number2) {
return number1;
} else {
return number2;
}
}

public void personDecision(Person person) {
Scanner scanner = new Scanner(System.in);
String playerDecisionString = scanner.nextLine();

if (playerDecisionString.equals("hit")) {
this.hit(person);
}
}

public String handToString(ArrayList<Card> handArrayList) {
StringBuilder sb = new StringBuilder();
for (Card card : handArrayList) {
sb.append(card.toString() + " ");
}
sb.deleteCharAt(sb.length()-1);
return sb.toString();
}

public void hit(Person person) {
Card cardFromDealer = this.getDeck().drawCard();
person.getHand().receiveCards(cardFromDealer);
}

// CardGameInterface
public int checkNumberOfCards() {
return 0;
}

@Override
public int checkNumberOfCards(Hand hand) {
return 0;
}

// CardGameInterface
public void dealCards() {

}

// GamblingInterface
public int checkChipAmount(Person personToCheck) {
return 0;
}

// GamblingInterface
public void placeBet(Person personPlacingBet, int betAmount) {
personPlacingBet.getWallet().removeChipsFromAmount(betAmount);
}

// GamblingInterface
public int getAnte() {
return 0;
}

// GamblingInterface
public void bootPlayerFromGame(Person personToBoot) {

}

// GamblingInterface
public int checkPot() {
return 0;
}

// public String askForPlayerName() {
// return "nameTest";
// }

// GameInterface or Game Class
public void start() {
this.getDeck().shuffleDeck();
Scanner scanner = new Scanner(System.in);

if (this.getPlayer().getWallet().checkChipAmount() <= 0) {
System.out.println("You don't have anymore chips to play");
return; // THIS EXITS THE METHOD
}

// Check bet > 0
int betPlaced = 0;
do {
System.out.println("How many chips do you want to bet?");
String inputString = scanner.nextLine(); // changed to nextLine to fix next loop
try {
betPlaced = Integer.parseInt(inputString);
if (betPlaced <= 0) {
System.out.println("Your bet must be a number greater than zero.");
System.out.println();
continue;
}
else if (betPlaced <= this.getPlayer().getWallet().checkChipAmount()) {
this.placeBet(this.getPlayer(), betPlaced);
break;
} else {
System.out.println("You only have " + this.getPlayer().getWallet().checkChipAmount() + " chip(s)");
System.out.println();
}
} catch (NumberFormatException ne) {
System.out.println("Please try again.");
System.out.println();
}
} while (true);

this.hit(this.getPlayer());
this.hit(this.getPlayer());
this.hit(this.getDealer());
this.hit(this.getDealer());

int personHandSum = 0;
int dealerHandSum = 0;

String myHand = "";
String dealerHand = "";
String playerDecisionString = "";

System.out.println();
System.out.println("+++ PLAY BLACKJACK +++");
do {
personHandSum = this.sumOfRanksInHand(this.getPlayer());
System.out.println();
System.out.print(this.getPlayer().getName() + ": " + "\u270B");
System.out.print(this.handToString(this.getPlayer().getHand().getHandArrayList()));
System.out.print("\u270B" + ", hand = " + personHandSum);

System.out.println();
String dealerCardShown = this.getDealer().getHand().getHandArrayList().get(1).toString();
System.out.print("Dealer: " + "\u270B" + "\uD83C\uDCA0" + " " + dealerCardShown + "\u270B");

if (personHandSum == 21) {
System.out.println();
System.out.println("++++++++++++++++++++++++++++++++");
System.out.println("BLACKJACK!+++ You won " + betPlaced + " chip(s)");
System.out.println("++++++++++++++++++++++++++++++++");
this.getPlayer().getWallet().addChipsToAmount(2 * betPlaced);
break;
} else if (personHandSum > 21){
System.out.println();
System.out.println("+++++++++++++++++++++");
System.out.println("BUST! You lost " + betPlaced + " chip(s)");
System.out.println("+++++++++++++++++++++");
break;
}

// get new deck if card number falls <= 16
if (this.getDeck().getDeckOfCards().size() <= 16) {
this.deck = new Deck();
getDeck().shuffleDeck();
}

System.out.println();
System.out.println("Do you want to \"hit\" or \"stay\"?: ");
playerDecisionString = scanner.nextLine();

if (playerDecisionString.equals("hit")) {
this.hit(this.getPlayer());
} else if (playerDecisionString.equals("stay")) {
break;
}
} while (personHandSum < 21);

dealerHandSum = this.sumOfRanksInHand(this.getDealer());
if ( !(personHandSum >= 21) ) { // If player stayed with a hand < 21
if (dealerHandSum <= 16) { // If dealer's hand >= 17, dealer has to stay
this.hit(dealer); // Hit dealer only once if dealer's hand <= 16
}
}

dealerHandSum = this.sumOfRanksInHand(this.getDealer());
if (playerDecisionString.equals("stay")) {
if ( (dealerHandSum <= 21) && (dealerHandSum > personHandSum) ) {
System.out.println("++++++++++++++++++++++++");
System.out.println("Dealer wins!");
System.out.println("You lost " + betPlaced + " chip(s)");
System.out.println("++++++++++++++++++++++++");
} else if ( (dealerHandSum <= 21) && (dealerHandSum == personHandSum) ) {
System.out.println("++++++++++++++++++++++++");
System.out.println("It's a tie!");
System.out.println("You keep your " + betPlaced + " chip(s)");
System.out.println("++++++++++++++++++++++++");
this.getPlayer().getWallet().addChipsToAmount(betPlaced);
} else {
System.out.println("+++++++++++++++++++++++++");
System.out.println(this.getPlayer().getName() + " wins!");
System.out.println("You won " + betPlaced + " chip(s)");
System.out.println("+++++++++++++++++++++++++");
this.getPlayer().getWallet().addChipsToAmount(2 * betPlaced); }
}

System.out.println();
System.out.println("FINAL SCORE:");
personHandSum = this.sumOfRanksInHand(this.getPlayer());
System.out.print(this.getPlayer().getName() + ": " + "\u270B");
System.out.print(this.handToString(this.getPlayer().getHand().getHandArrayList()));
System.out.print("\u270B" + ", hand = " + personHandSum);

dealerHandSum = this.sumOfRanksInHand(this.getDealer());
System.out.println();
System.out.print("Dealer: " + "\u270B");
System.out.print(this.handToString(this.getDealer().getHand().getHandArrayList()));
System.out.print("\u270B" + ", hand = " + dealerHandSum);
System.out.println();
System.out.println();
System.out.print(this.getPlayer().getName() + " has ");
System.out.println(this.getPlayer().getWallet().checkChipAmount() + " chip(s)");

System.out.println();
this.doYouWantToContinuePlaying();
System.out.println();
}

public void doYouWantToContinuePlaying() {
Scanner scanner = new Scanner(System.in);
String test = "";
do {
System.out.println("Keep playing? (yes/no) ");
test = scanner.nextLine();
if (test.equals("yes")) {
this.getPlayer().getHand().clearHand();
this.getDealer().getHand().clearHand();
this.start();
break;
} if (test.equals("no")) {
break;
}
} while(true);
}

// Game Class
public void end() {
System.out.print("Thank you for playing");
System.out.println();
}

// public static void main (String[] args) {
// Blackjack blackjack = new Blackjack("Anyname", 10);
// blackjack.start();
// blackjack.end();
// }
}
Loading