diff options
-rw-r--r-- | Makefile | 5 | ||||
-rw-r--r-- | game.cpp | 8 | ||||
-rw-r--r-- | game.h | 3 | ||||
-rw-r--r-- | sorthand.cpp | 59 | ||||
-rw-r--r-- | sorthand.h | 20 |
5 files changed, 2 insertions, 93 deletions
@@ -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: @@ -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)) @@ -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 - |