Commit d89cd354 authored by Stephan Kulow's avatar Stephan Kulow

adapt to KDE4 API

svn path=/trunk/KDE/kdegames/lskat/; revision=533360
parent 63a241ff
......@@ -74,7 +74,7 @@ CardSprite* AbstractDisplay::createSprite(int no)
{
if (!mDeck)
{
kdFatal() << "createSprite::No deck set " << endl;
kFatal() << "createSprite::No deck set " << endl;
return (CardSprite*)0;
}
......@@ -109,7 +109,7 @@ void AbstractDisplay::updateSpriteGraphics()
{
if (!mDeck)
{
kdFatal() << "updateSpriteGraphics::No deck set " << endl;
kFatal() << "updateSpriteGraphics::No deck set " << endl;
return;
}
QHashIterator<int,CardSprite*> it(mCards);
......
......@@ -39,7 +39,7 @@ AiInput::AiInput(EngineTwo* engine, QString dir, QObject* parent)
mInputIcon = new QPixmap();
if (!mInputIcon->load(filename))
{
kdError() << "Cannot load file " << filename << endl;
kError() << "Cannot load file " << filename << endl;
}
// Store engine
......@@ -60,13 +60,13 @@ void AiInput::aiTurn()
// Turn was stopped meanwhile
if (!mInputAllowed) return;
kdDebug() << "==================================================="<<endl;
kdDebug() << "AI TURN START " <<mInputAllowed<< endl;
kDebug() << "==================================================="<<endl;
kDebug() << "AI TURN START " <<mInputAllowed<< endl;
// Check we are the right player
if (mId != mEngine->currentPlayer())
{
kdFatal() << "AI plays for wrong player " << endl;
kFatal() << "AI plays for wrong player " << endl;
return;
}
......@@ -77,21 +77,21 @@ void AiInput::aiTurn()
// Initiate move
if (mEngine->currentMovePhase() == EngineTwo::FirstPlayerTurn)
{
kdDebug() << "Performing initiual move "<<mId << endl;
kDebug() << "Performing initiual move "<<mId << endl;
move = initiateMove(mId, board);
}
// Respond to move
else
{
kdDebug() << "Performing answer move "<<mId << endl;
kDebug() << "Performing answer move "<<mId << endl;
move = answerMove(mId, board);
}
// Send out move
kdDebug() << "AI player " << mId << " moves to " << move.move << endl;
kDebug() << "AI player " << mId << " moves to " << move.move << endl;
if (move.move>=0) emit signalPlayerInput(mId, mId, move.move);
else kdError() << "Illegal AI Move ??? " << endl;
else kError() << "Illegal AI Move ??? " << endl;
}
......@@ -164,11 +164,11 @@ AiInput::Move AiInput::initiateMove(int p, const AiInput::Board& board)
if (card < 0) continue; // Illegal move
// Store move
current.playedCard = card;
kdDebug() << "First mover try move on " << m << " ("<<Deck::name(card) <<endl;
kDebug() << "First mover try move on " << m << " ("<<Deck::name(card) <<endl;
AiInput::Move answer = answerMove(1-p, current);
// Negate answering moves value to get our rating
double rating = -answer.value;
kdDebug() << "First mover yields rating of " << rating << endl;
kDebug() << "First mover yields rating of " << rating << endl;
// New best move?
if (rating > maxMove.value)
{
......@@ -191,7 +191,7 @@ AiInput::Move AiInput::answerMove(int p, const AiInput::Board& board)
for (int m=0; m<8; m++)
{
AiInput::Board current(board);
// kdDebug() << "CARD "<<m<< " is "
// kDebug() << "CARD "<<m<< " is "
// << Deck::name(current.cards[p][m]) << " on top of "
// << Deck::name(current.cards[p][m+8]) << endl;
......@@ -209,7 +209,7 @@ AiInput::Move AiInput::answerMove(int p, const AiInput::Board& board)
// Check move winner
int winner = mEngine->whoWonMove(current.playedCard, card);
kdDebug() << " Card " << m<< " (" << Deck::name(card) << ") is valid "
kDebug() << " Card " << m<< " (" << Deck::name(card) << ") is valid "
<< " countering " << Deck::name(current.playedCard)<<" with "
<< " winner (0:other, 1:we) " << winner << endl;
int deltaPoints = 0;
......@@ -229,7 +229,7 @@ AiInput::Move AiInput::answerMove(int p, const AiInput::Board& board)
double rating = evaluteGame(p, current);
kdDebug() << " Points after 2nd move "<<m<<" would be we: "
kDebug() << " Points after 2nd move "<<m<<" would be we: "
<< current.points[p] << " other: " << current.points[1-p]
<< " rating is thus " << rating << endl;
// New best move?
......
......@@ -210,7 +210,7 @@ void CardSprite::advance(int phase)
{
mAnimationCnt--;
if (mAnimationState == 0)
kdDebug() << "Start moving sprite " << this << endl;
kDebug() << "Start moving sprite " << this << endl;
}
// Then move to target position
else
......
......@@ -85,11 +85,11 @@ QPixmap* Deck::cardPixmap(int no)
// Load the card backside from a given file
bool Deck::loadCardBackside(QString filename)
{
kdDebug() << "Loading backside image " << filename << endl;
kDebug() << "Loading backside image " << filename << endl;
QPixmap* pm = new QPixmap();
if (!pm->load(filename))
{
kdError() << "Cannot load file " << filename << endl;
kError() << "Cannot load file " << filename << endl;
return false;
}
if (mCardBackside) delete mCardBackside;
......@@ -100,7 +100,7 @@ bool Deck::loadCardBackside(QString filename)
// Load the trump icons from a directory
bool Deck::loadTrump(QString dir)
{
kdDebug() << "Loading trump images " << dir << endl;
kDebug() << "Loading trump images " << dir << endl;
mTrumpIcons.clear();
for (int i=0;i<5;i++)
......@@ -109,7 +109,7 @@ bool Deck::loadTrump(QString dir)
QString file = dir+"/"+QString("t%1.png").arg(i);
if (!pm->load(file))
{
kdError() << "Cannot load file " << file << endl;
kError() << "Cannot load file " << file << endl;
return false;
}
if (mTrumpIcons.contains((Suite)i)) delete mTrumpIcons[(Suite)i];
......@@ -137,12 +137,12 @@ bool Deck::loadCards(QString cardPath)
for (int i=0;i<NUMBER_OF_CARDS;i++)
{
QString filename = cardPath+"/"+QString("%1.png").arg(i+1);
//kdDebug() << "Loading image " << filename << endl;
//kDebug() << "Loading image " << filename << endl;
QPixmap* pm = new QPixmap();
if (!pm->load(filename))
{
mCardPixmaps.clear();
kdError() << "Cannot load file " << filename << endl;
kError() << "Cannot load file " << filename << endl;
maxCardSize = QSize(0,0);
return false;
}
......@@ -205,7 +205,7 @@ int Deck::drawCard()
{
if (mCards.size() < 1)
{
kdFatal() << "No more cards to draw from card deck " << endl;
kFatal() << "No more cards to draw from card deck " << endl;
}
int card = mCards.takeFirst();
return card;
......
......@@ -89,7 +89,7 @@ DisplayTwo::DisplayTwo(QString grafixDir, Deck* deck, Q3Canvas* canvas, QObject*
mMovePixmap = new QPixmap();
if (!mMovePixmap->load(filename))
{
kdError() << "Cannot load file " << filename << endl;
kError() << "Cannot load file " << filename << endl;
}
}
......@@ -154,12 +154,12 @@ void DisplayTwo::deal(Player* player, int position)
{
if (position != 0 && position != 1)
{
kdFatal() << "Wrong player position " << position << endl;
kFatal() << "Wrong player position " << position << endl;
return ;
}
if (!player)
{
kdFatal() << "No player given " << endl;
kFatal() << "No player given " << endl;
return ;
}
......@@ -281,7 +281,7 @@ CardSprite* DisplayTwo::getCardSprite(int cardValue)
CardSprite* sprite = mCards[cardValue];
if (!sprite)
{
kdFatal() << "Could not find cardsprite for card value " << cardValue
kFatal() << "Could not find cardsprite for card value " << cardValue
<< " Stored are " << mCards.size() << " sprites "
<< endl;
return 0;
......@@ -407,6 +407,6 @@ void DisplayTwo::showMove(int no)
sprite->hide();
}
kdDebug() << "Display start sprite to " << no << endl;
kDebug() << "Display start sprite to " << no << endl;
if (no>=0) mMoveSprites[no]->show();
}
......@@ -56,11 +56,11 @@ void EngineTwo::gameLoopStart()
// Here: inputId == playerNumber
void EngineTwo::playerInput(int inputId, int playerNumber, int cardNumber)
{
kdDebug() << "Engine got player input: card= " << cardNumber
kDebug() << "Engine got player input: card= " << cardNumber
<< " Player= " << playerNumber << " Id=" << inputId << endl;
if (playerNumber != mCurrentPlayer)
{
kdDebug() << "EngineTwo::playerInput: Input from wrong player" << endl;
kDebug() << "EngineTwo::playerInput: Input from wrong player" << endl;
return;
}
......@@ -79,7 +79,7 @@ void EngineTwo::playerInput(int inputId, int playerNumber, int cardNumber)
// Check whether player still has this card
if (card < 0)
{
kdDebug() << "EngineTwo::playerInput: Card " << cardNumber + 8*height
kDebug() << "EngineTwo::playerInput: Card " << cardNumber + 8*height
<< " not available anymore "<< endl;
return;
}
......@@ -87,7 +87,7 @@ void EngineTwo::playerInput(int inputId, int playerNumber, int cardNumber)
// TODO: Remove this, Debug current card
Suite suite = mDeck->getSuite(card);
CardType type = mDeck->getCardType(card);
kdDebug() << "Gameloop "<<mCurrentPlayer <<" plays " << mDeck->name(suite, type) << endl;
kDebug() << "Gameloop "<<mCurrentPlayer <<" plays " << mDeck->name(suite, type) << endl;
......@@ -97,7 +97,7 @@ void EngineTwo::playerInput(int inputId, int playerNumber, int cardNumber)
// Check (card of player 1), (card of player 2), (player 2)
if (!isLegalMove(mCurrentMoveCards[FirstPlayerTurn], card, playerNumber))
{
kdDebug() << "EngineTwo::playerInput: Card " << cardNumber + 8*height
kDebug() << "EngineTwo::playerInput: Card " << cardNumber + 8*height
<< " is not a valid move "<< endl;
return;
}
......@@ -169,9 +169,9 @@ void EngineTwo::gameLoopFinish()
player->addWonCard(mCurrentMoveCards[FirstPlayerTurn]);
player->addWonCard(mCurrentMoveCards[SecondPlayerTurn]);
kdDebug() << "Winner = " << winner << " current = " << mCurrentPlayer <<endl;
kdDebug() << " He has won " << player->noOfMovesWon() << " moves." << endl;
kdDebug() << " He has " << player->points() << " points." << endl;
kDebug() << "Winner = " << winner << " current = " << mCurrentPlayer <<endl;
kDebug() << " He has won " << player->noOfMovesWon() << " moves." << endl;
kDebug() << " He has " << player->points() << " points." << endl;
// Switch move phase (half moves)
mCurrentMovePhase = FirstPlayerTurn;
}
......@@ -186,7 +186,7 @@ void EngineTwo::gameLoopFinish()
// Check whether the game is over
if (gameOver())
{
kdDebug() << "GAME OVER " << endl;
kDebug() << "GAME OVER " << endl;
mGameStatus = Stopped;
mDisplay->showMove(-1);
int winner = evaluateGame();
......@@ -206,7 +206,7 @@ void EngineTwo::gameLoopFinish()
// Check whether the game is over
bool EngineTwo::gameOver()
{
kdDebug() << "Move number in game over " << mMoveNumber << endl;
kDebug() << "Move number in game over " << mMoveNumber << endl;
// Check number of moves. If all moves are done game is over.
if (mMoveNumber >= 31) return true;
return false;
......@@ -468,8 +468,8 @@ int EngineTwo::whoWonMove(int card1,int card2)
return 1;
}
if (suite1 == mTrump) kdDebug() << "FIRST card wins TRUMP" << endl;
if (suite2 == mTrump) kdDebug() << "SECOND card wins TRUMP" << endl;
if (suite1 == mTrump) kDebug() << "FIRST card wins TRUMP" << endl;
if (suite2 == mTrump) kDebug() << "SECOND card wins TRUMP" << endl;
// If cards are not of the same suite a trump wins
if (suite1 == mTrump) return 0;
......
......@@ -84,7 +84,7 @@ PlayerStatusWidget* GameView::statusWidget(int pos)
{
if (!mPlayerWidgets.contains(pos))
{
kdFatal() << "Player status widget " << pos << "does not exists" << endl;
kFatal() << "Player status widget " << pos << "does not exists" << endl;
return 0;
}
return mPlayerWidgets[pos];
......
......@@ -63,7 +63,7 @@ int main(int argc, char *argv[])
if (args->isSet("debug"))
{
// global_debug=QString(args->getOption("debug")).toInt();
// kdDebug(12010) << "Debug level set to " << global_debug << endl;
// kDebug(12010) << "Debug level set to " << global_debug << endl;
}
KApplication application(true);
......
......@@ -40,6 +40,7 @@
#include <khelpmenu.h>
#include <kcarddialog.h>
#include <krandom.h>
#include <kglobal.h>
// Application specific includes
#include "mainwindow.h"
......@@ -86,12 +87,12 @@ Mainwindow::Mainwindow(QWidget* parent)
mGrafixDir = kapp->dirs()->findResourceDir("data", file)+"lskat/grafix/";
// Debug
kdDebug() << "SRCDIR="<<SRCDIR<<endl;
kdDebug() << "GrafixDir="<<mGrafixDir << endl;
kDebug() << "SRCDIR="<<SRCDIR<<endl;
kDebug() << "GrafixDir="<<mGrafixDir << endl;
// Our config
mConfig=kapp->config();
mConfig=KGlobal::config();
// Overall view
mView = new GameView(QSize(600, 570), ADVANCE_PERDIOD, this);
......@@ -117,7 +118,7 @@ Mainwindow::Mainwindow(QWidget* parent)
// Get the card deck
long seed = KRandom::random();
kdDebug() << "Random seed " << seed << endl;
kDebug() << "Random seed " << seed << endl;
mDeck = new Deck(seed, this);
mDeck->loadCards(mCardDir);
mDeck->loadCardBackside(mDeckGrafix);
......@@ -142,7 +143,7 @@ Mainwindow::~Mainwindow()
if (mLSkatConfig) delete mLSkatConfig;
if (mDeck) delete mDeck;
if (mView) delete mView;
kdDebug() << "Destructor Mainwindow" << endl;
kDebug() << "Destructor Mainwindow" << endl;
}
// Called by KMainWindow when the last window of the application is
......@@ -189,8 +190,8 @@ void Mainwindow::readProperties(KConfig* cfg)
QDir dir(mCardDir);
if (!dir.exists()) mCardDir = dcd;
kdDebug() << "set mDeckGrafix=" << mDeckGrafix << endl;
kdDebug() << "set mCardDir=" << mCardDir << endl;
kDebug() << "set mDeckGrafix=" << mDeckGrafix << endl;
kDebug() << "set mCardDir=" << mCardDir << endl;
int no = cfg->readNumEntry("startplayer", 0);
setStartPlayer(no);
......@@ -228,7 +229,7 @@ AbstractInput* Mainwindow::createInput(
}
else
{
kdFatal() << "Unpupported input device type " << inputType << endl;
kFatal() << "Unpupported input device type " << inputType << endl;
}
return input;
......@@ -270,7 +271,7 @@ void Mainwindow::startGame()
// Here a game over is signalled
void Mainwindow::gameOver(int winner)
{
kdDebug() << "GameOver:: Winner= " << winner << endl;
kDebug() << "GameOver:: Winner= " << winner << endl;
}
......@@ -354,7 +355,7 @@ void Mainwindow::initGUI()
void Mainwindow::menuStartplayer()
{
int i=((KSelectAction *)ACTION("startplayer"))->currentItem();
kdDebug() << "Set startplayer to " << i << endl;
kDebug() << "Set startplayer to " << i << endl;
setStartPlayer(i);
}
......@@ -362,7 +363,7 @@ void Mainwindow::menuStartplayer()
void Mainwindow::menuPlayer1By()
{
int i = ((KSelectAction *)ACTION("player1"))->currentItem();
kdDebug() << "Player 1 by " << i << endl;
kDebug() << "Player 1 by " << i << endl;
mLSkatConfig->setInputType(0, (InputDeviceType)i);
}
......@@ -370,7 +371,7 @@ void Mainwindow::menuPlayer1By()
void Mainwindow::menuPlayer2By()
{
int i = ((KSelectAction *)ACTION("player2"))->currentItem();
kdDebug() << "Player 2 by " << i << endl;
kDebug() << "Player 2 by " << i << endl;
mLSkatConfig->setInputType(1, (InputDeviceType)i);
}
......@@ -383,7 +384,7 @@ void Mainwindow::menuCardDeck()
result=KCardDialog::getCardDeck(s1,s2);
if (result==QDialog::Accepted)
{
kdDebug() << "Card deck to " << s1 << " and " << s2 << endl;
kDebug() << "Card deck to " << s1 << " and " << s2 << endl;
bool change = false; // Avoid unecessary changes
if (!s1.isEmpty() && s1 != mDeckGrafix)
{
......@@ -426,7 +427,7 @@ void Mainwindow::menuClearStatistics()
// Abort a game
void Mainwindow::menuEndGame()
{
kdDebug() << "EXIT" << endl;
kDebug() << "EXIT" << endl;
if (mEngine)
{
mEngine->stopGame();
......@@ -437,7 +438,7 @@ void Mainwindow::menuEndGame()
// Start a new game
void Mainwindow::menuNewLSkatGame()
{
kdDebug() << "NEW LSKAT" << endl;
kDebug() << "NEW LSKAT" << endl;
Player* p1 = mLSkatConfig->player(0);
Player* p2 = mLSkatConfig->player(1);
......@@ -488,7 +489,7 @@ void Mainwindow::menuNewLSkatGame()
// Change the player names in a dialog
void Mainwindow::menuPlayerNames()
{
kdDebug() << "Change player names" << endl;
kDebug() << "Change player names" << endl;
NameDialogWidget dlg(this);
for (int i=0;i<2;i++)
{
......@@ -513,14 +514,14 @@ void Mainwindow::menuPlayerNames()
void Mainwindow::setStartPlayer(int no)
{
mStartPlayer = no;
kdDebug() << "Set startplayer to " << mStartPlayer << endl;
kDebug() << "Set startplayer to " << mStartPlayer << endl;
((KSelectAction *)ACTION("startplayer"))->setCurrentItem(mStartPlayer);
}
// Set the input type for a given player number.
void Mainwindow::setInputType(int no, InputDeviceType type)
{
kdDebug() << "setInputType " << no << " to " << (int)type << endl;
kDebug() << "setInputType " << no << " to " << (int)type << endl;
Player* p = 0;
// Player 1
if (no == 0)
......
......@@ -36,7 +36,7 @@ MouseInput::MouseInput(QString dir, QObject* parent)
mInputIcon = new QPixmap();
if (!mInputIcon->load(filename))
{
kdError() << "Cannot load file " << filename << endl;
kError() << "Cannot load file " << filename << endl;
}
}
......@@ -53,7 +53,7 @@ void MouseInput::mousePress(QPoint point)
// Check whether the move is for the right player
if (playerNumber == mId)
{
kdDebug() << "MouseInput:: Convert to " << playerNumber << ", " << cardNumber << endl;
kDebug() << "MouseInput:: Convert to " << playerNumber << ", " << cardNumber << endl;
emit signalPlayerInput(mId, playerNumber, cardNumber);
}
}
......
......@@ -98,7 +98,7 @@ void Player::deal(int amount)
{
if (!mDeck)
{
kdFatal() << "No deck set to player." << endl;
kFatal() << "No deck set to player." << endl;
return;
}
mCards.clear();
......@@ -168,7 +168,7 @@ void Player::deleteCard(int cardPosition)
{
if (cardPosition >= mCards.size())
{
kdFatal() << "Player " << mId << " tries to delete non esxisting card position "
kFatal() << "Player " << mId << " tries to delete non esxisting card position "
<< cardPosition <<" >= " << mCards.size() << endl;
}
mCards[cardPosition] = -1;
......@@ -179,7 +179,7 @@ void Player::addCard(int cardPosition, int card)
{
if (cardPosition >= mCards.size())
{
kdFatal() << "Player " << mId << " tries to add to esxisting card position "
kFatal() << "Player " << mId << " tries to add to esxisting card position "
<< cardPosition <<" >= " << mCards.size() << endl;
}
mCards[cardPosition] = card;
......@@ -190,7 +190,7 @@ int Player::getCard(int playerNumber)
{
if (playerNumber >= mCards.size())
{
kdFatal() << "Player " << mId << " tries to get non esxisting card "
kFatal() << "Player " << mId << " tries to get non esxisting card "
<< playerNumber <<" >= " << mCards.size() << endl;
}
......@@ -226,7 +226,7 @@ int Player::getWonCard(int no)
{
if (no>=mWonCards.size())
{
kdFatal() << "Player::getWonCard This card " << no << " is not available. "
kFatal() << "Player::getWonCard This card " << no << " is not available. "
<< "Only " << mWonCards.size() << " cards stored." << endl;
return -1;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment