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

CasinoWar #11

Open
wants to merge 79 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
79 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
ea50b94
Merge branch 'RickyRick' into Destany
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
fe215ac
"update"
oadams2013 Jul 21, 2023
9595a9e
Merge pull request #9 from zip-it-lock-put-it-in-your-pocket/master
oadams2013 Jul 21, 2023
f80d2fe
Pulling account balance
rpk2301 Jul 21, 2023
4a6d750
Added StreetCraps Game (I still need to add players balance and bet a…
santoslopez890 Jul 21, 2023
9569dbc
Merge pull request #10 from zip-it-lock-put-it-in-your-pocket/Santos
santoslopez890 Jul 21, 2023
b00c223
slots fixed
rpk2301 Jul 21, 2023
0547767
Merge branch 'master' into RickyRick
rpk2301 Jul 21, 2023
72d8f33
Merge pull request #11 from zip-it-lock-put-it-in-your-pocket/RickyRick
rpk2301 Jul 21, 2023
3718359
added a new class
oadams2013 Jul 21, 2023
6e94e49
roulette game creation
anudeep-chennuri Jul 21, 2023
82c6ba7
Merge remote-tracking branch 'origin/master' into Olamide
oadams2013 Jul 21, 2023
6aecfa5
write broken in slots
rpk2301 Jul 21, 2023
a5f3fe5
Kinda fixed betting in slots
rpk2301 Jul 21, 2023
ae6a949
"update"
oadams2013 Jul 24, 2023
7e43278
Merge pull request #12 from zip-it-lock-put-it-in-your-pocket/Olamide
oadams2013 Jul 24, 2023
8ee8a80
Updated CasinoWar game to be testable
DestanyM Jul 25, 2023
6815468
CasinoWar Updates
DestanyM Jul 25, 2023
21005e4
Merge branch 'master' into Destany
DestanyM Jul 25, 2023
0143db0
Merge pull request #13 from zip-it-lock-put-it-in-your-pocket/Destany
santoslopez890 Jul 25, 2023
dfd0135
Update Casino.java
DestanyM Jul 25, 2023
6e4d2e4
fixed betting in ride the bus
rpk2301 Jul 25, 2023
8d8a2cc
Erase old CasinoWar.java
DestanyM Jul 25, 2023
85d7b63
fixed merge conflict
rpk2301 Jul 25, 2023
d7afbea
Merge branch 'master' into RickyRick
rpk2301 Jul 25, 2023
1a45a1d
Merge pull request #15 from zip-it-lock-put-it-in-your-pocket/RickyRick
rpk2301 Jul 25, 2023
ed01bcb
Delete CasinoWar.java
santoslopez890 Jul 25, 2023
2450f3c
fixed betting in slots
rpk2301 Jul 25, 2023
8627adc
Merge pull request #16 from zip-it-lock-put-it-in-your-pocket/RickyRick
rpk2301 Jul 25, 2023
c929878
Merge pull request #17 from zip-it-lock-put-it-in-your-pocket/BlackJa…
rpk2301 Jul 25, 2023
7d27313
REBASEING STUFF
santoslopez890 Jul 25, 2023
8e16a07
did some things
rpk2301 Jul 25, 2023
5d333a5
STREETCRAPS WORKS WOWOWOWOW
santoslopez890 Jul 25, 2023
3e818a7
Merge branch 'master' into NEWSANTOS
santoslopez890 Jul 25, 2023
c474aed
Merge pull request #18 from zip-it-lock-put-it-in-your-pocket/NEWSANTOS
santoslopez890 Jul 25, 2023
da20f38
StreetCraps DONE
santoslopez890 Jul 25, 2023
b3bb393
Merge remote-tracking branch 'origin/NEWSANTOS' into NEWSANTOS
santoslopez890 Jul 25, 2023
86e86ab
Merge pull request #19 from zip-it-lock-put-it-in-your-pocket/NEWSANTOS
santoslopez890 Jul 25, 2023
27c4eb4
fixed issue with streetcraps taking double your money
santoslopez890 Jul 25, 2023
564e845
Merge pull request #20 from zip-it-lock-put-it-in-your-pocket/NEWSANTOS
santoslopez890 Jul 25, 2023
ab107a1
we dont talk about this
santoslopez890 Jul 25, 2023
f433370
Merge pull request #21 from zip-it-lock-put-it-in-your-pocket/NEWSANTOS
santoslopez890 Jul 25, 2023
f0c35ae
added tests with olamide
rpk2301 Jul 25, 2023
2a4a590
added some more tests.
rpk2301 Jul 25, 2023
bbca9eb
ADDED 2 MORE TESTS
santoslopez890 Jul 25, 2023
a2cc1e7
added some more tests.
rpk2301 Jul 25, 2023
0214413
Merge pull request #22 from zip-it-lock-put-it-in-your-pocket/NEWSANTOS
rpk2301 Jul 25, 2023
599847f
roulette game creation
anudeep-chennuri Jul 25, 2023
ebf9cf2
Merge remote-tracking branch 'origin/master'
anudeep-chennuri Jul 25, 2023
61fe3a6
commented out
anudeep-chennuri Jul 25, 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.
1 change: 1 addition & 0 deletions GroupCasino
Submodule GroupCasino added at d1d591
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
55 changes: 45 additions & 10 deletions src/main/java/com/github/zipcodewilmington/Casino.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,68 @@
import com.github.zipcodewilmington.casino.CasinoAccountManager;
import com.github.zipcodewilmington.casino.GameInterface;
import com.github.zipcodewilmington.casino.PlayerInterface;
import com.github.zipcodewilmington.casino.games.BlackJack.BlackJackGame;
import com.github.zipcodewilmington.casino.games.RideTheBus.RideTheBusGame;
import com.github.zipcodewilmington.casino.games.StreetCraps;
import com.github.zipcodewilmington.casino.games.numberguess.NumberGuessGame;
import com.github.zipcodewilmington.casino.games.numberguess.NumberGuessPlayer;
import com.github.zipcodewilmington.casino.games.slots.SlotsGame;
import com.github.zipcodewilmington.casino.games.slots.SlotsPlayer;
import com.github.zipcodewilmington.casino.games.CasinoWar.CasinoWar;

import com.github.zipcodewilmington.utils.AnsiColor;
import com.github.zipcodewilmington.utils.IOConsole;

/**
* Created by leon on 7/21/2020.
*/

public class Casino implements Runnable {
private final IOConsole console = new IOConsole(AnsiColor.BLUE);

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

String arcadeDashBoardInput;
CasinoAccountManager casinoAccountManager = new CasinoAccountManager();
do {
CasinoAccountManager.addtofile();
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(casinoAccount);
ride.start();


}
else if (gameSelectionInput.equals("WAR")) {
CasinoWar casinoWar = new CasinoWar();
casinoWar.run();


} else if (gameSelectionInput.equals("STREETCRAPS")) {
StreetCraps craps = new StreetCraps(casinoAccount);
craps.run();
}
else if (gameSelectionInput.equals("BLACKJACK")) {
BlackJackGame.runBlackJack();
} else {
// TODO - implement better exception handling
String errorMessage = "[ %s ] is an invalid game selection";
Expand All @@ -49,9 +81,11 @@ 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));

}

private String getArcadeDashboardInput() {
Expand All @@ -66,14 +100,15 @@ 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 ], [ WAR ], [ STREETCRAPS ], [ BLACKJACK ] ")
.toString());
}

private void play(Object gameObject, Object playerObject) {
GameInterface game = (GameInterface)gameObject;
PlayerInterface player = (PlayerInterface)playerObject;
private void play(Object gameObject, Object playerObject) throws InterruptedException {
GameInterface game = (GameInterface) gameObject;
PlayerInterface player = (PlayerInterface) playerObject;
game.add(player);
game.run();
}
}

}}

Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.github.zipcodewilmington;

public class MainApplication {
public static void main(String[] args) {
public class MainApplication
{
public static void main(String[] args) throws InterruptedException
{
new Casino().run();
}
}



Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Santos,Santos,123,100.0
Kantos,Kantos,ugh,1450.0
BobLee,BobLee,4321,0.0
hans,hans,4321,0.0
bans,bans,4321,0.0
Deep,Deep,rollinginthedeep,0.0
1,1,1,1046.0
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,57 @@
* 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 addCasinoBalance(double add){
casinoBalance+=add;
}
public void subCasinoBalance(double sub){
casinoBalance-=sub;
}


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;
}


}
Original file line number Diff line number Diff line change
@@ -1,46 +1,151 @@
package com.github.zipcodewilmington.casino;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.*;

/**
* Created by leon on 7/21/2020.
* `ArcadeAccountManager` stores, manages, and retrieves `ArcadeAccount` objects
* it is advised that every instruction in this class is logged
*/
public class CasinoAccountManager {
public class CasinoAccountManager extends CasinoAccount{
/**
* @param accountName name of account to be returned
* @param accountPassword password of account to be returned
* @return `ArcadeAccount` with specified `accountName` and `accountPassword`
*/

public static LinkedHashMap<String, CasinoAccount> data = new LinkedHashMap<String, CasinoAccount>();


public CasinoAccount getAccount(String accountName, String accountPassword) {
String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName();
String currentClassName = getClass().getName();
String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented";
throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName));

boolean end=false;
Iterator it = data.entrySet().iterator();
CasinoAccount acc = null;
// acc=data.get(accountName);

while (it.hasNext()&& !end) {
Map.Entry pair = (Map.Entry) it.next();
acc = (CasinoAccount) pair.getValue();
if (Objects.equals(acc.getName(), accountName) && Objects.equals(acc.getAccountPassword(), accountPassword)) {
end = true;
}
else{
acc=null;
}
}

return acc;
}


//String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName();
//String currentClassName = getClass().getName();
//String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented";
//throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName));



/**
* logs & creates a new `ArcadeAccount`
*
* @param accountName name of account to be created
* @param accountPassword password of account to be created
* @return new instance of `ArcadeAccount` with specified `accountName` and `accountPassword`
*/

public CasinoAccount createAccount(String accountName, String accountPassword) {
CasinoAccount account=new CasinoAccount();



String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName();
account.setAccountName(accountName);
String currentClassName = getClass().getName();
account.setAccountPassword(accountPassword);
String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented";
throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName));
data.put(accountName,account);
return account;


}

/**
* logs & registers a new `ArcadeAccount` to `this.getArcadeAccountList()`
*
* @param casinoAccount the arcadeAccount to be added to `this.getArcadeAccountList()`
*/

public void registerAccount(CasinoAccount casinoAccount) {


String currentMethodName = new Object(){}.getClass().getEnclosingMethod().getName();

String currentClassName = getClass().getName();

String errorMessage = "Method with name [ %s ], defined in class with name [ %s ] has not yet been implemented";
throw new RuntimeException(String.format(errorMessage, currentMethodName, currentClassName));
}
public static void addAllAccounts(){
data.put("Santos",new CasinoAccount("Santos","123" , 1000));



try {
Scanner fileIn = new Scanner(new File("src/main/java/com/github/zipcodewilmington/casino/Accounts.txt"));

while (fileIn.hasNextLine())
{
String line = fileIn.nextLine();
String [] accountData=line.split(",");
String hashKey= (accountData[0]);
String accountName= (accountData[1]);
String accountPass= (accountData[2]);
double casinoBalance= Double.parseDouble(accountData[3]);

// Reads the entire line
// Output the line
data.put(hashKey, new CasinoAccount(accountName,accountPass,casinoBalance));
}
}
catch (IOException e) {
System.out.println("File not found");
}
}
public static void addtofile(){
//add to file
File file = new File("src/main/java/com/github/zipcodewilmington/casino/Accounts.txt");
BufferedWriter bf = null;
//adds account to properties
try {


bf = new BufferedWriter(new FileWriter(file));
for (Map.Entry<String, CasinoAccount> entry : data.entrySet()) {
// put key and value separated by a colon
bf.write(entry.getKey() + "," + entry.getValue().getName()+","+entry.getValue().getAccountPassword()+","+entry.getValue().getCasinoBalance());
// new line
bf.newLine();
}
bf.flush();
}
catch (IOException e) {
e.printStackTrace();
}
finally {

try {

// always close the writer
bf.close();
}
catch (Exception e) {
}
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ public interface GameInterface extends Runnable {
*/
void remove(PlayerInterface player);



/**
* specifies how the game will run
*/
void run();
}
Loading