Skip to content
This repository has been archived by the owner on Aug 18, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2 from evolutionsoftswiss/develop
Browse files Browse the repository at this point in the history
Publish version 1.1.0
  • Loading branch information
evolutionsoftswiss authored Jan 20, 2021
2 parents d5d6197 + dda9695 commit 2ae5772
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<artifactId>poker-calculator</artifactId>
<packaging>war</packaging>
<name>poker-calculator</name>
<version>1.0.0</version>
<version>1.1.0</version>

<build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ public void removeBoardCard() {
public void addPlayer() {

if (this.hands.size() < MAX_PLAYER_SIZE) {
this.hands.add(new PlayerHand(this.numberOfHoleCards));
this.hands.add(new PlayerHand(this, this.numberOfHoleCards));
}
}

Expand Down Expand Up @@ -578,8 +578,8 @@ public boolean containsCard(String value) {
void initPlayers() {

this.hands = new LinkedList<>();
this.hands.add(new PlayerHand(this.numberOfHoleCards));
this.hands.add(new PlayerHand(this.numberOfHoleCards));
this.hands.add(new PlayerHand(this, this.numberOfHoleCards));
this.hands.add(new PlayerHand(this, this.numberOfHoleCards));
}

void initBoard() {
Expand All @@ -589,6 +589,7 @@ void initBoard() {
for (Card card : this.board.getCards()) {

card.setValue(null);
card.setCalculator(this);
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/main/java/ch/evolutionsoft/poker/calculator/model/Card.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Card implements Serializable {
private static final String[] ranks = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K" };

private static final String[] suits = { "s", "h", "d", "c" };

private static Map<String, String> validCards;
static {

Expand All @@ -34,8 +34,11 @@ public class Card implements Serializable {
}
}
}

public static final String EMPTY_IMAGE_PATH = "images/emptycard.png";

private Calculator calculator;

private String value;
private String imagePath = EMPTY_IMAGE_PATH;

Expand All @@ -54,7 +57,10 @@ public String getLowerCaseValue() {

public void valueChange(ValueChangeEvent valueChangeEvent) {

this.setValue(String.valueOf(valueChangeEvent.getNewValue()));
String cardValue = String.valueOf(valueChangeEvent.getNewValue());
this.setValue(cardValue);

calculator.updateCardPaths();
}

public void setValue(String value) {
Expand Down Expand Up @@ -183,4 +189,12 @@ public int hashCode() {

return 0;
}

public Calculator getCalculator() {
return calculator;
}

public void setCalculator(Calculator calculator) {
this.calculator = calculator;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ public class PlayerHand implements Serializable{

private Card[] hand;

public PlayerHand(int numberOfHoleCards) {
public PlayerHand(Calculator calculator, int numberOfHoleCards) {

this.hand = new Card[numberOfHoleCards];
for (int index = 0; index < this.hand.length; index++) {
this.hand[index] = new Card();
this.hand[index].setCalculator(calculator);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/main/webapp/WEB-INF/liferay-plugin-package.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name=poker-calculator
module-group-id=poker-calculator
module-incremental-version=1
module-incremental-version=2
tags=Poker,texas hold'em,omaha hi,omaha hi/lo,calculator
short-description=Poker Calculator
long-description=Poker Calculator supports calculating poker odds for Omaha Hi, Omaha Hi/Lo and Texas Hold'em.
change-log=
page-url=http://evolution-soft.ch
page-url=https://evolution-soft.ch
author=EvolutionSoft
licenses=LGPL
speed-filters-enabled=false
Bundle-Version=1.0.0
Bundle-Version=1.1.0
8 changes: 7 additions & 1 deletion src/main/webapp/WEB-INF/resources/css/portlet-override.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
}

.bigCardImage {
width: 90%;
width: 100%;
}

.smallCardImage {
width: 40px;
margin: 2px 2px;
}

@media screen and (max-width: 768px) {

.content-desktop {display: none;}

}
10 changes: 6 additions & 4 deletions src/main/webapp/WEB-INF/views/input.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<h:panelGrid columns="3">
<c:forEach var="hand" items="#{calculator.hands}" varStatus="playerStatus" >
<ace:panel>
<h:outputLabel for="player" value="Player #{playerStatus.index + 1}"/>
<c:forEach id="player" var="card" items="#{hand.cards}" varStatus="cardStatus" >
<h:commandLink action="#{calculator.removePlayerCard}" >
<f:ajax render="menuForm inputForm cardsForm" />
Expand All @@ -17,11 +18,11 @@
<h:graphicImage name="#{card.imagePath}" styleClass="smallCardImage" />
</h:commandLink>
</c:forEach>
<h:outputLabel for="player" value="Player #{playerStatus.index + 1}"/>
<c:forEach var="card" items="#{hand.cards}" varStatus="cardStatus">
<h:inputText value="#{card.value}" validator="#{card.validate}"
valueChangeListener="#{card.valueChange}" size="2"
tabindex="#{(playerStatus.index + 1) * 4 + cardStatus.index}">
tabindex="#{(playerStatus.index + 1) * 4 + cardStatus.index}"
styleClass="content-desktop">
<f:ajax render="menuForm inputForm cardsForm" />
</h:inputText>
</c:forEach>
Expand All @@ -31,18 +32,19 @@

<h:panelGrid columns="1" styleClass="boardPanel">
<ace:panel>
<h:outputLabel for="board" value="Board"/>
<c:forEach var="card" items="#{calculator.boardCards}" varStatus="boardStatus">
<h:commandLink action="#{calculator.removeBoardCard}" >
<f:ajax render="menuForm inputForm cardsForm" />
<f:param name="cardParam" value="#{boardStatus.index}" />
<h:graphicImage name="#{card.imagePath}" styleClass="smallCardImage" />
</h:commandLink>
</c:forEach>
<h:outputLabel for="board" value="Board"/>
<c:forEach id="board" var="card" items="#{calculator.boardCards}">
<h:inputText id="boardCard" validator="#{card.validate}" value="#{card.value}"
valueChangeListener="#{card.valueChange}" size="2"
tabindex="#{100 + boardStatus.index}">
tabindex="#{100 + boardStatus.index}"
styleClass="content-desktop">
<f:ajax render="menuForm inputForm cardsForm" />
</h:inputText>
</c:forEach>
Expand Down

0 comments on commit 2ae5772

Please sign in to comment.