summaryrefslogtreecommitdiff
path: root/noncore/games/oyatzee/oyatzee.cpp
Unidiff
Diffstat (limited to 'noncore/games/oyatzee/oyatzee.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/games/oyatzee/oyatzee.cpp112
1 files changed, 103 insertions, 9 deletions
diff --git a/noncore/games/oyatzee/oyatzee.cpp b/noncore/games/oyatzee/oyatzee.cpp
index 5c4d1f7..6228a8f 100644
--- a/noncore/games/oyatzee/oyatzee.cpp
+++ b/noncore/games/oyatzee/oyatzee.cpp
@@ -39,6 +39,20 @@ OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow(
39 39
40
41 setPlayerNumber( 4 );
42 setRoundsNumber( 1 );
43
44 playerList ps;
45 ps.append( new Player( "Carsten" ) );
46 ps.append( new Player( "Julia" ) );
47 ps.append( new Player( "Christine" ) );
48 ps.append( new Player( "Stephan" ) );
49
50 Game *g = new Game( ps );
51
52
40 QVBoxLayout *vbox = new QVBoxLayout( thing ); 53 QVBoxLayout *vbox = new QVBoxLayout( thing );
41 54
42 sb = new Scoreboard( thing , "sb" ); 55 sb = new Scoreboard( ps, thing , "sb" );
43 dw = new DiceWidget( thing , "dw" ); 56 dw = new DiceWidget( thing , "dw" );
57 connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) );
44 58
@@ -46,7 +60,2 @@ OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow(
46 vbox->addWidget( dw ); 60 vbox->addWidget( dw );
47
48 setPlayerNumber( 2 );
49 setRoundsNumber( 1 );
50
51 connect( dw->rollButton, SIGNAL( clicked() ), this , SLOT( slotRollDices() ) );
52} 61}
@@ -162,4 +171,2 @@ void OYatzee::displayPossibilites()
162{ 171{
163 qDebug( "running displayPossibilites(), %d item", posibilities.count() );
164
165 for ( QValueListInt::Iterator it = posibilities.begin() ; it != posibilities.end(); ++it ) 172 for ( QValueListInt::Iterator it = posibilities.begin() ; it != posibilities.end(); ++it )
@@ -242,4 +249,32 @@ void OYatzee::slotRollDices()
242 */ 249 */
243Scoreboard::Scoreboard( QWidget *parent, const char *name ) : QWidget( parent , name ) 250Scoreboard::Scoreboard( playerList ps, QWidget *parent, const char *name ) : QWidget( parent , name )
251{
252 ps_ = ps;
253
254 pb = new Possibilityboard( this , "pb" );
255
256 createResultboards( 4 );
257
258 QHBoxLayout *hbox = new QHBoxLayout( this );
259
260 hbox->addWidget( pb );
261
262 hbox->addSpacing( 25 );
263
264 Resultboard *r = rbList.first();
265
266 for ( ; r != 0 ; r = rbList.next() )
267 {
268 hbox->addWidget( r );
269 }
270}
271
272void Scoreboard::createResultboards(const int num)
244{ 273{
274 Player *p = ps_.first();
275 for ( int i = 0 ; i < num ; ++i , p = ps_.next() )
276 {
277 QString n = p->playerName;
278 rbList.append( new Resultboard( n , this ) );
279 }
245} 280}
@@ -363 +398,60 @@ Player::Player( QString name )
363 398
399
400/*
401 * Board
402 */
403Board::Board( QWidget *parent , const char* name ) : QWidget ( parent , name )
404{
405}
406
407void Board::paintEvent( QPaintEvent* )
408{
409 QPainter p;
410 p.begin( this );
411
412 p.drawRect( 0,0, this->width() , this->height() );
413}
414
415/*
416 * Resultboard
417 */
418
419Resultboard::Resultboard( QString playerName , QWidget *parent , const char* name ) : Board ( parent , name )
420{
421 pName = playerName;
422}
423
424void Resultboard::paintEvent( QPaintEvent* )
425{
426 QPainter p;
427 p.begin( this );
428
429 p.drawText( 10,10, pName );
430 p.drawRect( 0,0, this->width() , this->height() );
431}
432
433/*
434 * Possibilityboard
435 */
436
437Possibilityboard::Possibilityboard( QWidget *parent , const char* name ) : Board ( parent , name )
438{
439}
440
441void Possibilityboard::paintEvent( QPaintEvent* )
442{
443 QPainter p;
444 p.begin( this );
445
446 p.drawRect( 0,0, this->width() , this->height() );
447}
448
449/*
450 * Game
451 */
452
453Game::Game( playerList pla )
454{
455 players = pla;
456}
457