/* Euchre - a free as in freedom and as in beer version of the euchre card game Copyright 2002 C Nathan Buckles (nbuckles@bigfoot.com) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include "globals.hpp" #include "support.hpp" #include "ComputerGuiPlayer.hpp" ComputerGuiPlayer::ComputerGuiPlayer(Common::PlayerPosition myPos, Player* theAI) : Player(myPos), GuiPlayer(myPos), itsAI(theAI) {} ComputerGuiPlayer::~ComputerGuiPlayer() { if (itsAI != NULL) { delete itsAI; } } void ComputerGuiPlayer::setHand(const Hand& theHand) { Player::setHand(theHand); itsAI->setHand(theHand); } void ComputerGuiPlayer::setTopCard(const Card& upCard) { setCardPixmap(cardPixmaps[upCard.getNumber()][upCard.getSuit()]); } void ComputerGuiPlayer::unsetTopCard() { setCardPixmap(itsOldPixmap); } Common::Bid ComputerGuiPlayer::auction1(const Card& upCard, Common::PlayerPosition dealer) { LOG(itsPos << " enter cgp::auction1" << endl); Common::Bid ret = itsAI->auction1(upCard, dealer); if (ret != Common::PASS) { setBidSuitPixmap(bidSuitPixmaps[upCard.getSuit()]); if (ret == Common::PICKITUP) { setBidCallPixmap(bidCallPixmaps[0]); } else { setBidCallPixmap(bidCallPixmaps[1]); } LOG("going for it with " << itsHand << " value " << itsHand.getValue(upCard.getSuit()) << endl); } else { setMarker(passMarkers[itsPos]); } LOG(itsPos << " exit cgp::auction1 with " << ret << endl); return ret; } void ComputerGuiPlayer::auction1End(const Card& upCard) { setCardPixmap(itsOldPixmap); itsAI->auction1End(upCard); setMarker(NULL); } Common::Bid ComputerGuiPlayer::auction2(Card& yourTrump, const Card& upCard, bool stuck) { LOG(itsPos << " enter cgp::auction2" << endl); Common::Bid ret = itsAI->auction2(yourTrump, upCard, stuck); if (ret != Common::PASS) { setBidSuitPixmap(bidSuitPixmaps[yourTrump.getSuit()]); if (ret == Common::PICKITUP) { setBidCallPixmap(bidCallPixmaps[0]); } else { setBidCallPixmap(bidCallPixmaps[1]); } LOG("going for it with " << itsHand << " value " << itsHand.getValue(yourTrump.getSuit()) << " trump " << yourTrump.getSuit() << endl); } else { setMarker(passMarkers[itsPos]); } LOG(itsPos << " exit cgp::auction2 with " << ret << endl); return ret; } void ComputerGuiPlayer::setBid(Common::PlayerPosition who, Common::Bid bid) { itsAI->setBid(who, bid); setMarker(NULL); } void ComputerGuiPlayer::setTrump(Card::Suit trump) { LOG(itsPos << " enter cgp::setTrump" << endl); setCardPixmap(itsOldPixmap); itsAI->setTrump(trump); LOG(itsPos << " exit cgp::setTrump" << endl); } Card ComputerGuiPlayer::getCard(const Round& theRound, Common::PlayerPosition whoStarted) { LOG(itsPos << " enter cgp::getCard" << endl); LOG(" " << itsPos << " hand is " << itsAI->getHand() << endl); Card ret = itsAI->getCard(theRound, whoStarted); LOG(" " << itsPos << " cgp::getCard with " << ret << endl); setCardPixmap(cardPixmaps[ret.getNumber()][ret.getSuit()]); LOG(" " << itsPos << " hand is " << itsAI->getHand() << endl); LOG(itsPos << " exit cgp::getCard with " << ret << endl); return ret; } void ComputerGuiPlayer::finishRound(const Round& theRound, Common::PlayerPosition whoStarted) { LOG(itsPos << " enter cgp finishRound" << endl); setCardPixmap(itsOldPixmap); itsAI->finishRound(theRound, whoStarted); LOG(itsPos << " exit cgp finishRound" << endl); } void ComputerGuiPlayer::allPass() { setCardPixmap(itsOldPixmap); setMarker(NULL); itsAI->allPass(); } Card ComputerGuiPlayer::discard(Card& newCard) { return itsAI->discard(newCard); } void ComputerGuiPlayer::finishDeal(int NSPoints, int EWPoints) { itsAI->finishDeal(NSPoints, EWPoints); setBidSuitPixmap(NULL); setBidCallPixmap(NULL); }