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

Theresa #21

Open
wants to merge 95 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
95 commits
Select commit Hold shift + click to select a range
c989258
git test
r-m-hufford Mar 15, 2021
b33deed
UML Diagram
r-m-hufford Mar 15, 2021
f4f013c
oops
liamkbecker Mar 16, 2021
ddfd733
Filled out much of CrapsDisplay
liamkbecker Mar 16, 2021
013ae20
UML Diagram
r-m-hufford Mar 16, 2021
0c2e482
Beetle added. Beetle Display started
r-m-hufford Mar 16, 2021
6d39c09
BeetleDisplay progress. GoFishDisplay added
r-m-hufford Mar 16, 2021
94439b9
Checkpointing
liamkbecker Mar 16, 2021
0eb2398
Checkpointing
liamkbecker Mar 16, 2021
897bf97
Appeasing uncle bob
liamkbecker Mar 16, 2021
c1f42d1
Started writing Diplay class methods
theresa-christina Mar 16, 2021
04acff4
GoFishDisplay progress
r-m-hufford Mar 16, 2021
f109c06
game interface. dice game abstract class.
r-m-hufford Mar 16, 2021
9691781
Merge pull request #1 from smartist17/ryan
r-m-hufford Mar 16, 2021
5c4fdf5
goFishDisplay and dice abstract class
r-m-hufford Mar 16, 2021
e8c865c
Completed more methods for Display class
theresa-christina Mar 16, 2021
67e19f0
Added methods to CardGame class
theresa-christina Mar 16, 2021
48b31dc
Merge branch 'master' into theresa
smartist17 Mar 16, 2021
5bb287f
Merge pull request #3 from smartist17/ryan
smartist17 Mar 16, 2021
043f39f
Merge pull request #2 from smartist17/theresa
smartist17 Mar 16, 2021
b6fba0e
Merge pull request #4 from smartist17/HazelBranch
smartist17 Mar 16, 2021
36598ec
Wrote methods for PlayerWarehouse class
theresa-christina Mar 17, 2021
48dab13
drew a beetle. Player class.
r-m-hufford Mar 17, 2021
412574f
Merge pull request #5 from smartist17/ryan
r-m-hufford Mar 17, 2021
e1f79a0
Merge branch 'master' into theresa
theresa-christina Mar 17, 2021
17106ef
Merge pull request #6 from smartist17/theresa
theresa-christina Mar 17, 2021
15ce9b5
Interfaces + bj display
smartist17 Mar 17, 2021
55de8a3
Merge branch 'master' into Ashley
r-m-hufford Mar 17, 2021
2d9a633
Merge pull request #7 from smartist17/Ashley
r-m-hufford Mar 17, 2021
78ae165
Black jack display complete
smartist17 Mar 17, 2021
2317eb7
Merge pull request #8 from smartist17/HazelBranch
smartist17 Mar 17, 2021
b56b0ae
Black jack display complete
smartist17 Mar 17, 2021
e3f50ce
Blackjack display complete
smartist17 Mar 17, 2021
68a2161
Merge pull request #9 from smartist17/Ashley
smartist17 Mar 17, 2021
354c448
Checkpointing
liamkbecker Mar 17, 2021
448e14d
Checkpointing
liamkbecker Mar 17, 2021
c60ad34
Filled out craps to the first dice roll
liamkbecker Mar 17, 2021
91be8bb
Checkpointing
liamkbecker Mar 17, 2021
b3a8778
Checkpointing
liamkbecker Mar 17, 2021
59a9e02
Filled out craps to the first dice roll
liamkbecker Mar 17, 2021
800b536
Updating
liamkbecker Mar 17, 2021
448ff52
Merge remote-tracking branch 'origin/HazelBranch' into HazelBranch
liamkbecker Mar 17, 2021
aeea383
beetle progress
r-m-hufford Mar 17, 2021
96c44a2
beetle
r-m-hufford Mar 17, 2021
9374e45
Checkpointing
liamkbecker Mar 17, 2021
a7af20c
Added methods for GoFish & fixed broken shuffle & dealCards methods
theresa-christina Mar 17, 2021
523cfcc
Merge pull request #10 from smartist17/ryan
r-m-hufford Mar 17, 2021
12bbc45
Finished bet options
liamkbecker Mar 17, 2021
7a94f4b
Changed a few methods
theresa-christina Mar 18, 2021
43d8809
Filled out gameplay flow post-point
liamkbecker Mar 18, 2021
ffd6f04
Added method for getting value on card
theresa-christina Mar 18, 2021
9476533
Merge pull request #12 from smartist17/theresa
theresa-christina Mar 18, 2021
8681833
beetle almost complete. additions to display and player
r-m-hufford Mar 18, 2021
fc844d3
Merge branches 'ryan' and 'master' of github.com:smartist17/Maven.Cas…
r-m-hufford Mar 18, 2021
b65ca8e
Craps finished
liamkbecker Mar 18, 2021
8ecfef9
Checkpointing
liamkbecker Mar 17, 2021
ba16a40
Checkpointing
liamkbecker Mar 17, 2021
71e9507
Filled out craps to the first dice roll
liamkbecker Mar 17, 2021
a2262be
Checkpointing
liamkbecker Mar 17, 2021
0f1f64a
Checkpointing
liamkbecker Mar 17, 2021
7073e23
Filled out craps to the first dice roll
liamkbecker Mar 17, 2021
fbeed88
Checkpointing
liamkbecker Mar 17, 2021
d3d117a
Finished bet options
liamkbecker Mar 17, 2021
8b82339
Filled out gameplay flow post-point
liamkbecker Mar 18, 2021
9bd31cf
Craps finished
liamkbecker Mar 18, 2021
11b0c5d
Updating
liamkbecker Mar 18, 2021
1a5687d
Merge remote-tracking branch 'origin/HazelBranch' into HazelBranch
liamkbecker Mar 18, 2021
8c11864
Added some more test methods for GoFish
theresa-christina Mar 18, 2021
e98d5ff
Merge pull request #13 from smartist17/theresa
theresa-christina Mar 18, 2021
5240da7
Checkpointing
liamkbecker Mar 18, 2021
a78e548
Working on users
liamkbecker Mar 18, 2021
7669f30
Added more test methods for GoFish
theresa-christina Mar 18, 2021
964a459
Added some more tests and a couple more methods to GoFish
theresa-christina Mar 18, 2021
f711417
Fixed PlayerWarehouse bug
liamkbecker Mar 18, 2021
a03499f
Merge pull request #11 from smartist17/HazelBranch
liamkbecker Mar 18, 2021
cedefd2
Started working out GoFish game flow
theresa-christina Mar 18, 2021
3257333
beetle complete.
r-m-hufford Mar 18, 2021
fae4f25
Merge pull request #14 from smartist17/ryan
r-m-hufford Mar 18, 2021
e53c800
game is fully functional
r-m-hufford Mar 19, 2021
10321a6
Merge pull request #15 from smartist17/ryan
r-m-hufford Mar 19, 2021
746f433
Beetle Dispaly tests
r-m-hufford Mar 19, 2021
841f0b8
Merge pull request #16 from smartist17/ryan
r-m-hufford Mar 19, 2021
c4dccc8
Attempting to get GoFish to work and it's just NOT....
theresa-christina Mar 19, 2021
31a6dea
Merge branch 'master' into theresa
r-m-hufford Mar 19, 2021
4320ea8
Merge pull request #17 from smartist17/theresa
r-m-hufford Mar 19, 2021
2c20684
UML Diagram
r-m-hufford Mar 20, 2021
7bbc605
Merge pull request #18 from smartist17/ryan
r-m-hufford Mar 20, 2021
463fe3d
BeetleService added. more tests.
r-m-hufford Mar 20, 2021
9b87a91
Merge pull request #19 from smartist17/ryan
r-m-hufford Mar 20, 2021
f991803
Small changes
theresa-christina Mar 21, 2021
ec9fd9d
Merge branch 'theresa' of https://github.com/smartist17/Maven.Casino …
theresa-christina Mar 21, 2021
2262a05
Think I've almost got it working 100%
theresa-christina Mar 22, 2021
f6b1ffe
Got all GoFish tests working again
theresa-christina Mar 22, 2021
19423b7
Merge branch 'master' into theresa
theresa-christina Mar 22, 2021
22dccb9
Minor fix to a small error I made while merging
theresa-christina Mar 22, 2021
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 .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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* `Player` objects should be created upon input from a user.
* `Game` interface
* Contract which ensures that a class enforces some aspect of _playing_.
* `GamblingGame` interface
* `io.zipcoder.casino.GamblingGame` interface
* Contract which ensures that a game enforces some aspect of _waging money_.
* `GamblingPlayer` interface
* Contract which ensures that a player has some ability to _wage money_.
Expand Down
Binary file added src/Casino Structure.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
199 changes: 199 additions & 0 deletions src/Casino Structure.puml
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
@startuml
'https://plantuml.com/class-diagram

Game <|-- GamblingGame
Game <|-- CardGame
GamblingPlayer <|-- Player
GamblingGame <|-- Blackjack
GamblingGame <|-- DiceGame

DiceGame <|-- Beetle
DiceGame <|-- Craps
CardGame <|-- Blackjack
CardGame <|-- GoFish


Display <|-- BeetleDisplay
Display <|-- CrapsDisplay
Display <|-- BlackjackDisplay
Display <|-- GoFishDisplay


'INTERFACE
interface Game {
Random
Boolean gameState
checkForWinner()
setPlayer()
}

interface GamblingGame {
acceptBetFrom()
calculateReward()
calculateLoss()
}

interface GamblingPlayer {
placeBet()
}


'ABSTRACT CLASS
abstract class CardGame{
Stack decksOfCards
ArrayList playersHand
ArrayList dealersHand
shuffleCards()
dealCards(Int numberOfCards)
skipDeal()

}

abstract class DiceGame {
rollDice(numberOfDice)
}


'CLASS
class Main{

}

class CasinoEngine {
runCasino()
}

class Player {
String name
Double accountBalance
getName()
getAccountBalance()
setAccountBalance()
}

class GoFish {
HashMap <Player, Hand>
HashMap <Player, NumberOfPairs>
exchangeCard()
getNumberOfPairs()
setNumberOfPairs()
}

class GoFishDisplay {
chooseAPlayerToAsk()
chooseACardtoAskFor()
playerHasCard()
goFish()
pairMade()

}

class Blackjack {
HashMap <String cardFaceValue, Int CardPointValue>
gotBlackJack(int betPlaced)
standOrHit()
}

class BlackjackDisplay {
dealersFirstCard()
bustMessage(String whoBusted)
dealersTotal()
dealerStands()
dealerHits()
chooseStandOrHit()
}

class Craps {
Boolean isNatural()
Boolean isCraps()
Boolean isPoint()
analyzeComeOutRoll()
analyzeFollowingRolls()
'comeBet()
'dontComeBet()
'passBet()
'dontPassBet()
'fieldBet()
'bigSixOrEightBet()
getTypeOfBet()
}

class CrapsDisplay {
rulesMenu()
optionsMenu()
shooterScores()
shooterSevenedOut()
push()
oneRollBetLoss()
onRollBetWin()
natural()
craps()
shooterRolled()
setTypeOfBet()
comeOutRoll()

}

class Beetle {
createNextImage()
}

class BeetleDisplay {
drawBugHead()
drawBugBody()
drawBugLeg1()
drawBugLeg2()
drawBugLeg3()
drawBugLeg4()
playerBugComplete()
opponentBugComplete()
repeatRoll()
bodyPartValue()
}

class PlayerWarehouse {
playerGroup <password, Player>
getPlayer()
}

class Console {
Scanner input
PrintStream output
print()
println()
getStringInput()
getDoubleInput()
getLongInput()
getIntegerInput()
}

class Display {
String currentDisplay

errorMessage()

'casino messages
welcomeMessage()
gamesMenu()
lowFundsWarning()
zeroFundsWarning()

'game messages
rollResult()
dealResult()
youWin()
youLose()
doYouWantToBet()

'new user messages
userId()
requestUserId()
initialDeposit()

'returning user messages
welcomeBack()

}


@enduml
155 changes: 155 additions & 0 deletions src/main/java/io/zipcoder/casino/Beetle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
package io.zipcoder.casino;

import io.zipcoder.casino.utilities.Console;

import java.io.InputStream;
import java.io.PrintStream;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;

public class Beetle extends DiceGame{
Player player;
Random random = new Random();
Console console;
private InputStream in;
private PrintStream out;
BeetleDisplay display = new BeetleDisplay();
BeetleService service = new BeetleService();

private Double purse = 0.00;

public Beetle(Player player) {
this.player = player;
this.in = System.in;
this.out = System.out;
this.console = new Console(in, out);
}

// FACILITATOR
public void gameEngine() {
Boolean userHasNotWon = true;
Boolean opponentHasNotWon = true;
Boolean playersHaveNotTied = true;

display.displayWelcomeSequence(player, service.getCompleteBeetle());
tableMinimumDeposit();
display.currentPurse(getPurse());
while (playersHaveNotTied && userHasNotWon && opponentHasNotWon) {

//BET
Double userBetAmount = (console.getDoubleInput("how much would you like to bet?"));
acceptBetFromUser(userBetAmount);
Double opponentBet = opponentBet(userBetAmount);
setPurse(opponentBet);

//PLAY
Integer userRollValue = diceRollSum(1);
analyzeRoll(service.getUsersRolls(), service.getUsersBeetle(), userRollValue);
Integer opponentsRollValue = diceRollSum(1);
analyzeRoll(service.getOpponentsRolls(), service.getOpponentsBeetle(), opponentsRollValue);

//DISPLAY
display.gameBoard(userRollValue, service.getUsersBeetle(), opponentsRollValue, service.getOpponentsBeetle(), getPurse(),userBetAmount,opponentBet);

//ANALYZE
playersHaveNotTied = tieStateDoesNotExist(service.getUsersBeetle(), service.getOpponentsBeetle());
userHasNotWon = winningStateDoesNotExist(service.getUsersBeetle());
opponentHasNotWon = losingStateDoesNotExist(service.getOpponentsBeetle());
}
display.printAccountBalance(player.getWallet());
}

//GAME STATE
public Boolean tieStateDoesNotExist(String[][] usersBeetle, String[][] opponentsBeetle) {
if (Arrays.deepEquals(service.getCompleteBeetle(), usersBeetle) && Arrays.deepEquals(service.getCompleteBeetle(), opponentsBeetle)) {
display.bothBeetlesComplete();
player.setWallet(player.getCurrentBet());
System.out.println("Your bets were returned to your wallet.");
return false;
}
return true;
}

public Boolean winningStateDoesNotExist(String[][] usersBeetle) {
if (Arrays.deepEquals(service.getCompleteBeetle(), usersBeetle)) {
display.userBugIsComplete();
player.setWallet(purse);
player.setCurrentBet(0.00);
return false;
}
return true;
}

public Boolean losingStateDoesNotExist(String[][] opponentsBeetle) {
if (Arrays.deepEquals(service.getCompleteBeetle(), opponentsBeetle)) {
display.opponentsBugisComplete();
player.setWallet(-player.getCurrentBet());
player.setCurrentBet(0.00);
return false;
}
return true;
}

public void analyzeRoll(Set<Integer> rollSet, String[][] playersBeetle, Integer diceRoll){
if(!rollSet.contains(diceRoll)) {
service.updateBeetleDrawing(playersBeetle,diceRoll);
rollSet.add(diceRoll);
}
}

//BETTING
public void acceptBetFromUser(Double betAmount) {
player.makeBet(betAmount);
purse += betAmount;
}


public Double tableMinimumDeposit() {
acceptBetFromUser(1.00);
purse += 1;
return purse;
}

public Double opponentBet(Double userBet) {
Double opponentBet = 0.0;
if (service.getOpponentsRolls().size() >= service.getUsersRolls().size()) {
Double multiplier = random.nextDouble() + 0.5;
opponentBet = userBet * Math.round(multiplier * 100) / 100;
}
BigDecimal formattedBet = new BigDecimal(opponentBet).setScale(2, RoundingMode.HALF_UP);
opponentBet = formattedBet.doubleValue();
return opponentBet;
}

public Double calculateReward() {
double reward = purse - player.getCurrentBet();
return reward;
}

//PURSE
public Double calculateLoss() {
return player.getCurrentBet();
}

public Double getPurse() {
BigDecimal purseFormatted = new BigDecimal(purse).setScale(2, RoundingMode.HALF_UP);
purse = purseFormatted.doubleValue();
return purse;
}

public Double setPurse(Double betAmount) {
purse += betAmount;
return purse;
}

//UNUSED METHODS FROM ABSTRACT CLASS
public String endGame() {
return null;
}

public String startGame() {
return null;
}

}
Loading