Skip to content

Commit

Permalink
Refactor to the Casino library
Browse files Browse the repository at this point in the history
  • Loading branch information
Software-Cat committed Apr 5, 2021
1 parent 33d1de1 commit cd1f0f7
Show file tree
Hide file tree
Showing 27 changed files with 81 additions and 113 deletions.
2 changes: 1 addition & 1 deletion .idea/Roulette.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/csv-plugin.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<!-- Basic Configuration -->
<groupId>io.github.softwarecats</groupId>
<artifactId>roulette</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>

<dependencies>
<dependency>
Expand All @@ -48,7 +48,7 @@
<dependency>
<groupId>io.github.softwarecats</groupId>
<artifactId>casino</artifactId>
<version>0.1.1</version>
<version>0.2.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/io/github/softwarecats/roulette/Bet.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.github.softwarecats.roulette;

import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.player.Player;

import java.util.Objects;
Expand Down Expand Up @@ -65,7 +66,7 @@ public Bet(int amountBet, Outcome outcome, Player parent) {
* @return amount won
*/
public int winAmount() {
return amountBet + outcome.winAmount(amountBet);
return amountBet + outcome.winAmount(amountBet).intValue();
}

/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/java/io/github/softwarecats/roulette/Bin.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

package io.github.softwarecats.roulette;

import java.util.Arrays;
import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.casino.event.RandomEvent;

import java.util.Collection;
import java.util.HashSet;

/**
* Bin contains a collection of Outcomes which reflect the winning bets that are paid for a particular bin on a Roulette
Expand All @@ -27,7 +28,7 @@
* “Split 1-4” , “Street 1-2-3” , “Corner 1-2-4-5” , “Five Bet” , “Line 1-2-3-4-5-6” , “00-0-1-2-3” , “Dozen 1” , “Low”
* and “Column 1” . These are collected into a single Bin .
*/
public class Bin extends HashSet<Outcome> {
public class Bin extends RandomEvent {

/**
* Instantiates an empty Bin. Outcomes can be added to it later.
Expand All @@ -43,7 +44,7 @@ public Bin() {
* @param outcomes a primitive array of outcomes
*/
public Bin(Outcome[] outcomes) {
super(Arrays.asList(outcomes));
super(outcomes);
}

/**
Expand Down Expand Up @@ -80,5 +81,4 @@ public boolean add(Outcome outcome) {
public String toString() {
return super.toString();
}

}
2 changes: 2 additions & 0 deletions src/main/java/io/github/softwarecats/roulette/BinBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.github.softwarecats.roulette;

import io.github.softwarecats.casino.event.Outcome;

import java.util.Set;

/**
Expand Down
90 changes: 0 additions & 90 deletions src/main/java/io/github/softwarecats/roulette/Outcome.java

This file was deleted.

2 changes: 2 additions & 0 deletions src/main/java/io/github/softwarecats/roulette/Wheel.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.github.softwarecats.roulette;

import io.github.softwarecats.casino.event.Outcome;

import java.util.*;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.roulette.*;
import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.Bet;
import io.github.softwarecats.roulette.Game;
import io.github.softwarecats.roulette.InvalidBetException;
import io.github.softwarecats.roulette.Table;

import java.util.ArrayDeque;
import java.util.Deque;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.roulette.*;
import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.Bet;
import io.github.softwarecats.roulette.Game;
import io.github.softwarecats.roulette.InvalidBetException;
import io.github.softwarecats.roulette.Table;

/**
* Fibonacci uses the Fibonacci betting system. This player allocates their available budget into a sequence
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.roulette.*;
import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.Bet;
import io.github.softwarecats.roulette.Game;
import io.github.softwarecats.roulette.InvalidBetException;
import io.github.softwarecats.roulette.Table;

/**
* Martingale is a Player who places bets in Roulette. This player doubles their bet on every loss and resets their
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@
package io.github.softwarecats.roulette.player;


import io.github.softwarecats.roulette.*;
import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.Bet;
import io.github.softwarecats.roulette.Game;
import io.github.softwarecats.roulette.InvalidBetException;
import io.github.softwarecats.roulette.Table;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.roulette.*;
import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.Bet;
import io.github.softwarecats.roulette.Game;
import io.github.softwarecats.roulette.InvalidBetException;
import io.github.softwarecats.roulette.Table;

/**
* Passenger57 constructs a Bet based on the Outcome named "Black".
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.Bet;
import io.github.softwarecats.roulette.InvalidBetException;
import io.github.softwarecats.roulette.Outcome;
import io.github.softwarecats.roulette.Table;

import java.util.Set;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.roulette.*;
import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.Bet;
import io.github.softwarecats.roulette.Game;
import io.github.softwarecats.roulette.InvalidBetException;
import io.github.softwarecats.roulette.Table;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.Game;
import io.github.softwarecats.roulette.InvalidBetException;
import io.github.softwarecats.roulette.Outcome;
import io.github.softwarecats.roulette.Table;

import java.util.Set;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/github/softwarecats/roulette/BetTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.github.softwarecats.roulette;

import io.github.softwarecats.casino.event.Outcome;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand Down
1 change: 1 addition & 0 deletions src/test/java/io/github/softwarecats/roulette/BinTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.github.softwarecats.roulette;

import io.github.softwarecats.casino.event.Outcome;
import org.junit.Test;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.github.softwarecats.roulette;

import io.github.softwarecats.casino.event.Outcome;
import org.junit.Test;

import static org.junit.Assert.assertEquals;
Expand All @@ -27,7 +28,7 @@ public class OutcomeTest {
public void winAmount() {
Outcome outcome = new Outcome("Name", 2);

assertEquals(4, outcome.winAmount(2));
assertEquals(4, outcome.winAmount(2).intValue());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.github.softwarecats.roulette;

import io.github.softwarecats.casino.event.Outcome;
import org.junit.Test;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.github.softwarecats.roulette;

import io.github.softwarecats.casino.event.Outcome;
import org.junit.Before;
import org.junit.Test;

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

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.*;
import org.junit.Before;
import org.junit.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package io.github.softwarecats.roulette.player;

import io.github.softwarecats.casino.event.Outcome;
import io.github.softwarecats.roulette.*;
import org.junit.Before;
import org.junit.Test;
Expand Down
Loading

0 comments on commit cd1f0f7

Please sign in to comment.