Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complete #14

Open
wants to merge 300 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
300 commits
Select commit Hold shift + click to select a range
8a32bfe
Merge branch 'crapsJack' of https://github.com/deltaGPhys/Maven.Casin…
Nov 4, 2019
544eed1
Merge branch 'crapsJack' of https://github.com/deltaGPhys/Maven.Casin…
Nov 4, 2019
57d05d4
rearranged startPlay and roundOfPlay, and stubbed out
Nov 4, 2019
c885611
coordinating with Jack
Nov 4, 2019
5949619
merge conflict
Nov 4, 2019
2d7cf67
added tests and game logic for craps - one test not passing
Nov 4, 2019
fee8b84
Player tests working
Nov 4, 2019
4ea5203
blackjack flow impreovements
deltaGPhys Nov 4, 2019
92f6c65
Player tests all pass
Nov 4, 2019
76c19b2
updated some thoughts on methods
Nov 4, 2019
b8f4b37
gameServices and tests
deltaGPhys Nov 4, 2019
bd26d9f
wagering
deltaGPhys Nov 4, 2019
9390de0
got music to workgit add . Now it can stop and play other songs. Also…
Sandicus Nov 4, 2019
1aaf9da
GoFish changes
Nov 4, 2019
bb44e99
Merge branch 'GoFish2' of https://github.com/deltaGPhys/Maven.Casino …
deltaGPhys Nov 4, 2019
2e4fe16
Merge branch 'Music' of https://github.com/deltaGPhys/Maven.Casino in…
deltaGPhys Nov 4, 2019
5e3d368
menu spacing
deltaGPhys Nov 5, 2019
2bc3e12
move music player and BJ dialogue edits
deltaGPhys Nov 5, 2019
7486371
Music nows plays everywhere and i mean EVERYWHERE
Sandicus Nov 5, 2019
7f41621
Merge branch 'MusicToo' of https://github.com/deltaGPhys/Maven.Casino…
deltaGPhys Nov 5, 2019
88ad6af
utilities package
deltaGPhys Nov 5, 2019
d6912d6
just committing
Sandicus Nov 5, 2019
71b5dd1
craps player test complete
Nov 5, 2019
f0751a3
still working
Gbunde Nov 5, 2019
71eb7e0
craps player tests working
Nov 5, 2019
8e00741
fixed the non-passing test in winOnSubsequentTest
Nov 5, 2019
8e2dc9f
added console printing and redirects to calculatePayout inside the cr…
Nov 5, 2019
554c958
menu updated
Nov 5, 2019
65fa2c9
Merge branch 'crapsJack' of https://github.com/deltaGPhys/Maven.Casin…
Nov 5, 2019
5617051
updated game messages
Nov 5, 2019
ad80a38
COMMENCE EPIC INTRO
Sandicus Nov 5, 2019
daed46c
The opening just got cooler
Sandicus Nov 5, 2019
629db82
added a intro sound effect, cool beans
Sandicus Nov 5, 2019
a0027c7
bloop
Sandicus Nov 5, 2019
65cd0c1
updatd methods for user input to roll dice
Nov 5, 2019
aae4792
updated user input rolling methods
Nov 5, 2019
55efd7f
branch change
deltaGPhys Nov 5, 2019
4ff4500
commit before pull
Nov 5, 2019
aa4c45c
merge conflict
deltaGPhys Nov 5, 2019
0a7b660
typos
deltaGPhys Nov 5, 2019
655fed1
getting ready to pull from dev
Nov 5, 2019
b1dffad
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 5, 2019
565532d
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 5, 2019
8ff1a9b
halfway
Gbunde Nov 5, 2019
58f05ea
added psvm - can run a sample game now
Nov 5, 2019
c84eb2f
teller menu complete
deltaGPhys Nov 5, 2019
055f183
acutally merging teller menu
deltaGPhys Nov 5, 2019
07fb85c
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 5, 2019
787a79f
Create ASCII of instructors
jackaharrisii Nov 5, 2019
0a9ae3f
toASCII method for CardSets and implementation
deltaGPhys Nov 5, 2019
f63a4e1
creating methods for functions in round of play
Nov 5, 2019
88d308c
pushing before a merge
Nov 5, 2019
0fbd82c
Merge branch 'craps' of https://github.com/deltaGPhys/Maven.Casino in…
Nov 5, 2019
ab8a95f
working on endings
Sandicus Nov 5, 2019
e247c17
added periods to screen prints
Nov 5, 2019
2a7661c
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Sandicus Nov 5, 2019
9cf0d5c
Console class implemented
Nov 5, 2019
aaee8d3
card set addmultiple
deltaGPhys Nov 5, 2019
817639f
blooopp
Sandicus Nov 5, 2019
50d9ba8
epic intro is a go
Sandicus Nov 5, 2019
48932cb
Merge remote-tracking branch 'origin/MusicFour' into dev
deltaGPhys Nov 5, 2019
7f78a49
Merge branch 'MusicFour' of https://github.com/deltaGPhys/Maven.Casin…
deltaGPhys Nov 5, 2019
6add8cf
access to initial winnings
deltaGPhys Nov 5, 2019
c044134
almost
Gbunde Nov 5, 2019
fc86837
played with interface and added betting - still need to finish interf…
Nov 5, 2019
02b3412
minor GF updates
Nov 5, 2019
3d68657
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 5, 2019
6cba24b
cleaned up game info
Nov 5, 2019
0d272df
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Sandicus Nov 5, 2019
4a2829c
round of play cleaned up
Nov 5, 2019
f925af7
updated table limits
Nov 5, 2019
b020644
updated bet choice menu with table limits
Nov 5, 2019
8863b88
game is allowing wagers, but the amount won or lost has little to do …
Nov 5, 2019
343b5e7
fixed merge conflict
Nov 5, 2019
a8d864c
crad suite display
deltaGPhys Nov 5, 2019
711cac8
functioning endings
Sandicus Nov 5, 2019
0f0aec8
remove card fixed
deltaGPhys Nov 5, 2019
70b1449
removeRank
deltaGPhys Nov 5, 2019
fa6b4c0
committing to pull
Nov 5, 2019
6682dd0
bet choices just about complete logic done need balance to work
Nov 5, 2019
b252cd0
added a bunch of tests for calculateWinnings - no longer win money on…
Nov 5, 2019
e321a0d
merge conflicts resolved
Nov 5, 2019
d53a448
fixed merge conflicts
Nov 5, 2019
6f5530d
another merge conflict
Nov 5, 2019
8316765
working to resolve merge conflicts
Nov 5, 2019
7c62c6a
trying to resolve merge conflict
Nov 5, 2019
82be7da
bet choices updated to work correctly
Nov 5, 2019
dc464ba
Merge branch 'dev' into crapsJack
Nov 5, 2019
bd3e454
splitting
deltaGPhys Nov 5, 2019
615c8a8
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
deltaGPhys Nov 5, 2019
54d4025
Three endings up and ready to go, more ASCII to come
Sandicus Nov 5, 2019
32160d4
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Sandicus Nov 5, 2019
ed7cf77
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
deltaGPhys Nov 5, 2019
407ca95
working
Gbunde Nov 5, 2019
18af259
Merge branch 'RRstub' of https://github.com/deltaGPhys/Maven.Casino i…
deltaGPhys Nov 5, 2019
77c5a62
blackjack split works
deltaGPhys Nov 5, 2019
87fea98
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
deltaGPhys Nov 5, 2019
f16f4e0
Merge branch 'temp' into dev
deltaGPhys Nov 5, 2019
b9f0604
Craps music and ascii is a go
Sandicus Nov 5, 2019
a819142
updated wager
Nov 5, 2019
8f7a252
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 5, 2019
6527f45
Merge branch 'craps' of https://github.com/deltaGPhys/Maven.Casino in…
Nov 6, 2019
1f6e5b4
Moved GFRound to GFGame
Nov 6, 2019
2e88a2d
GFG opponen turn beginning
Nov 6, 2019
71febfd
Main ascii art is done, and all story portions are just about there
Sandicus Nov 6, 2019
874fbcb
finished player/npc loop
Nov 6, 2019
1ebf26e
fix aces bug
deltaGPhys Nov 6, 2019
45b8974
Delete .DS_Store
deltaGPhys Nov 6, 2019
4d1a8db
gitignore
deltaGPhys Nov 6, 2019
663976d
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
deltaGPhys Nov 6, 2019
731a813
Delete .DS_Store
deltaGPhys Nov 6, 2019
c67f4d8
Delete .DS_Store
deltaGPhys Nov 6, 2019
10e2161
Delete .DS_Store
deltaGPhys Nov 6, 2019
86f53ea
Delete .DS_Store
deltaGPhys Nov 6, 2019
4c1b7ef
Delete .DS_Store
deltaGPhys Nov 6, 2019
3f1ccbe
Delete .DS_Store
deltaGPhys Nov 6, 2019
fd89d7b
Delete .DS_Store
deltaGPhys Nov 6, 2019
c98733a
minor test updates
Nov 6, 2019
404571d
Merge branch 'dev'
deltaGPhys Nov 6, 2019
3b362cb
committing
Sandicus Nov 6, 2019
3fb31f8
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 6, 2019
cb1d6f4
pre-merge
deltaGPhys Nov 6, 2019
f683561
trying to merge
Nov 6, 2019
7abdfa5
preparing to merge into dev
Nov 6, 2019
af39844
Merge Party
Nov 6, 2019
dd1aae9
Merge branch 'craps' of https://github.com/deltaGPhys/Maven.Casino in…
Nov 6, 2019
e2d048a
premerge
Sandicus Nov 6, 2019
7ead7ef
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Sandicus Nov 6, 2019
09615b7
Merge Party
Nov 6, 2019
42a2029
ascii merge
Sandicus Nov 6, 2019
d017cdc
ln stuff
deltaGPhys Nov 6, 2019
dc16714
merge dev
deltaGPhys Nov 6, 2019
460ce30
merge dev
deltaGPhys Nov 6, 2019
1249908
worked with print delays
Sandicus Nov 6, 2019
bae63ea
gofissssh
deltaGPhys Nov 6, 2019
081ebeb
tweeking with strings
Sandicus Nov 6, 2019
60e7d08
Merge branch 'ascii3' of https://github.com/deltaGPhys/Maven.Casino i…
deltaGPhys Nov 6, 2019
6662935
minor navigation
deltaGPhys Nov 6, 2019
ce39a24
pulling
Nov 6, 2019
27e7c38
menus
deltaGPhys Nov 6, 2019
f9719bf
ascii for dice
deltaGPhys Nov 6, 2019
b6c9fb8
cap
deltaGPhys Nov 6, 2019
d3ffddb
added test
Nov 6, 2019
6f0847c
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 6, 2019
e7e847f
enter bug for chris
deltaGPhys Nov 6, 2019
acbbde0
gameplay tweeking and strings
Sandicus Nov 6, 2019
d4ffcf9
gimme dev
Sandicus Nov 6, 2019
f85a20e
ready to show ascii dice and need to fix payouts
Nov 6, 2019
479e64f
roll counter consolidated
Nov 6, 2019
53d2476
testing game loop
Nov 6, 2019
e8bbcd4
got the winOnSubsequent payout working correctly
Nov 6, 2019
dd294f1
working on ASCII dice
Nov 6, 2019
505546e
Merge branch 'crapsJack' of https://github.com/deltaGPhys/Maven.Casin…
Nov 6, 2019
d391967
SONGS AINT OVERLAPPING ON MY WATCH
Sandicus Nov 6, 2019
596b4ed
ASCII dice working
Nov 6, 2019
062d202
Merge conflict fixed
Nov 6, 2019
e6b475e
ascii art and messages cleaned up
Nov 6, 2019
10c9cb8
ascii again, it never ends
Sandicus Nov 6, 2019
acf17b2
set craps game table limits in GameRepo
Nov 6, 2019
9fce922
ascii and more ascii
Sandicus Nov 6, 2019
96f6b9e
updated changes to betting menu to be able to leave
Nov 6, 2019
cdbc108
Craps music has been fixed
Sandicus Nov 6, 2019
eaac652
merging to dev
Sandicus Nov 6, 2019
1d01d2e
lemme merge darn it lol
Sandicus Nov 6, 2019
f14c35b
worked on Tests
Gbunde Nov 6, 2019
9e92bb2
Merge remote-tracking branch 'origin' into dev
Sandicus Nov 6, 2019
b26e030
stash
deltaGPhys Nov 6, 2019
2f9c1d7
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
deltaGPhys Nov 6, 2019
f016b64
merge conflict
deltaGPhys Nov 6, 2019
7e6d089
Merge branch 'crapsdt' into dev
deltaGPhys Nov 6, 2019
247c987
mergee
Sandicus Nov 6, 2019
8a38177
gimme dev pls
Sandicus Nov 6, 2019
58f5540
tweeking music and strings
Sandicus Nov 6, 2019
53b84fd
merge confl
deltaGPhys Nov 6, 2019
9412c26
RRTest move
deltaGPhys Nov 6, 2019
4f88f3a
fixed teller ascii
Sandicus Nov 6, 2019
8f154e4
functioning loopssssss
Nov 6, 2019
15cb727
fixed conflicts
Sandicus Nov 6, 2019
ec4420a
test
Nov 6, 2019
89270a0
now u die in roulette
Sandicus Nov 7, 2019
486c4af
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Sandicus Nov 7, 2019
72f4c6f
merge
Sandicus Nov 7, 2019
5064543
you can die in roullete merge
Sandicus Nov 7, 2019
1f4d981
Merge branch 'asciiart' of https://github.com/deltaGPhys/Maven.Casino…
deltaGPhys Nov 7, 2019
25d27da
tweeking string outputs
Sandicus Nov 7, 2019
76d19c2
mergee
Sandicus Nov 7, 2019
c39f8d9
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Sandicus Nov 7, 2019
6ebda75
merging string edits
Sandicus Nov 7, 2019
9489081
some GF tests
deltaGPhys Nov 7, 2019
ea65302
pulling test updates
Nov 7, 2019
1016222
merge
deltaGPhys Nov 7, 2019
653cbcf
fixing conflicts
Nov 7, 2019
1bb4f94
Tests added to finish craps
Nov 7, 2019
adda358
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 7, 2019
638eb8c
Roulette is done for reals
Sandicus Nov 7, 2019
dd36616
mergin final roulette edits
Sandicus Nov 7, 2019
0156835
more tests for fisih and NPCfish
deltaGPhys Nov 7, 2019
0836650
Merge branch 'gftests' into dev
deltaGPhys Nov 7, 2019
626a5a3
win condition works
Nov 7, 2019
dbafb69
reset implemented
Nov 7, 2019
b2eec84
game services fixes merge
deltaGPhys Nov 7, 2019
db3e845
ending money text fix merge
deltaGPhys Nov 7, 2019
4222044
string editing bloop
Sandicus Nov 7, 2019
b565c71
removing unnecessary exceptions and imports
deltaGPhys Nov 7, 2019
4a0530c
pulling dev
Sandicus Nov 7, 2019
1db0059
merging dev to gameplay2
Sandicus Nov 7, 2019
bfeae67
more problematic exceptions removed
deltaGPhys Nov 7, 2019
5968b7b
fixed merge conflicts
Sandicus Nov 7, 2019
bf58d5e
pulling dev
Sandicus Nov 7, 2019
044a89d
merging gameplay2 to dev
Sandicus Nov 7, 2019
4737873
skip prologue with enter
deltaGPhys Nov 7, 2019
c537cdb
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
deltaGPhys Nov 7, 2019
1a66621
go fish scan for suites test passing
deltaGPhys Nov 7, 2019
91e4194
player tests
deltaGPhys Nov 7, 2019
70418ee
things
Nov 7, 2019
39ae258
Tried to get return to game menu working
Nov 7, 2019
02440cb
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 7, 2019
1b0eef6
card sanitization fix
deltaGPhys Nov 7, 2019
7a5bb30
pull prep
Nov 7, 2019
fa7bb96
.
Nov 7, 2019
c708018
BJ quit at beginning
deltaGPhys Nov 7, 2019
7d7060e
message update
Nov 8, 2019
309fd5b
merging
Nov 8, 2019
c0ccb68
craps now displays amount won in the winning message
Nov 8, 2019
5653437
Merge branch 'dev' into crapsWinnings
Nov 8, 2019
6834553
fixed winning on first roll message
Nov 8, 2019
c42857f
final wager message fix
Nov 8, 2019
18a53fc
craps menu and tests passing and work with ASCII die
Nov 8, 2019
eea152e
merge conflicts resolved
Nov 8, 2019
488e9dc
ASCII die reformatted to be underneath messages
Nov 8, 2019
1378d78
ASCII dice on bottom tests pass
Nov 8, 2019
dbe4a49
prologue skip fix and gf fish music fix
deltaGPhys Nov 8, 2019
3558f06
bj option 5 quitting fix
deltaGPhys Nov 8, 2019
3e5046d
rr game music stopping
deltaGPhys Nov 8, 2019
bef0db3
merging message
Nov 8, 2019
b5fde40
Merge branch 'GF5' of https://github.com/deltaGPhys/Maven.Casino into…
deltaGPhys Nov 8, 2019
4d4810a
GF message fix and player choice resstriction
deltaGPhys Nov 8, 2019
441fdba
wincheck fix
deltaGPhys Nov 8, 2019
dda08c3
GF quit
deltaGPhys Nov 8, 2019
1f5c29c
craps music repeats
deltaGPhys Nov 8, 2019
9c3c8a9
deleting unused stuff
deltaGPhys Nov 8, 2019
7a00f46
deleting merge game
deltaGPhys Nov 8, 2019
da55946
comment prune
deltaGPhys Nov 8, 2019
9dee45b
unnecessary try block remove
deltaGPhys Nov 8, 2019
8f15576
more tests for rr
Nov 8, 2019
2311101
Merge branch 'dev' of https://github.com/deltaGPhys/Maven.Casino into…
Nov 8, 2019
1920674
tests pass RR working
Nov 8, 2019
40a90f7
minor output tweak in happy ending
deltaGPhys Nov 8, 2019
1c232bb
minor cleanup
deltaGPhys Nov 8, 2019
76f4b97
.
deltaGPhys Jan 18, 2020
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ local.properties
.settings/
.loadpath
.recommenders
*.DS_Store

# External tool builders
.externalToolBuilders/
Expand Down
312 changes: 312 additions & 0 deletions ASCII of instructors

Large diffs are not rendered by default.

36 changes: 34 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,44 @@
<artifactId>casino</artifactId>
<version>1.0-SNAPSHOT</version>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>pl.pragmatists</groupId>
<artifactId>JUnitParams</artifactId>
<version>1.1.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>4.5</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
<version>4.13-beta-3</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

Binary file added src/.DS_Store
Binary file not shown.
294 changes: 294 additions & 0 deletions src/main/java/io/zipcoder/casino/Blackjack/BlackjackGame.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,294 @@
package io.zipcoder.casino.Blackjack;

import io.zipcoder.casino.CardGame;
import io.zipcoder.casino.CardSet;
import io.zipcoder.casino.Interfaces.Game;
import io.zipcoder.casino.Menus.BlackjackMenu;
import io.zipcoder.casino.Player;
import io.zipcoder.casino.Services.GameServices;
import io.zipcoder.casino.Utility.Music;
import io.zipcoder.casino.utilities.Console;

import java.util.ArrayList;
import java.util.HashMap;

public class BlackjackGame extends CardGame implements Game {

private String name = "Blackjack";
public static final HashMap<String, Integer> cardMap = new HashMap<String,Integer>();
static {
for (int i = 2; i <= 10; i++) {
cardMap.put(String.valueOf(i), i);
}
cardMap.put("J",10);
cardMap.put("Q",10);
cardMap.put("K",10);
cardMap.put("A",11);
}
private Console console = new Console(System.in, System.out);
private GameServices gameServices = new GameServices();

private double minBet;
private double maxBet;
private BlackjackPlayer player;
private BlackjackNPCPlayer dealer;
private ArrayList<BlackjackHand> hands;
private CardSet shoe;
private int numDecks;
private Music blackJackMusic = null;


public BlackjackGame(double minBet, double maxBet, Player incomingPlayer) {
this.minBet = minBet;
this.maxBet = maxBet;
this.player = new BlackjackPlayer(incomingPlayer);
this.dealer = new BlackjackNPCPlayer(new Player("Mr.", "Roboto", 50, 1000000.00), 17, true);
this.numDecks = 5;
this.hands = new ArrayList<BlackjackHand>(0);
}

public static void main(String[] args) { // for testing
Player player = new Player ("Lem", "Jukes", 23,300.00);
BlackjackGame blackjackGame = new BlackjackGame(0.0,0.0,player);
blackjackGame.startPlay();
}

public void setMinBet(double minBet) {
this.minBet = minBet;
}

public void setMaxBet(double maxBet) {
this.maxBet = maxBet;
}

@Override
public String getName() {
return name;
}

public double getMinBet() {
return minBet;
}

public double getMaxBet() {
return maxBet;
}

public int getNumDecks() {
return numDecks;
}

public CardSet getShoe() {
return shoe;
}

public ArrayList<BlackjackHand> getHands() {
return hands;
}

public BlackjackPlayer getPlayer() {
return player;
}

public BlackjackNPCPlayer getDealer() {
return dealer;
}

public void startPlay() {
//Starts playing music!
try {
Music.filePath = "src/music/(BlackJack) Glide with me.wav";
blackJackMusic = new Music();
blackJackMusic.play();
} catch (Exception ex) {
System.out.println("Error playing sound.");
ex.printStackTrace();
}

new BlackjackMenu(this).displayMenu();
if (this.minBet != 0.0) {
roundStart();
}

blackJackMusic.stop();

}

public void roundStart() {
console.printWithDelays("");
Double betSize = betChoice();
if (betSize != null) {
initialDeal(betSize);

if (initialWinnerCheck()) {
displayTable(true);
} else {
displayTable(false);

roundOfPlay();
}
clearHands();
roundStart();
}

}

public Double betChoice () {
Double wager;
console.printWithDelays(String.format("\n[DEALER]: Current bankroll: $%.2f\n", this.player.getPlayer().getBalance()),10);
wager = console.getCurrency("\n[DEALER]: Bet size (or press Enter to stand up) \n\n", this.minBet, this.maxBet);
if (wager != null) {
if (gameServices.wager(wager, this.player.getPlayer())) {
return wager;
} else {
console.printWithDelays(String.format("\n[DEALER]: Your mouth is writing checks that your wallet can't cash, %s.", this.player.getPlayer().getLastName()));
console.println("(\nGo to the Teller to pull out money)");
return betChoice();
}
} else {
return null;
}
}



public void initialDeal(double betSize) {

checkShoe();
BlackjackHand playerHand = new BlackjackHand(betSize, this.player, this.shoe.removeFirstCard(), this.shoe.removeFirstCard());

this.hands.add(playerHand);
this.player.addHand(playerHand);

NPCBlackjackHand dealerHand = new NPCBlackjackHand(0.00, (BlackjackPlayer) this.dealer, this.shoe.removeFirstCard(), this.shoe.removeFirstCard());
this.hands.add(dealerHand);
this.dealer.addHand(dealerHand);

}

public void roundOfPlay() {
int handNum = this.player.getHands().size();
for (int i = 0; i < handNum; i++) {
int value = -1;
while (value < 0) {
value = this.player.getHands().get(i).playChoice(this.shoe);
handNum = this.player.getHands().size();
this.displayTable(false);
}
}
for (BlackjackHand hand : this.dealer.getHands()) {
int value = -1;
while (value < 0) {
value = hand.playChoice(this.shoe);
this.displayTable(false);
}
}
displayTable(true);
}

public void clearHands() {
this.hands.clear();
this.player.getHands().clear();
this.dealer.getHands().clear();
}

public void endChoice() {

}

public void checkShoe() {
if (this.shoe == null || this.shoe.size() < this.numDecks * 26) {
this.shoe = getNewShoe();
}
}

public CardSet getNewShoe() {
CardSet newShoe = new CardSet(this.numDecks);
newShoe.shuffle();
return newShoe;
}

public void displayTable(boolean showWinnings) {
//temporary
console.clearScreen();

System.out.println(String.format(" .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. .----------------. \n" +
"| .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. || .--------------. |\n" +
"| | ______ | || | _____ | || | __ | || | ______ | || | ___ ____ | || | _____ | || | __ | || | ______ | || | ___ ____ | |\n" +
"| | |_ _ \\ | || | |_ _| | || | / \\ | || | .' ___ | | || | |_ ||_ _| | || | |_ _| | || | / \\ | || | .' ___ | | || | |_ ||_ _| | |\n" +
"| | | |_) | | || | | | | || | / /\\ \\ | || | / .' \\_| | || | | |_/ / | || | | | | || | / /\\ \\ | || | / .' \\_| | || | | |_/ / | |\n" +
"| | | __'. | || | | | _ | || | / ____ \\ | || | | | | || | | __'. | || | _ | | | || | / ____ \\ | || | | | | || | | __'. | |\n" +
"| | _| |__) | | || | _| |__/ | | || | _/ / \\ \\_ | || | \\ `.___.'\\ | || | _| | \\ \\_ | || | | |_' | | || | _/ / \\ \\_ | || | \\ `.___.'\\ | || | _| | \\ \\_ | |\n" +
"| | |_______/ | || | |________| | || ||____| |____|| || | `._____.' | || | |____||____| | || | `.___.' | || ||____| |____|| || | `._____.' | || | |____||____| | |\n" +
"| | | || | | || | | || | | || | | || | | || | | || | | || | | |\n" +
"| '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' || '--------------' |\n" +
" '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' '----------------' \n" + "\n" + "\n" + "\n" +

"\nTable stakes: $%.2f min / $%.2f max\n", this.minBet, this.maxBet));
console.println("[Dealer's Hand]:");
BlackjackHand dealerHand = this.dealer.getHands().get(0);

console.print(dealerHand.getCards().toASCII());
console.println("\n");
console.println(String.format("[%s's Hand(s)]:",this.player.getPlayer().getFirstName()));
ArrayList<BlackjackHand> playerHands = this.player.getHands();
for (BlackjackHand hand : playerHands) {
console.print(hand.getCards().toASCII());
console.print(" $%.2f", hand.getBet());
if (showWinnings) {
console.print(winningMessage(hand));
}
console.println("\n");
}

}

public String winningMessage(BlackjackHand hand) {
String message = " ----> ";
double winnings = calculateWinnings(hand);
if (winnings == hand.getBet()) {
message += "Push";
} else if (winnings == 0.0) {
message += "((Dealer wins))";
} else {
message += String.format("Winnings: $%.2f",winnings);
}
return message;
}

public boolean initialWinnerCheck() { // looking for blackjacks
BlackjackHand dealerHand = this.dealer.getHands().get(0); // dealer only ever has one hand
BlackjackHand playerHand = this.player.getHands().get(0); // player starts with only one hand
int dealerValue = dealerHand.getValue();
int playerValue = playerHand.getValue();

if (dealerValue == 21 && playerValue < 21 //lose to blackjack
|| dealerValue < 21 && playerValue == 21 //win w/ blackjack
|| dealerValue == 21 && 21 == playerValue) { //push w/blackjacks
return true;
}
return false;
}

// returns 0 if you lost, bet size if you pushed, 2x bet size if you won
public double calculateWinnings (BlackjackHand handToEvaluate) {

BlackjackHand dealerHand = this.dealer.getHands().get(0); // dealer only ever has one hand
int dealerValue = dealerHand.getValue();
int playerValue = handToEvaluate.getValue();
if (playerValue > dealerValue) {
if (handToEvaluate.getCards().size() == 2 && handToEvaluate.getValue() == 21) {
gameServices.payOut(2.5 * handToEvaluate.getBet(), this.player.getPlayer());
return 2.5 * handToEvaluate.getBet();
}
gameServices.payOut(2 * handToEvaluate.getBet(), this.player.getPlayer());
return 2 * handToEvaluate.getBet();
} else if (playerValue == dealerValue) {
gameServices.payOut(handToEvaluate.getBet(), this.player.getPlayer());
return handToEvaluate.getBet();
} else {
return 0.0;
}
}

}
Loading