summaryrefslogtreecommitdiff
path: root/noncore/games/oyatzee/oyatzee.cpp
Side-by-side diff
Diffstat (limited to 'noncore/games/oyatzee/oyatzee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/oyatzee/oyatzee.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/noncore/games/oyatzee/oyatzee.cpp b/noncore/games/oyatzee/oyatzee.cpp
index 86318db..a55aa73 100644
--- a/noncore/games/oyatzee/oyatzee.cpp
+++ b/noncore/games/oyatzee/oyatzee.cpp
@@ -1,128 +1,128 @@
#include "oyatzee.h"
#include <qmessagebox.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qlayout.h>
#include <stdlib.h>
OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow( parent , name , fl )
{
QWidget *thing = new QWidget( this );
setCentralWidget( thing );
setCaption( tr( "OYatzee" ) );
setPlayerNumber( 4 );
setRoundsNumber( 1 );
lastPlayerFinished = false;
currentPlayer = 1;
ps.append( new Player( "Carsten" ) );
ps.append( new Player( "Julia" ) );
ps.append( new Player( "Christine" ) );
ps.append( new Player( "Stephan" ) );
QVBoxLayout *vbox = new QVBoxLayout( thing );
sb = new Scoreboard( ps, thing , "sb" );
- connect( sb->pb , SIGNAL( item( int ) ), this , SLOT( slotEndRound( int ) ) );
+ connect( sb->pb , SIGNAL( item(int) ), this , SLOT( slotEndRound(int) ) );
dw = new DiceWidget( thing , "dw" );
dw->setMaximumHeight( this->height()/4 );
connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) );
vbox->addWidget( sb );
vbox->addWidget( dw );
}
void OYatzee::slotEndRound( int item )
{
qDebug( "Der User hat Nummer %d ausgewählt" , item );
/*
* if the user clicked on Total, Bonus or Score and thus not on a
* selectable item return and do nothing
*/
if ( item == 7 || item == 8 || item == 16 ) return;
/*
* check if the user can really click on that item
*/
if ( posibilities.find( item ) == posibilities.end() ) return;
QValueListInt numbers;
Dice *d = dw->diceList.first();
for ( ; d != 0 ; d = dw->diceList.next() )
{
numbers.append( d->hasValue() );
}
int points = 0;
switch ( item )
{
case Ones:
points = getPoints( 1 , numbers );
break;
case Twos:
points = getPoints( 2 , numbers );
break;
case Threes:
points = getPoints( 3 , numbers );
break;
case Fours:
points = getPoints( 4 , numbers );
break;
case Fives:
points = getPoints( 5 , numbers );
break;
case Sixes:
points = getPoints( 6 , numbers );
break;
case ThreeOfAKind:
points = oakPoints;
break;
case FourOfAKind:
points = oakPoints;
break;
case FullHouse:
points = 25;
break;
case SStraight:
points = 30;
break;
case LStraight:
points = 40;
break;
case Yatzee:
points = 50;
break;
case Chance:
points = getPoints ( Chance , numbers );
}
sb->nextRB(currentPlayer-1)->updateMap( item , points );
nextPlayer();
qDebug( "Punkte: %d" , points );
}
void OYatzee::nextPlayer()
{
currentPlayer++;
if ( currentPlayer > numOfPlayers )
{
currentPlayer = 1;
}
ps.at(currentPlayer-1)->turn = 0;
}
int OYatzee::getPoints( const int num , QValueListInt l)
{
@@ -553,135 +553,135 @@ void Player::setupResultList()
{
pResults.append( 0 );
}
}
/*
* TODO: muss noch genutzt werden
*/
void Player::updateTotalPoints( pointMap m )
{
pointMap::Iterator it = m.begin();
for ( ; it != m.end() ; ++it )
{
totalPoints += it.data();
}
}
void Player::setResults( const int cat , const int points )
{
QValueListInt::Iterator it = pResults.at( cat );
*it = points;
}
/*
* Board
*/
Board::Board( QWidget *parent , const char* name ) : QWidget ( parent , name )
{
}
void Board::mousePressEvent( QMouseEvent *e )
{
emit clicked( e->pos() );
}
/*
* Resultboard
*/
Resultboard::Resultboard( QString playerName , QWidget *parent , const char* name ) : Board ( parent , name )
{
pName = playerName;
}
void Resultboard::paintEvent( QPaintEvent* )
{
QPainter p;
p.begin( this );
const int cell_width = this->width();
const int cell_height = this->height()/17;
pointMap::Iterator it = pMap.begin();
for ( ; it != pMap.end() ; ++it )
{
int i = it.key();
qDebug( "ok: %d , %d" , i , it.data() );
p.drawText( 0, i*cell_height , cell_width , cell_height , Qt::AlignCenter , QString::number( it.data() ) );
}
p.drawText( 0,0,cell_width,cell_height, Qt::AlignCenter , pName ); //Playername
}
void Resultboard::updateMap( int item , int points )
{
pMap.insert( item , points );
update();
}
/*
* Possibilityboard
*/
Possibilityboard::Possibilityboard( QWidget *parent , const char* name ) : Board ( parent , name )
{
begriffe.append( "1er" );
begriffe.append( "2er" );
begriffe.append( "3er" );
begriffe.append( "4er" );
begriffe.append( "5er" );
begriffe.append( "6er" );
begriffe.append( "Total" );
begriffe.append( "Bonus" );
begriffe.append( "3oaK" );
begriffe.append( "4oaK" );
begriffe.append( "Full House" );
begriffe.append( "Short S" );
begriffe.append( "Long S" );
begriffe.append( "Yatzee!" );
begriffe.append( "Chance" );
begriffe.append( "Score" );
- connect( this , SIGNAL( clicked( QPoint ) ), this , SLOT( slotClicked( QPoint ) ) );
+ connect( this , SIGNAL( clicked(QPoint) ), this , SLOT( slotClicked(QPoint) ) );
}
void Possibilityboard::slotClicked( QPoint p)
{
emit item( p.y()/(this->height()/17) );
}
void Possibilityboard::paintEvent( QPaintEvent* )
{
QPainter p;
p.begin( this );
const int cell_width = this->width();
const int cell_height = this->height()/17;
p.setBrush( Qt::blue );
QValueListInt::Iterator listIt = list.begin();
for ( ; listIt != list.end() ; ++listIt )
{
p.drawRect( 0 , (*listIt) * cell_height , cell_width , cell_height );
}
p.setBrush( Qt::black );
p.setBrush( Qt::NoBrush );
QStringList::Iterator begriffeIt = begriffe.begin();
for ( int i = 1 ; i < 18 ; ++i )
{
p.drawText( 0 , i*cell_height , cell_width , cell_height , Qt::AlignCenter , *begriffeIt );
++begriffeIt;
}
}
void Possibilityboard::setIntlist( QValueListInt &l )
{
list = l;
}