Skip to content

Commit

Permalink
Merge pull request #15 from montezuma93/shamel
Browse files Browse the repository at this point in the history
Shamel
  • Loading branch information
montezuma93 authored Aug 20, 2021
2 parents 5cb0638 + b0d34c5 commit 5c882d1
Show file tree
Hide file tree
Showing 5 changed files with 171 additions and 3 deletions.
5 changes: 5 additions & 0 deletions src/main/java/Poker/Decision.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package Poker;

public enum Decision {
FOLD,CALL,RAISE;
}
13 changes: 13 additions & 0 deletions src/main/java/Poker/Player.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,29 @@
public class Player {
String name;
int chips;
int chipSetInRound;
boolean dealer;
boolean smallBlind;
boolean bigBlind;
public boolean gameMember;
public List<Card> cards;

public Player(String name, int chips) {
this.name = name;
this.chips = chips;
this.chipSetInRound = 0;
this.dealer = false;
this.cards = new ArrayList<>();
this.bigBlind = false;
this.smallBlind = false;
this.gameMember = true;
}
public void addCard(Card card){
this.cards.add(card);
}
public Decision decide(){
return Decision.CALL;
}

}

62 changes: 59 additions & 3 deletions src/main/java/Poker/PokerGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,32 @@ public class PokerGame {
int pot;
int smallBlind;
int bigBlind;
int roundSize;

public PokerGame(List<Player> players, int smallBlind, int bigBlind) {
int roundSize = bigBlind;
this.players = players;
this.smallBlind = smallBlind;
this.bigBlind = bigBlind;
this.pot = 0;

}

public void startGame() {
allCards = generateCards();
dealCards();
setBlinds();
while (!isGameOver()) {
// start next round
}
System.out.println("GameOver");

}
public void setBlinds(){
players.get(0).dealer = true;
players.get(1).smallBlind = true;
players.get(2).bigBlind = true;

}

public boolean isGameOver() {
Expand All @@ -38,6 +50,46 @@ public boolean isGameOver() {
}
return amountOfPlayersWithChips < 2;
}
public void startRounds(){
for (int i = 0; i < 4; i++){
startRound();
dealNextCard();//Neu Karte verteilen!
}
}
public void dealNextCard(){
for(int i = 0; i < players.size(); i++){
Player player = players.get(i);
if(player.gameMember){
dealLastCard(player);//jeder Player hat eigene Liste (cards)
}
}
}

public void startRound(){
//Methode!!
for(int i = 0; i < players.size(); i++) {
Player player = players.get(i);
calculateDecision(player);
//Runde inkrementieren!
}
}

private void calculateDecision(Player player) {
Decision decision = player.decide();
switch (decision) {
case FOLD:
player.gameMember = false;
case CALL:
int chipsNeedToBeSet = roundSize - player.chipSetInRound;
player.chipSetInRound = player.chipSetInRound + chipsNeedToBeSet;
player.chips -= chipsNeedToBeSet;
pot += chipsNeedToBeSet;
case RAISE: //



}
}


public void dealCards() {
Expand All @@ -47,13 +99,17 @@ public void dealCards() {
for (int i = 0; i < players.size(); i++) {
Player player = players.get(i); // erster Player usw.
for (int j = 0; j < 2; j++) { //0 <2 -> true 1<2 -> true 2<2 -false
Card card = allCards.get(allCards.size() - 1); // Karte in der Hand
allCards.remove(card); // Karte wird aus allCards entfernt
player.addCard(card); // Spieler bekommt die Karte
dealLastCard(player);
}
}
}

private void dealLastCard(Player player) {
Card card = allCards.get(allCards.size() - 1); // Karte in der Hand
allCards.remove(card); // Karte wird aus allCards entfernt
player.addCard(card); // Spieler bekommt die Karte
}

public List<Card> generateCards() {
List<Card> cards = new ArrayList<>();
List<Color> colors = Arrays.asList(Color.values());
Expand Down
81 changes: 81 additions & 0 deletions src/main/java/domain/Assignment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package domain;
//Test comment
import org.springframework.scheduling.config.Task;

import java.util.Collections;
import java.util.List;

public class Assignment {

private int earliestStartDate;
private int latestStartDate;
private int earliestEndDate;
private int latestEndDate;

private int duration;

private List<org.springframework.scheduling.config.Task> predecessors;
private List<org.springframework.scheduling.config.Task> successors;

public Assignment(int duration, List<org.springframework.scheduling.config.Task> predecessors, List<org.springframework.scheduling.config.Task> successors) {
this.duration = duration;
this.predecessors = predecessors;
this.successors = successors;
}

public int getEarliestStartDate() {
return earliestStartDate;
}

public void setEarliestStartDate(int earliestStartDate) {
this.earliestStartDate = earliestStartDate;
}

public int getLatestStartDate() {
return latestStartDate;
}

public void setLatestStartDate(int latestStartDate) {
this.latestStartDate = latestStartDate;
}

public int getEarliestEndDate() {
return earliestEndDate;
}

public void setEarliestEndDate(int earliestEndDate) {
this.earliestEndDate = earliestEndDate;
}

public int getLatestEndDate() {
return latestEndDate;
}

public void setLatestEndDate(int latestEndDate) {
this.latestEndDate = latestEndDate;
}

public int getDuration() {
return duration;
}

public void setDuration(int duration) {
this.duration = duration;
}

public List<org.springframework.scheduling.config.Task> getPredecessors() {
return predecessors;
}

public void setPredecessors(List<org.springframework.scheduling.config.Task> predecessors) {
this.predecessors = predecessors;
}

public List<org.springframework.scheduling.config.Task> getSuccessors() {
return successors;
}

public void setSuccessors(List<org.springframework.scheduling.config.Task> successors) {
this.successors = successors;
}
}
13 changes: 13 additions & 0 deletions src/test/java/poker/PokerGameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ private PokerGame createPokerGame(int amountOfFirstPlayer) {
return pokerGame;
}

@Test
public void testDealNextCard(){
PokerGame pokerGame = createPokerGame(4);
pokerGame.allCards = pokerGame.generateCards();
pokerGame.dealCards();
pokerGame.players.get(1).gameMember = false;
pokerGame.dealNextCard();
assertEquals(pokerGame.allCards.size(), 41);
assertEquals(pokerGame.players.get(0).cards.size(),3);
assertEquals(pokerGame.players.get(1).cards.size(),2);
}

@Test
public void isGameOver() {
PokerGame pokerGame = createPokerGame(10);
Expand All @@ -53,3 +65,4 @@ public void isGameOver() {
assertEquals(pokerGame.isGameOver(), true);
}
}

0 comments on commit 5c882d1

Please sign in to comment.