diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..b080d2d
--- /dev/null
+++ b/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..ca28c78
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ic_launcher-web.png b/ic_launcher-web.png
new file mode 100644
index 0000000..d06c518
Binary files /dev/null and b/ic_launcher-web.png differ
diff --git a/libs/android-support-v4.jar b/libs/android-support-v4.jar
new file mode 100644
index 0000000..9056828
Binary files /dev/null and b/libs/android-support-v4.jar differ
diff --git a/proguard-project.txt b/proguard-project.txt
new file mode 100644
index 0000000..f2fe155
--- /dev/null
+++ b/proguard-project.txt
@@ -0,0 +1,20 @@
+# To enable ProGuard in your project, edit project.properties
+# to define the proguard.config property as described in that file.
+#
+# Add project specific ProGuard rules here.
+# By default, the flags in this file are appended to flags specified
+# in ${sdk.dir}/tools/proguard/proguard-android.txt
+# You can edit the include path and order by changing the ProGuard
+# include property in project.properties.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# Add any project specific keep options here:
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
diff --git a/project.properties b/project.properties
new file mode 100644
index 0000000..4ab1256
--- /dev/null
+++ b/project.properties
@@ -0,0 +1,14 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system edit
+# "ant.properties", and override values to adapt the script to your
+# project structure.
+#
+# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
+#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
+
+# Project target.
+target=android-19
diff --git a/res/drawable-hdpi/ic_launcher.png b/res/drawable-hdpi/ic_launcher.png
new file mode 100644
index 0000000..f653362
Binary files /dev/null and b/res/drawable-hdpi/ic_launcher.png differ
diff --git a/res/drawable-mdpi/ic_launcher.png b/res/drawable-mdpi/ic_launcher.png
new file mode 100644
index 0000000..304fc84
Binary files /dev/null and b/res/drawable-mdpi/ic_launcher.png differ
diff --git a/res/drawable-xhdpi/ic_launcher.png b/res/drawable-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..9253d3a
Binary files /dev/null and b/res/drawable-xhdpi/ic_launcher.png differ
diff --git a/res/drawable-xxhdpi/ic_launcher.png b/res/drawable-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..ff7ebc7
Binary files /dev/null and b/res/drawable-xxhdpi/ic_launcher.png differ
diff --git a/res/drawable/aces.png b/res/drawable/aces.png
new file mode 100644
index 0000000..8af2966
Binary files /dev/null and b/res/drawable/aces.png differ
diff --git a/res/drawable/card102.png b/res/drawable/card102.png
new file mode 100644
index 0000000..857b0bf
Binary files /dev/null and b/res/drawable/card102.png differ
diff --git a/res/drawable/card103.png b/res/drawable/card103.png
new file mode 100644
index 0000000..b0f7e28
Binary files /dev/null and b/res/drawable/card103.png differ
diff --git a/res/drawable/card104.png b/res/drawable/card104.png
new file mode 100644
index 0000000..cad79e2
Binary files /dev/null and b/res/drawable/card104.png differ
diff --git a/res/drawable/card105.png b/res/drawable/card105.png
new file mode 100644
index 0000000..a67ba40
Binary files /dev/null and b/res/drawable/card105.png differ
diff --git a/res/drawable/card106.png b/res/drawable/card106.png
new file mode 100644
index 0000000..3dcab3a
Binary files /dev/null and b/res/drawable/card106.png differ
diff --git a/res/drawable/card107.png b/res/drawable/card107.png
new file mode 100644
index 0000000..3225ad6
Binary files /dev/null and b/res/drawable/card107.png differ
diff --git a/res/drawable/card108.png b/res/drawable/card108.png
new file mode 100644
index 0000000..285bebb
Binary files /dev/null and b/res/drawable/card108.png differ
diff --git a/res/drawable/card109.png b/res/drawable/card109.png
new file mode 100644
index 0000000..e8cd762
Binary files /dev/null and b/res/drawable/card109.png differ
diff --git a/res/drawable/card110.png b/res/drawable/card110.png
new file mode 100644
index 0000000..f562cb3
Binary files /dev/null and b/res/drawable/card110.png differ
diff --git a/res/drawable/card111.png b/res/drawable/card111.png
new file mode 100644
index 0000000..d7eaeb2
Binary files /dev/null and b/res/drawable/card111.png differ
diff --git a/res/drawable/card112.png b/res/drawable/card112.png
new file mode 100644
index 0000000..7e2b898
Binary files /dev/null and b/res/drawable/card112.png differ
diff --git a/res/drawable/card113.png b/res/drawable/card113.png
new file mode 100644
index 0000000..2076e54
Binary files /dev/null and b/res/drawable/card113.png differ
diff --git a/res/drawable/card114.png b/res/drawable/card114.png
new file mode 100644
index 0000000..c66bac2
Binary files /dev/null and b/res/drawable/card114.png differ
diff --git a/res/drawable/card202.png b/res/drawable/card202.png
new file mode 100644
index 0000000..faafcf3
Binary files /dev/null and b/res/drawable/card202.png differ
diff --git a/res/drawable/card203.png b/res/drawable/card203.png
new file mode 100644
index 0000000..2cabb51
Binary files /dev/null and b/res/drawable/card203.png differ
diff --git a/res/drawable/card204.png b/res/drawable/card204.png
new file mode 100644
index 0000000..68ff9af
Binary files /dev/null and b/res/drawable/card204.png differ
diff --git a/res/drawable/card205.png b/res/drawable/card205.png
new file mode 100644
index 0000000..a0a7291
Binary files /dev/null and b/res/drawable/card205.png differ
diff --git a/res/drawable/card206.png b/res/drawable/card206.png
new file mode 100644
index 0000000..b5d8d0e
Binary files /dev/null and b/res/drawable/card206.png differ
diff --git a/res/drawable/card207.png b/res/drawable/card207.png
new file mode 100644
index 0000000..748f9cc
Binary files /dev/null and b/res/drawable/card207.png differ
diff --git a/res/drawable/card208.png b/res/drawable/card208.png
new file mode 100644
index 0000000..41c374d
Binary files /dev/null and b/res/drawable/card208.png differ
diff --git a/res/drawable/card209.png b/res/drawable/card209.png
new file mode 100644
index 0000000..ecad351
Binary files /dev/null and b/res/drawable/card209.png differ
diff --git a/res/drawable/card210.png b/res/drawable/card210.png
new file mode 100644
index 0000000..88dd05d
Binary files /dev/null and b/res/drawable/card210.png differ
diff --git a/res/drawable/card211.png b/res/drawable/card211.png
new file mode 100644
index 0000000..a0fb841
Binary files /dev/null and b/res/drawable/card211.png differ
diff --git a/res/drawable/card212.png b/res/drawable/card212.png
new file mode 100644
index 0000000..b05657a
Binary files /dev/null and b/res/drawable/card212.png differ
diff --git a/res/drawable/card213.png b/res/drawable/card213.png
new file mode 100644
index 0000000..07af640
Binary files /dev/null and b/res/drawable/card213.png differ
diff --git a/res/drawable/card214.png b/res/drawable/card214.png
new file mode 100644
index 0000000..6fce8df
Binary files /dev/null and b/res/drawable/card214.png differ
diff --git a/res/drawable/card302.png b/res/drawable/card302.png
new file mode 100644
index 0000000..bae43dd
Binary files /dev/null and b/res/drawable/card302.png differ
diff --git a/res/drawable/card303.png b/res/drawable/card303.png
new file mode 100644
index 0000000..4b8b00e
Binary files /dev/null and b/res/drawable/card303.png differ
diff --git a/res/drawable/card304.png b/res/drawable/card304.png
new file mode 100644
index 0000000..ac3c5b0
Binary files /dev/null and b/res/drawable/card304.png differ
diff --git a/res/drawable/card305.png b/res/drawable/card305.png
new file mode 100644
index 0000000..99c7e57
Binary files /dev/null and b/res/drawable/card305.png differ
diff --git a/res/drawable/card306.png b/res/drawable/card306.png
new file mode 100644
index 0000000..7233005
Binary files /dev/null and b/res/drawable/card306.png differ
diff --git a/res/drawable/card307.png b/res/drawable/card307.png
new file mode 100644
index 0000000..b73ffad
Binary files /dev/null and b/res/drawable/card307.png differ
diff --git a/res/drawable/card308.png b/res/drawable/card308.png
new file mode 100644
index 0000000..453600c
Binary files /dev/null and b/res/drawable/card308.png differ
diff --git a/res/drawable/card309.png b/res/drawable/card309.png
new file mode 100644
index 0000000..20508c0
Binary files /dev/null and b/res/drawable/card309.png differ
diff --git a/res/drawable/card310.png b/res/drawable/card310.png
new file mode 100644
index 0000000..6f7dc26
Binary files /dev/null and b/res/drawable/card310.png differ
diff --git a/res/drawable/card311.png b/res/drawable/card311.png
new file mode 100644
index 0000000..8614574
Binary files /dev/null and b/res/drawable/card311.png differ
diff --git a/res/drawable/card312.png b/res/drawable/card312.png
new file mode 100644
index 0000000..ed66429
Binary files /dev/null and b/res/drawable/card312.png differ
diff --git a/res/drawable/card313.png b/res/drawable/card313.png
new file mode 100644
index 0000000..1d42421
Binary files /dev/null and b/res/drawable/card313.png differ
diff --git a/res/drawable/card314.png b/res/drawable/card314.png
new file mode 100644
index 0000000..9907373
Binary files /dev/null and b/res/drawable/card314.png differ
diff --git a/res/drawable/card402.png b/res/drawable/card402.png
new file mode 100644
index 0000000..3d9b95a
Binary files /dev/null and b/res/drawable/card402.png differ
diff --git a/res/drawable/card403.png b/res/drawable/card403.png
new file mode 100644
index 0000000..9268d8c
Binary files /dev/null and b/res/drawable/card403.png differ
diff --git a/res/drawable/card404.png b/res/drawable/card404.png
new file mode 100644
index 0000000..75a96aa
Binary files /dev/null and b/res/drawable/card404.png differ
diff --git a/res/drawable/card405.png b/res/drawable/card405.png
new file mode 100644
index 0000000..5e499ef
Binary files /dev/null and b/res/drawable/card405.png differ
diff --git a/res/drawable/card406.png b/res/drawable/card406.png
new file mode 100644
index 0000000..59d1e14
Binary files /dev/null and b/res/drawable/card406.png differ
diff --git a/res/drawable/card407.png b/res/drawable/card407.png
new file mode 100644
index 0000000..4100392
Binary files /dev/null and b/res/drawable/card407.png differ
diff --git a/res/drawable/card408.png b/res/drawable/card408.png
new file mode 100644
index 0000000..10412e5
Binary files /dev/null and b/res/drawable/card408.png differ
diff --git a/res/drawable/card409.png b/res/drawable/card409.png
new file mode 100644
index 0000000..3a07351
Binary files /dev/null and b/res/drawable/card409.png differ
diff --git a/res/drawable/card410.png b/res/drawable/card410.png
new file mode 100644
index 0000000..a906a55
Binary files /dev/null and b/res/drawable/card410.png differ
diff --git a/res/drawable/card411.png b/res/drawable/card411.png
new file mode 100644
index 0000000..f805615
Binary files /dev/null and b/res/drawable/card411.png differ
diff --git a/res/drawable/card412.png b/res/drawable/card412.png
new file mode 100644
index 0000000..53384f0
Binary files /dev/null and b/res/drawable/card412.png differ
diff --git a/res/drawable/card413.png b/res/drawable/card413.png
new file mode 100644
index 0000000..6399a58
Binary files /dev/null and b/res/drawable/card413.png differ
diff --git a/res/drawable/card414.png b/res/drawable/card414.png
new file mode 100644
index 0000000..f3fe889
Binary files /dev/null and b/res/drawable/card414.png differ
diff --git a/res/drawable/card_back.png b/res/drawable/card_back.png
new file mode 100644
index 0000000..4ee826e
Binary files /dev/null and b/res/drawable/card_back.png differ
diff --git a/res/drawable/play_button_down.png b/res/drawable/play_button_down.png
new file mode 100644
index 0000000..8a76016
Binary files /dev/null and b/res/drawable/play_button_down.png differ
diff --git a/res/drawable/play_button_up.png b/res/drawable/play_button_up.png
new file mode 100644
index 0000000..5fedc69
Binary files /dev/null and b/res/drawable/play_button_up.png differ
diff --git a/res/drawable/settings_button_down.png b/res/drawable/settings_button_down.png
new file mode 100644
index 0000000..9425319
Binary files /dev/null and b/res/drawable/settings_button_down.png differ
diff --git a/res/drawable/settings_button_up.png b/res/drawable/settings_button_up.png
new file mode 100644
index 0000000..8e56fd7
Binary files /dev/null and b/res/drawable/settings_button_up.png differ
diff --git a/res/layout/activity_game.xml b/res/layout/activity_game.xml
new file mode 100644
index 0000000..c895222
--- /dev/null
+++ b/res/layout/activity_game.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/res/layout/activity_main.xml b/res/layout/activity_main.xml
new file mode 100644
index 0000000..731df59
--- /dev/null
+++ b/res/layout/activity_main.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
diff --git a/res/menu/game.xml b/res/menu/game.xml
new file mode 100644
index 0000000..c002028
--- /dev/null
+++ b/res/menu/game.xml
@@ -0,0 +1,9 @@
+
diff --git a/res/menu/main.xml b/res/menu/main.xml
new file mode 100644
index 0000000..c002028
--- /dev/null
+++ b/res/menu/main.xml
@@ -0,0 +1,9 @@
+
diff --git a/res/values-sw600dp/dimens.xml b/res/values-sw600dp/dimens.xml
new file mode 100644
index 0000000..44f01db
--- /dev/null
+++ b/res/values-sw600dp/dimens.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
diff --git a/res/values-sw720dp-land/dimens.xml b/res/values-sw720dp-land/dimens.xml
new file mode 100644
index 0000000..61e3fa8
--- /dev/null
+++ b/res/values-sw720dp-land/dimens.xml
@@ -0,0 +1,9 @@
+
+
+
+ 128dp
+
+
diff --git a/res/values-v11/styles.xml b/res/values-v11/styles.xml
new file mode 100644
index 0000000..12f5f13
--- /dev/null
+++ b/res/values-v11/styles.xml
@@ -0,0 +1,24 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/res/values-v14/styles.xml b/res/values-v14/styles.xml
new file mode 100644
index 0000000..a91fd03
--- /dev/null
+++ b/res/values-v14/styles.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
new file mode 100644
index 0000000..e67df0a
--- /dev/null
+++ b/res/values/attrs.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
diff --git a/res/values/colors.xml b/res/values/colors.xml
new file mode 100644
index 0000000..327c060
--- /dev/null
+++ b/res/values/colors.xml
@@ -0,0 +1,5 @@
+
+
+ #66000000
+
+
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
new file mode 100644
index 0000000..55c1e59
--- /dev/null
+++ b/res/values/dimens.xml
@@ -0,0 +1,7 @@
+
+
+
+ 16dp
+ 16dp
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..9120054
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,11 @@
+
+
+
+ Poker
+ Settings
+ Hello world!
+ GameActivity
+ Dummy Button
+ DUMMY\nCONTENT
+
+
diff --git a/res/values/styles.xml b/res/values/styles.xml
new file mode 100644
index 0000000..4d77c75
--- /dev/null
+++ b/res/values/styles.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/ecv/poker/activity/GameActivity.java b/src/ecv/poker/activity/GameActivity.java
new file mode 100644
index 0000000..949e204
--- /dev/null
+++ b/src/ecv/poker/activity/GameActivity.java
@@ -0,0 +1,21 @@
+package ecv.poker.activity;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.Window;
+import android.view.WindowManager;
+import ecv.poker.view.GameView;
+
+public class GameActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ GameView gameView = new GameView(this);
+ gameView.setKeepScreenOn(true);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ setContentView(gameView);
+ }
+}
diff --git a/src/ecv/poker/activity/TitleActivity.java b/src/ecv/poker/activity/TitleActivity.java
new file mode 100644
index 0000000..04dc667
--- /dev/null
+++ b/src/ecv/poker/activity/TitleActivity.java
@@ -0,0 +1,32 @@
+package ecv.poker.activity;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.view.Menu;
+import android.view.Window;
+import android.view.WindowManager;
+import ecv.poker.R;
+import ecv.poker.view.TitleView;
+
+public class TitleActivity extends Activity {
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ TitleView titleView = new TitleView(this);
+ titleView.setKeepScreenOn(true);
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
+ getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
+ WindowManager.LayoutParams.FLAG_FULLSCREEN);
+
+ setContentView(titleView);
+ }
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ // Inflate the menu; this adds items to the action bar if it is present.
+ getMenuInflater().inflate(R.menu.main, menu);
+ return true;
+ }
+
+}
diff --git a/src/ecv/poker/card/Card.java b/src/ecv/poker/card/Card.java
new file mode 100644
index 0000000..eeab6cd
--- /dev/null
+++ b/src/ecv/poker/card/Card.java
@@ -0,0 +1,76 @@
+package ecv.poker.card;
+
+import android.graphics.Bitmap;
+
+/**
+ * Copied from Crazy Eights
+ * With small modifications
+ * - scoreValue removed
+ * - implements comparable so hands
+ * can easily be sorted
+ * - toString for easier debugging
+ *
+ * @author Evan
+ */
+public class Card implements Comparable {
+
+ private int id;
+ private int suit;
+ private int rank;
+ private Bitmap bmp;
+
+ public Card(int newId) {
+ id = newId;
+ suit = Math.round((id/100) * 100);
+ rank = id - suit;
+ }
+
+ public void setBitmap(Bitmap newBitmap) {
+ bmp = newBitmap;
+ }
+
+ public Bitmap getBitmap() {
+ return bmp;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public int getSuit() {
+ return suit;
+ }
+
+ public int getRank() {
+ return rank;
+ }
+
+ @Override
+ public int compareTo(Card another) {
+ if(this.getRank() < another.getRank())
+ return -1;
+ else if(this.getRank() > another.getRank())
+ return 1;
+ else
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ String str = "" + rank;
+ switch(suit) {
+ case 100:
+ str += 'D';
+ break;
+ case 200:
+ str += 'C';
+ break;
+ case 300:
+ str += 'H';
+ break;
+ case 400:
+ str += 'S';
+ }
+ return str;
+ }
+}
diff --git a/src/ecv/poker/card/Deck.java b/src/ecv/poker/card/Deck.java
new file mode 100644
index 0000000..579446f
--- /dev/null
+++ b/src/ecv/poker/card/Deck.java
@@ -0,0 +1,53 @@
+package ecv.poker.card;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * List of 52 cards
+ * Some functionality taken from Crazy Eights
+ *
+ * @author Evan
+ */
+public class Deck {
+
+ private List cards = new LinkedList();
+
+ public Deck() {
+ for (int i = 0; i < 4; i++) {
+ for (int j = 102; j < 115; j++) {
+ int id = j + (i*100);
+ Card card = new Card(id);
+ cards.add(card);
+ }
+ }
+ }
+
+ /**
+ * Shuffle the deck
+ */
+ public void shuffle() {
+ Collections.shuffle(cards);
+ }
+
+ /**
+ * @return Card from top of deck
+ */
+ public Card dealCard() {
+ return cards.remove(0);
+ }
+
+ /**
+ * Bring the cards from the hand back to the deck
+ *
+ * @param myCards
+ * @param computerCards
+ * @param communityCards
+ */
+ public void returnCards(List myCards, List computerCards, List communityCards) {
+ cards.addAll(myCards);
+ cards.addAll(computerCards);
+ cards.addAll(communityCards);
+ }
+}
diff --git a/src/ecv/poker/card/Evaluator.java b/src/ecv/poker/card/Evaluator.java
new file mode 100644
index 0000000..24c871a
--- /dev/null
+++ b/src/ecv/poker/card/Evaluator.java
@@ -0,0 +1,216 @@
+package ecv.poker.card;
+
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Utility class to evaluate a player's hand.
+ * Must have at least 2 cards in hand, no more than 5.
+ * Use Hand.java's getBestCards
+ *
+ * @author Evan
+ *
+ */
+public class Evaluator {
+ public static final int HIGH_CARD = 0,
+ ONE_PAIR = 1,
+ TWO_PAIR = 2,
+ TRIPS = 3,
+ STRAIGHT = 4,
+ FLUSH = 5,
+ FULL_HOUSE = 6,
+ QUADS = 7,
+ STRAIGHT_FLUSH = 8;
+
+ /**
+ * Attempt to rank the the hand given available cards.
+ *
+ * @param playerCards
+ * @param communityCards
+ * @return a[0] = int 0-8 representing type of hand (two pair, flush, etc),
+ * and a[1] = the additional info used to compare like hands
+ */
+ public static int[] evaluateCards(List originalCards) {
+ // first sort cards in descending order
+ // highest pairs will appear first and will save search time
+ List cards = new LinkedList(originalCards);
+ Collections.sort(cards);
+ Collections.reverse(cards);
+
+ int[] returnVal = new int[2];
+ int tmp;
+
+ // check if the cards meet criteria of a hand value
+ if(0 < (tmp = getStraightFlush(cards))) {
+ returnVal[0] = STRAIGHT_FLUSH;
+ returnVal[1] = tmp;
+ } else if(0 < (tmp = getQuads(cards))) {
+ returnVal[0] = QUADS;
+ returnVal[1] = tmp;
+ } else if(0 < (tmp = getFullHouse(cards))) {
+ returnVal[0] = FULL_HOUSE;
+ returnVal[1] = tmp;
+ } else if(0 < (tmp = getFlush(cards))) {
+ returnVal[0] = FLUSH;
+ } else if(0 < (tmp = getStraight(cards))) {
+ returnVal[0] = STRAIGHT;
+ returnVal[1] = tmp;
+ } else if(0 < (tmp = getTrips(cards))) {
+ returnVal[0] = TRIPS;
+ returnVal[1] = tmp;
+ } else if(0 < (tmp = getTwoPair(cards))) {
+ returnVal[0] = TWO_PAIR;
+ returnVal[1] = tmp;
+ } else if(0 < (tmp = getPair(cards))) {
+ returnVal[0] = ONE_PAIR;
+ returnVal[1] = tmp;
+ } else {
+ returnVal[0] = HIGH_CARD;
+ returnVal[1] = cards.get(0).getRank();
+ }
+ return returnVal;
+ }
+
+ /* --------------
+ * Methods to determine the poker hand.
+ * Return an int used to compare like hands,
+ * Or zero if hand is not what it is being checked for
+ * -------------- */
+
+ // all cards have same suit
+ // return high card in hand
+ private static int getFlush(List cards) {
+ if(cards.size() == 5) {
+ int suit = cards.get(0).getSuit();
+ for(int i = 0; i < cards.size(); i++) {
+ if(cards.get(i).getSuit() != suit)
+ return 0;
+ }
+ return cards.get(0).getRank();
+
+ } else
+ return 0;
+ }
+
+ // cards are in consecutive order (hand in descending order)
+ // ace can be used as low card - A5432 is a straight
+ // returns high card in straight
+ private static int getStraight(List cards) {
+ if(cards.size() == 5) {
+ boolean isStraight = true;
+ for(int i = 1; i < cards.size() && isStraight; i++) {
+ if(cards.get(i).getRank() != cards.get(i - 1).getRank() - 1) {
+ isStraight = false;
+ // allow hand to start with A5xxx
+ if(i == 1 && cards.get(i).getRank() == 5 &&
+ cards.get(0).getRank() == 14)
+ isStraight = true;
+ }
+ }
+ if(isStraight)
+ return cards.get(0).getRank();
+ }
+ return 0;
+ }
+
+ // hand is a flush and a straight
+ // return highest card in hand
+ private static int getStraightFlush(List cards) {
+ int straight = getStraight(cards);
+ if(getFlush(cards) > 0 && straight > 0)
+ return straight;
+ else
+ return 0;
+ }
+
+ // return rank of four of a kind
+ private static int getQuads(List cards) {
+ if(cards.size() >= 4) {
+ // compare first 2 cards to next 3
+ for(int i = 0; i < 2; i++) {
+ boolean isQuads = true;
+ for(int j = i+1; j < i+4; j++) {
+ if(cards.get(i).getRank() != cards.get(j).getRank())
+ isQuads = false;
+ }
+ if(isQuads)
+ return cards.get(i).getRank();
+ }
+ }
+ return 0;
+ }
+
+ // return rank of three of a kind
+ private static int getTrips(List cards) {
+ if(cards.size() >= 3) {
+ // compare first 3 cards to next 2
+ for(int i = 0; i < cards.size() - 2; i++) {
+ boolean isTrips = true;
+ for(int j = i + 1; j < i + 3; j++) {
+ if(cards.get(i).getRank() != cards.get(j).getRank())
+ isTrips = false;
+ }
+ if(isTrips)
+ return cards.get(i).getRank();
+ }
+ }
+ return 0;
+ }
+
+ // return rank of pair
+ private static int getPair(List cards) {
+ for(int i = 1; i < cards.size(); i++) {
+ if(cards.get(i-1).getRank() == cards.get(i).getRank())
+ return cards.get(i).getRank();
+ }
+ return 0;
+ }
+
+ // get one pair and check for another
+ // return int:
+ // 1000s and 100s = high pair value
+ // 10s and 1s = low pair value
+ private static int getTwoPair(List cards) {
+ if(cards.size() >= 4) {
+ int highPair = getPair(cards);
+ if(highPair > 0) {
+ // can ignore the first 2 cards (would be highPair)
+ for(int i = 3; i < cards.size(); i++) {
+ if(cards.get(i-1).getRank() == cards.get(i).getRank()
+ && cards.get(i).getRank() != highPair) {
+ int value = highPair * 100;
+ value += cards.get(i).getRank();
+ return value;
+ }
+ }
+ }
+ }
+ return 0;
+ }
+
+ // trips and pair (different)
+ // return int:
+ // 1000s and 100s = trip value
+ // 10s and 1s = pair value
+ private static int getFullHouse(List cards) {
+ if(cards.size() == 5) {
+ int trips = getTrips(cards);
+ if(trips > 0) {
+ int value = trips * 100;
+ // find another pair
+ boolean pairFound = false;
+ for(int i = 1; i < cards.size() && !pairFound; i++) {
+ if(cards.get(i-1).getRank() == cards.get(i).getRank() &&
+ cards.get(i).getRank() != trips) {
+ value += cards.get(i).getRank();
+ pairFound = true;
+ }
+ }
+ if(pairFound)
+ return value;
+ }
+ }
+ return 0;
+ }
+}
diff --git a/src/ecv/poker/card/Hand.java b/src/ecv/poker/card/Hand.java
new file mode 100644
index 0000000..7ae49a1
--- /dev/null
+++ b/src/ecv/poker/card/Hand.java
@@ -0,0 +1,117 @@
+package ecv.poker.card;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * A Player's hand is made of 2 cards,
+ * And has up to 5 community cards available to use.
+ * Hands are compared by traditional poker rules.
+ *
+ * This class holds a list of cards,
+ * and allows two hands to be compared.
+ *
+ * @author Evan
+ */
+public class Hand implements Comparable{
+
+ private List myCards;
+ private List communityCards; // reference to community cards for game
+
+ public Hand(List community) {
+ myCards = new LinkedList();
+ communityCards = community;
+ }
+
+ public List getCards() {
+ return myCards;
+ }
+
+ public Card get(int i) {
+ return myCards.get(i);
+ }
+
+ /**
+ * Add a card to the player's hand
+ * @param card
+ */
+ public void add(Card card) {
+ myCards.add(card);
+ }
+
+ /**
+ * Remove the player's cards
+ */
+ public void clear() {
+ myCards.clear();
+ }
+
+ /**
+ * If the hand is made of more than 5 cards,
+ * The best hand must be found
+ *
+ * @return List of up to 5 cards with greatest value
+ */
+ public List getBestCards() {
+ LinkedList allCards = new LinkedList();
+ allCards.addAll(communityCards);
+ allCards.addAll(myCards);
+ LinkedList bestCards = new LinkedList(allCards);
+
+ // make a 5 card hand by removing all combinations of 2 cards
+ if(allCards.size() > 5) {
+ // remove a card from hand to evaluate 5 card hand
+ for(int i = 0; i < 6; i++) {
+ Card removedCard1 = allCards.remove(0);
+ // evaluating 7 cards...need to remove another card
+ if(allCards.size() > 5) {
+ for(int j = i; j < 7; j++) {
+ Card removedCard2 = allCards.remove(0);
+ if(compareCardLists(allCards, bestCards) >= 0)
+ bestCards = new LinkedList(allCards);
+ allCards.add(removedCard2);
+ }
+ } else if(compareCardLists(allCards, bestCards) >= 0) {
+ bestCards = new LinkedList(allCards);
+ }
+ allCards.add(removedCard1); // put card back at end of list
+ }
+ }
+ return bestCards;
+ }
+
+ private static int compareCardLists(List one, List two) {
+ int[] thisRank = Evaluator.evaluateCards(one);
+ int[] thatRank = Evaluator.evaluateCards(two);
+
+ if(thisRank[0] < thatRank[0])
+ return -1;
+ else if(thisRank[0] > thatRank[0])
+ return 1;
+ // both hands are the same type. need to compare further
+ else {
+ if(thisRank[1] < thatRank[1])
+ return -1;
+ else if(thisRank[1] > thatRank[1])
+ return 1;
+ // same pair, trips, kicker, etc. need to find next highest card
+ else {
+ for(int i = 0; i < one.size(); i++) {
+ int thisCardRank = one.get(i).getRank();
+ int thatCardRank = two.get(i).getRank();
+ if(thisCardRank < thatCardRank)
+ return -1;
+ else if(thisCardRank > thatCardRank)
+ return 1;
+ }
+ }
+ }
+ // fell through and hands are equivalent
+ return 0;
+ }
+
+ @Override
+ public int compareTo(Hand another) {
+ return compareCardLists(this.getBestCards(), another.getBestCards());
+ }
+}
diff --git a/src/ecv/poker/card/Table.java b/src/ecv/poker/card/Table.java
new file mode 100644
index 0000000..f46bfad
--- /dev/null
+++ b/src/ecv/poker/card/Table.java
@@ -0,0 +1,45 @@
+package ecv.poker.card;
+
+import java.util.LinkedList;
+import java.util.List;
+
+import ecv.poker.player.Player;
+
+/**
+ * A representation of where a game of poker takes place.
+ * A table has a deck of cards, community cards used in the game,
+ * And two players.
+ *
+ * Unsure of what package to keep this in...really only acts as a container
+ *
+ * @author Evan
+ */
+public class Table {
+ private Deck deck;
+ private Player user, computer;
+ private List communityCards;
+
+ public Table() {
+ deck = new Deck();
+ communityCards = new LinkedList();
+ user = new Player(this);
+ computer = new Player(this);
+ }
+
+ public Deck getDeck() {
+ return deck;
+ }
+
+ public Player getUser() {
+ return user;
+ }
+
+ public Player getComputer() {
+ return computer;
+ }
+
+ public List getCommunityCards() {
+ return communityCards;
+ }
+
+}
diff --git a/src/ecv/poker/player/Player.java b/src/ecv/poker/player/Player.java
new file mode 100644
index 0000000..dc0d480
--- /dev/null
+++ b/src/ecv/poker/player/Player.java
@@ -0,0 +1,41 @@
+package ecv.poker.player;
+
+import ecv.poker.card.Card;
+import ecv.poker.card.Hand;
+import ecv.poker.card.Table;
+
+public class Player {
+ private int chips;
+ private Hand hand;
+
+ public Player(Table table) {
+ chips = 1000; // or some default number?
+ hand = new Hand(table.getCommunityCards());
+ }
+
+ /**
+ * @return Number of chips player has left to play with
+ */
+ public int getChips() {
+ return chips;
+ }
+
+ /**
+ * @param i number of chips to be added or deducted from player
+ */
+ public void addChips(int i) {
+ chips += i;
+ }
+
+ public Hand getHand() {
+ return hand;
+ }
+
+ /**
+ * Add a card dealt from the deck
+ * @param card
+ */
+ public void drawCard(Card card) {
+ hand.add(card);
+ }
+}
diff --git a/src/ecv/poker/test/Tester.java b/src/ecv/poker/test/Tester.java
new file mode 100644
index 0000000..48205d9
--- /dev/null
+++ b/src/ecv/poker/test/Tester.java
@@ -0,0 +1,63 @@
+package ecv.poker.test;
+
+import java.util.List;
+
+import android.util.Log;
+import ecv.poker.card.Card;
+import ecv.poker.card.Evaluator;
+import ecv.poker.card.Table;
+import ecv.poker.player.Player;
+
+/**
+ * Essentially a test suit
+ * Since it was a pain testing if methods for
+ * ranking hands worked....
+ *
+ * @author Evan
+ */
+public class Tester {
+
+ private static Table table = new Table();
+ private static Player player = new Player(table);
+
+ // run tests to check hands for expected values
+ public static void testEvaluations() {
+
+ int[] cardIds = new int[]{ 114, 102, 103, 104, 105, 106, 107 };
+ testHand(cardIds, Evaluator.STRAIGHT_FLUSH);
+
+ cardIds = new int[]{ 110, 102, 210, 104, 310, 106, 410};
+ testHand(cardIds, Evaluator.QUADS);
+
+ cardIds = new int[]{ 110, 102, 210, 104, 310, 102, 404};
+ testHand(cardIds, Evaluator.FULL_HOUSE);
+
+ cardIds = new int[]{ 313, 310, 302, 306, 311, 114, 308};
+ testHand(cardIds, Evaluator.FLUSH);
+
+ cardIds = new int[]{ 113, 210, 302, 306, 311, 114, 312};
+ testHand(cardIds, Evaluator.STRAIGHT);
+
+ cardIds = new int[]{ 202, 310, 302, 306, 311, 102, 208};
+ testHand(cardIds, Evaluator.TRIPS);
+
+ cardIds = new int[]{ 202, 310, 302, 306, 311, 110, 208};
+ testHand(cardIds, Evaluator.TWO_PAIR);
+
+ cardIds = new int[]{ 202, 310, 307, 306, 311, 103, 210};
+ testHand(cardIds, Evaluator.ONE_PAIR);
+
+ cardIds = new int[]{ 202, 303, 404, 106, 307, 109, 208};
+ testHand(cardIds, Evaluator.HIGH_CARD);
+ }
+
+ private static void testHand(int[] cardIds, int expectedValue) {
+ for(int i = 0; i < cardIds.length; i++) {
+ player.drawCard(new Card(cardIds[i]));
+ }
+ List cards = player.getHand().getBestCards();
+ int[] val = Evaluator.evaluateCards(cards);
+ Log.d("MyApp", (expectedValue == val[0]) + " " + val[0] + "," + val[1]);
+ player.getHand().clear();
+ }
+}
diff --git a/src/ecv/poker/view/GameView.java b/src/ecv/poker/view/GameView.java
new file mode 100644
index 0000000..3d54fad
--- /dev/null
+++ b/src/ecv/poker/view/GameView.java
@@ -0,0 +1,51 @@
+package ecv.poker.view;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.view.MotionEvent;
+import android.view.View;
+
+public class GameView extends View {
+
+ private Paint redPaint;
+ private int circleX, circleY;
+ private float radius;
+
+ public GameView(Context context) {
+ super(context);
+ redPaint = new Paint();
+ redPaint.setAntiAlias(true);
+ redPaint.setColor(Color.RED);
+ circleX = circleY = 100;
+ radius = 30;
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ canvas.drawCircle(circleX, circleY, radius, redPaint);
+ }
+
+ public boolean onTouchEvent(MotionEvent evt) {
+ int action = evt.getAction();
+ int x = (int) evt.getX();
+ int y = (int) evt.getY();
+
+ switch(action) {
+ case MotionEvent.ACTION_DOWN:
+ circleX = x;
+ circleY = y;
+ break;
+ case MotionEvent.ACTION_MOVE:
+ circleX = x;
+ circleY = y;
+ break;
+ case MotionEvent.ACTION_UP:
+ break;
+ }
+
+ invalidate();
+ return true;
+ }
+}
diff --git a/src/ecv/poker/view/TitleView.java b/src/ecv/poker/view/TitleView.java
new file mode 100644
index 0000000..829f077
--- /dev/null
+++ b/src/ecv/poker/view/TitleView.java
@@ -0,0 +1,127 @@
+package ecv.poker.view;
+
+import ecv.poker.activity.GameActivity;
+import ecv.poker.test.Tester;
+import ecv.poker.R;
+import android.content.Context;
+import android.content.Intent;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+import android.graphics.Canvas;
+import android.view.MotionEvent;
+import android.view.View;
+
+public class TitleView extends View {
+
+ private Context context;
+ private Bitmap titleGraphic,
+ playButtonUp,
+ playButtonDown,
+ settingsButtonUp,
+ settingsButtonDown;
+ private int screenW, screenH;
+ private int playButtonX, playButtonY,
+ settingsButtonX, settingsButtonY;
+ private boolean playButtonPressed,
+ settingsButtonPressed;
+
+ public TitleView(Context context) {
+ super(context);
+ this.context = context;
+ titleGraphic = BitmapFactory.decodeResource(getResources(),
+ R.drawable.aces);
+ playButtonDown = BitmapFactory.decodeResource(getResources(),
+ R.drawable.play_button_down);
+ playButtonUp = BitmapFactory.decodeResource(getResources(),
+ R.drawable.play_button_up);
+ settingsButtonDown = BitmapFactory.decodeResource(getResources(),
+ R.drawable.settings_button_down);
+ settingsButtonUp = BitmapFactory.decodeResource(getResources(),
+ R.drawable.settings_button_up);
+ }
+
+ @Override
+ public void onSizeChanged(int w, int h, int oldW, int oldH) {
+ super.onSizeChanged(w, h, oldW, oldH);
+ screenH = h;
+ screenW = w;
+
+ // scale the title graphic for portrait/landscape - fill either width/height
+ if(screenW < screenH) {
+ float heightRatio = (float) titleGraphic.getHeight() / titleGraphic.getWidth();
+ int newHeight = (int) (screenW * heightRatio);
+ titleGraphic = Bitmap.createScaledBitmap(titleGraphic,
+ screenW, newHeight, false);
+ } else {
+ float widthRatio = (float) titleGraphic.getWidth() / titleGraphic.getHeight();
+ int newWidth = (int) (screenH * widthRatio);
+ titleGraphic = Bitmap.createScaledBitmap(titleGraphic,
+ newWidth, screenH, false);
+ }
+
+ // set the position of the play button
+ playButtonX = (screenW - playButtonUp.getWidth()) / 2;
+ if(screenH > screenW)
+ playButtonY = (int) (screenH * 0.7);
+ else
+ playButtonY = screenH - 2 * playButtonUp.getHeight() - 20; // button heights + padding
+ // set position of settings button - below play button
+ settingsButtonX = playButtonX;
+ settingsButtonY = playButtonY + playButtonUp.getHeight() + 10; // 10px padding;
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ // draw the title image centered on screen
+ int titleX = (screenW - titleGraphic.getWidth()) / 2;
+ canvas.drawBitmap(titleGraphic, titleX, 0, null);
+
+ if(playButtonPressed)
+ canvas.drawBitmap(playButtonDown, playButtonX, playButtonY, null);
+ else
+ canvas.drawBitmap(playButtonUp, playButtonX, playButtonY, null);
+
+ if(settingsButtonPressed)
+ canvas.drawBitmap(settingsButtonDown, settingsButtonX, settingsButtonY, null);
+ else
+ canvas.drawBitmap(settingsButtonUp, settingsButtonX, settingsButtonY, null);
+ }
+
+ @Override
+ public boolean onTouchEvent(MotionEvent evt) {
+ int action = evt.getAction();
+ int x = (int) evt.getX();
+ int y = (int) evt.getY();
+
+ switch(action) {
+ case MotionEvent.ACTION_DOWN:
+ // C.D. for play button
+ if(x > playButtonX && x < playButtonX + playButtonUp.getWidth()
+ && y > playButtonY && y < playButtonY + playButtonUp.getHeight()) {
+ playButtonPressed = true;
+ }
+ // C.D. for settings button
+ else if(x > settingsButtonX && x < settingsButtonX + settingsButtonUp.getWidth()
+ && y > settingsButtonY && y < settingsButtonY + settingsButtonUp.getHeight()) {
+ settingsButtonPressed = true;
+ }
+ break;
+ case MotionEvent.ACTION_MOVE:
+ break;
+ case MotionEvent.ACTION_UP:
+ if(playButtonPressed) {
+ Intent gameIntent = new Intent(context, GameActivity.class);
+ context.startActivity(gameIntent);
+ playButtonPressed = false;
+ }
+ else if(settingsButtonPressed) {
+ // do something here
+ Tester.testEvaluations();
+ settingsButtonPressed = false;
+ }
+ break;
+ }
+ invalidate();
+ return true;
+ }
+}