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

Olamide #7

Open
wants to merge 30 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
93794ee
UML
santoslopez890 Jul 18, 2023
32e2ede
Delete Casino Project UML.drawio.png
santoslopez890 Jul 19, 2023
188524e
Add files via upload
santoslopez890 Jul 19, 2023
2f83bf0
APPROVED UML
santoslopez890 Jul 19, 2023
df2f2e6
Started War Test
DestanyM Jul 19, 2023
4a1ce82
Pushing Ride The Bus, Deck, and Card
rpk2301 Jul 20, 2023
8c0507e
Merge pull request #1 from zip-it-lock-put-it-in-your-pocket/RickyRick
rpk2301 Jul 20, 2023
5fb38ae
Put games into package
rpk2301 Jul 20, 2023
0e5995a
Merge pull request #2 from zip-it-lock-put-it-in-your-pocket/RickyRick
rpk2301 Jul 20, 2023
0637381
CasinoWar game progress
DestanyM Jul 20, 2023
96270b5
Account maker done
santoslopez890 Jul 20, 2023
11fff8a
Merge pull request #3 from zip-it-lock-put-it-in-your-pocket/Santos
santoslopez890 Jul 20, 2023
d2344e8
added input validation; bet amounts implemented.
rpk2301 Jul 20, 2023
1abe974
Account creation works now and Writes and read from file now
santoslopez890 Jul 20, 2023
e6f3159
Account creation works now and Writes and read from file now (FIXED B…
santoslopez890 Jul 20, 2023
b5db3f2
Account creation works now and Writes and read from file now (FIXED B…
santoslopez890 Jul 20, 2023
a6eca1b
updates for CasinoWar
DestanyM Jul 20, 2023
7eaf07e
Merge pull request #4 from zip-it-lock-put-it-in-your-pocket/Santos
santoslopez890 Jul 21, 2023
d0ee673
Working on changing color within slots
rpk2301 Jul 21, 2023
8a143cf
Merge pull request #5 from zip-it-lock-put-it-in-your-pocket/RickyRick
rpk2301 Jul 21, 2023
bad2595
This time for sure
santoslopez890 Jul 21, 2023
0ef4ff5
Merge branch 'master' into Santos
santoslopez890 Jul 21, 2023
85bf577
Merge pull request #6 from zip-it-lock-put-it-in-your-pocket/Santos
santoslopez890 Jul 21, 2023
d1d5912
Merge pull request #7 from zip-it-lock-put-it-in-your-pocket/Destany
rpk2301 Jul 21, 2023
f18463e
Done for the night
rpk2301 Jul 21, 2023
507a785
Merge pull request #8 from zip-it-lock-put-it-in-your-pocket/RickyRick
rpk2301 Jul 21, 2023
8031043
roulette table progress
anudeep-chennuri Jul 21, 2023
6ba4e4b
roulette test creation
anudeep-chennuri Jul 21, 2023
b5397c3
"update"
oadams2013 Jul 21, 2023
9595a9e
Merge pull request #9 from zip-it-lock-put-it-in-your-pocket/master
oadams2013 Jul 21, 2023
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 Casino Project-Page-1.drawio (1).png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Casino Project-Page-1.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
Expand Down
25 changes: 19 additions & 6 deletions src/main/java/com/github/zipcodewilmington/Casino.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.github.zipcodewilmington.casino.CasinoAccountManager;
import com.github.zipcodewilmington.casino.GameInterface;
import com.github.zipcodewilmington.casino.PlayerInterface;
import com.github.zipcodewilmington.casino.games.RideTheBus.RideTheBusGame;
import com.github.zipcodewilmington.casino.games.numberguess.NumberGuessGame;
import com.github.zipcodewilmington.casino.games.numberguess.NumberGuessPlayer;
import com.github.zipcodewilmington.casino.games.slots.SlotsGame;
Expand All @@ -19,21 +20,32 @@ public class Casino implements Runnable {

@Override
public void run() {
CasinoAccountManager.addAllAccounts();

String arcadeDashBoardInput;
CasinoAccountManager casinoAccountManager = new CasinoAccountManager();
do {
arcadeDashBoardInput = getArcadeDashboardInput();
if ("select-game".equals(arcadeDashBoardInput)) {
String accountName = console.getStringInput("Enter your account name:");
String accountPassword = console.getStringInput("Enter your account password:");

CasinoAccount casinoAccount = casinoAccountManager.getAccount(accountName, accountPassword);
boolean isValidLogin = casinoAccount != null;

if (isValidLogin) {
String gameSelectionInput = getGameSelectionInput().toUpperCase();
if (gameSelectionInput.equals("SLOTS")) {
play(new SlotsGame(), new SlotsPlayer());
} else if (gameSelectionInput.equals("NUMBERGUESS")) {
play(new NumberGuessGame(), new NumberGuessPlayer());
SlotsGame slots = new SlotsGame(casinoAccount);
try {
slots.run();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
} else if (gameSelectionInput.equals("RIDETHEBUS")) {
RideTheBusGame ride = new RideTheBusGame();
ride.start();

} else {
// TODO - implement better exception handling
String errorMessage = "[ %s ] is an invalid game selection";
Expand All @@ -49,7 +61,8 @@ public void run() {
String accountName = console.getStringInput("Enter your account name:");
String accountPassword = console.getStringInput("Enter your account password:");
CasinoAccount newAccount = casinoAccountManager.createAccount(accountName, accountPassword);
casinoAccountManager.registerAccount(newAccount);
CasinoAccountManager.addtofile();
//casinoAccountManager.registerAccount(newAccount);
}
} while (!"logout".equals(arcadeDashBoardInput));
}
Expand All @@ -66,11 +79,11 @@ private String getGameSelectionInput() {
return console.getStringInput(new StringBuilder()
.append("Welcome to the Game Selection Dashboard!")
.append("\nFrom here, you can select any of the following options:")
.append("\n\t[ SLOTS ], [ NUMBERGUESS ]")
.append("\n\t[ SLOTS ], [ RIDETHEBUS ]")
.toString());
}

private void play(Object gameObject, Object playerObject) {
private void play(Object gameObject, Object playerObject) throws InterruptedException {
GameInterface game = (GameInterface)gameObject;
PlayerInterface player = (PlayerInterface)playerObject;
game.add(player);
Expand Down
141 changes: 141 additions & 0 deletions src/main/java/com/github/zipcodewilmington/CasinoWar.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
package com.github.zipcodewilmington;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class CasinoWar {

public static void main(String[] args) {
playCasinoWar();
}

static void playCasinoWar() {
Scanner scanner = new Scanner(System.in);

// Change to call deck
List<String> deck = createShuffledDeck();

int playerScore = 0;
int dealerScore = 0;

while (!deck.isEmpty()) {
// Player's turn
System.out.println("Press Enter to draw a card.");
scanner.nextLine();
String playerCard = drawCard(deck);
System.out.println("You drew: " + playerCard);
int playerCardValue = getCardValue(playerCard);

// Dealer's turn
System.out.println("Press Enter for the dealer to draw a card.");
scanner.nextLine();
String dealerCard = drawCard(deck);
System.out.println("Dealer drew: " + dealerCard + "\n");
int dealerCardValue = getCardValue(dealerCard);

// Compare the cards
if (playerCardValue > dealerCardValue) {
System.out.println("You win this round!");
playerScore++;
} else if (dealerCardValue > playerCardValue) {
System.out.println("Dealer wins this round!");
dealerScore++;
} else {
System.out.println("It's a tie! Time for war!");
// War: draw three more cards each
List<String> playerWarCards = new ArrayList<>();
List<String> dealerWarCards = new ArrayList<>();

for (int i = 0; i < 2; i++) {
playerWarCards.add(drawCard(deck));
dealerWarCards.add(drawCard(deck));
}

// Get the fourth card for comparison
String playerFourthCard = drawCard(deck);
String dealerFourthCard = drawCard(deck);

System.out.println("Your fourth card: " + playerFourthCard);
System.out.println("Dealer's fourth card: " + dealerFourthCard);

int playerFourthCardValue = getCardValue(playerFourthCard);
int dealerFourthCardValue = getCardValue(dealerFourthCard);

if (playerFourthCardValue > dealerFourthCardValue) {
System.out.println("You win the war!");
playerScore++;
} else if (dealerFourthCardValue > playerFourthCardValue) {
System.out.println("Dealer wins the war!");
dealerScore++;
} else {
System.out.println("It's a tie in the war too! Nobody wins.");
}
}


// Display the current scores
System.out.println("Your score: " + playerScore);
System.out.println("Dealer's score: " + dealerScore);
// Check if the deck is empty
if (deck.isEmpty()) {
System.out.println("The deck is empty. Game over!");
break;
}


// Ask the player if they want to continue playing
System.out.println("\n Press enter to play again or (exit) to leave.");
String input = scanner.nextLine();
if (input.equalsIgnoreCase("exit")) {
System.out.println("Thanks for playing! Final scores:");
System.out.println("Your score: " + playerScore);
System.out.println("Dealer's score: " + dealerScore);
break;
}
}

scanner.close();
}

private static List<String> createShuffledDeck() {
List<String> deck = new ArrayList<>();

String[] suits = {"Hearts", "Diamonds", "Clubs", "Spades"};
String[] ranks = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "Jack", "Queen", "King", "Ace"};

for (String suit : suits) {
for (String rank : ranks) {
deck.add(rank + " of " + suit);
}
}


Collections.shuffle(deck);
return deck;
}

private static String drawCard(List<String> deck) {
return deck.remove(deck.size() - 1);
}

private static int getCardValue(String card) {
String rank = card.split(" ")[0];
switch (rank) {
case "Ace":
return 14;
case "King":
return 13;
case "Queen":
return 12;
case "Jack":
return 11;
default:
return Integer.parseInt(rank);
}
}


}


Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public class MainApplication {
public static void main(String[] args) {

new Casino().run();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Santos,Santos,123,100.0
BobLee,BobLee,4321,0.0
hans,hans,4321,0.0
bans,bans,4321,0.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,49 @@
* The `ArcadeAccount` is used to log into the system to select a `Game` to play.
*/
public class CasinoAccount {
// variables
private String accountName;
private String accountPassword;
private double casinoBalance = 0;

public CasinoAccount(String accountName, String accountPassword) {
this.accountName = accountName;
this.accountPassword = accountPassword;
}

public CasinoAccount() {

}

public String getName() {
return accountName;
}

public void setAccountName(String accountName) {
this.accountName = accountName;
}

public String getAccountPassword() {
return accountPassword;
}

public void setAccountPassword(String accountPassword) {
this.accountPassword = accountPassword;
}

public double getCasinoBalance() {
return casinoBalance;
}

public void setCasinoBalance(double casinoBalance) {
this.casinoBalance = casinoBalance;
}

public CasinoAccount(String accountName, String accountPassword, double casinoBalance) {
this.accountName = accountName;
this.accountPassword = accountPassword;
this.casinoBalance=casinoBalance;
}


}
Loading