summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle K <kylek389@gmail.com>2011-02-01 17:31:14 -0600
committerKamil Kaminski <kamilkss@gmail.com>2011-02-01 17:31:14 -0600
commit6c30258da6449f9ffae4b42f4aeda587fe4a3111 (patch)
tree37cf8d9492c95f308d9ba80c77d55d4b8625f6b8
parent97290be5e03ba2299de0e0988404fb4979852b5c (diff)
downloadpoker-6c30258da6449f9ffae4b42f4aeda587fe4a3111.tar.gz
poker-6c30258da6449f9ffae4b42f4aeda587fe4a3111.tar.bz2
poker-6c30258da6449f9ffae4b42f4aeda587fe4a3111.zip
try putting multiple cards to the left using bubble sort
-rw-r--r--Makefile5
-rw-r--r--game.cpp8
-rw-r--r--game.h3
-rw-r--r--sorthand.cpp59
-rw-r--r--sorthand.h20
5 files changed, 2 insertions, 93 deletions
diff --git a/Makefile b/Makefile
index 6a63de7..468cd4c 100644
--- a/Makefile
+++ b/Makefile
@@ -7,7 +7,7 @@
# Makefile
PROG = poker
-OBJS = main.o cardpile.o card.o game.o user.o opponent.o sorthand.o
+OBJS = main.o cardpile.o card.o game.o user.o opponent.o
CC = g++
DBGFLAGS = -g -O0
ifdef DEBUG
@@ -38,9 +38,6 @@ user.o: %.o: %.cpp %.h
opponent.o: %.o: %.cpp %.h
$(CC) -c $(CFLAGS) $<
-sorthand.o: %.o: %.cpp %.h
- $(CC) -c $(CFLAGS) $<
-
.PHONY: clean
clean:
diff --git a/game.cpp b/game.cpp
index fd9806e..6f8931b 100644
--- a/game.cpp
+++ b/game.cpp
@@ -837,16 +837,11 @@ void Game::evaluateHand(Card **cards, int who)
/* four of a kind */
else if (tmp2.count == 4)
- {
whatHand = 2;
- sortFourOfAKind(cards, &tmp2);
- }
/* full house */
else if ((tmp2.count == 3) && hasFullHouse(cards, &tmp2))
- {
whatHand = 3;
- }
/* flush */
else if (tmp.count == 5)
@@ -858,10 +853,7 @@ void Game::evaluateHand(Card **cards, int who)
/* three of a kind */
else if (tmp2.count == 3)
- {
whatHand = 6;
- sortThreeOfAKind(cards, &tmp2);
- }
/* two pair */
else if (hasTwoPairs(cards))
diff --git a/game.h b/game.h
index 0ac8a66..0e4d7f7 100644
--- a/game.h
+++ b/game.h
@@ -11,13 +11,12 @@
#include "cardpile.h"
#include "user.h"
#include "opponent.h"
-#include "sorthand.h"
using std::cout;
using std::endl;
using std::cin;
-class Game : virtual public CardPile, public User, public Opponent, public SortHand
+class Game : virtual public CardPile, public User, public Opponent
{
private:
diff --git a/sorthand.cpp b/sorthand.cpp
deleted file mode 100644
index e713b7d..0000000
--- a/sorthand.cpp
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * sorthand.cpp
- *
- *
- */
-
-#include "sorthand.h"
-
-SortHand::SortHand()
-{
-
-}
-
-void SortHand::sortFourOfAKind(Card **cards, struct countAndType *maxCount)
-{
-#if 0
- int i;
- /* find the card that is different from other four */
- for (i = 0; i < 5; i++)
- if (cards[i]->getType()[0] != maxCount->type)
- break;
-#endif
-
- int k;
- for (k = 0; k < 5; k++)
- if (cards[k]->getType()[0] == maxCount->type)
- {
- cards[k]->specialRank();
-#ifdef DEBUG
- cout << ANSI_COLOR_CYAN << "\ndebug: sortFourOfAKind(): "
- << cards[k]->getType() << " at cards[" << k
- << "] gets special rank "<< endl << ANSI_COLOR_RESET;
-#endif
- }
-}
-
-void SortHand::sortThreeOfAKind(Card **cards, struct countAndType *threeCount)
-{
- int i;
- /* find 2 cards that are different from other three */
- for (i = 0; i < 5; i++)
- if (cards[i]->getType()[0] != threeCount->type)
- break;
-
- int j;
- for (j = 0; j < 5; j++)
- if ((cards[j]->getType()[0] != threeCount->type) && (i != j))
- break;
-
-#ifdef DEBUG
- cout << ANSI_COLOR_CYAN << "\ndebug: sortThreeOfAKind(): card " << cards[i]->getType()
- << " and " << cards[j]->getType() << " are different from other 3 cards"
- << endl << ANSI_COLOR_RESET;
-#endif
-
- cards[i]->specialRank();
- cards[j]->specialRank();
-}
-
diff --git a/sorthand.h b/sorthand.h
deleted file mode 100644
index 6d5c288..0000000
--- a/sorthand.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef _SORTHAND_H_
-#define _SORTHAND_H_
-
-#include "cardpile.h"
-
-class SortHand : virtual public CardPile
-{
- private:
-
- protected:
-
- public:
- SortHand(void);
-
- void sortFourOfAKind(Card **, struct countAndType *);
- void sortThreeOfAKind(Card **, struct countAndType *);
-};
-
-#endif
-