Diffstat (limited to 'noncore/games/oyatzee/oyatzee.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/games/oyatzee/oyatzee.cpp | 112 |
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 | |||
@@ -37,18 +37,27 @@ OYatzee::OYatzee( QWidget *parent , const char *name, WFlags fl ) : QMainWindow( | |||
37 | QWidget *thing = new QWidget( this ); | 37 | QWidget *thing = new QWidget( this ); |
38 | setCentralWidget( thing ); | 38 | setCentralWidget( thing ); |
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 | ||
45 | vbox->addWidget( sb ); | 59 | vbox->addWidget( sb ); |
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 | } |
53 | 62 | ||
54 | OYatzee::~OYatzee() | 63 | OYatzee::~OYatzee() |
@@ -160,8 +169,6 @@ void OYatzee::detectPosibilities() | |||
160 | 169 | ||
161 | void OYatzee::displayPossibilites() | 170 | 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 ) |
166 | { | 173 | { |
167 | qDebug( QString::number( *it ) ); | 174 | qDebug( QString::number( *it ) ); |
@@ -240,8 +247,36 @@ void OYatzee::slotRollDices() | |||
240 | /* | 247 | /* |
241 | * Scoreboard | 248 | * Scoreboard |
242 | */ | 249 | */ |
243 | Scoreboard::Scoreboard( QWidget *parent, const char *name ) : QWidget( parent , name ) | 250 | Scoreboard::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() ) | ||
244 | { | 267 | { |
268 | hbox->addWidget( r ); | ||
269 | } | ||
270 | } | ||
271 | |||
272 | void Scoreboard::createResultboards(const int num) | ||
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 | } |
246 | 281 | ||
247 | void Scoreboard::paintEvent( QPaintEvent * ) | 282 | void Scoreboard::paintEvent( QPaintEvent * ) |
@@ -361,3 +396,62 @@ Player::Player( QString name ) | |||
361 | playerName = name; | 396 | playerName = name; |
362 | } | 397 | } |
363 | 398 | ||
399 | |||
400 | /* | ||
401 | * Board | ||
402 | */ | ||
403 | Board::Board( QWidget *parent , const char* name ) : QWidget ( parent , name ) | ||
404 | { | ||
405 | } | ||
406 | |||
407 | void 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 | |||
419 | Resultboard::Resultboard( QString playerName , QWidget *parent , const char* name ) : Board ( parent , name ) | ||
420 | { | ||
421 | pName = playerName; | ||
422 | } | ||
423 | |||
424 | void 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 | |||
437 | Possibilityboard::Possibilityboard( QWidget *parent , const char* name ) : Board ( parent , name ) | ||
438 | { | ||
439 | } | ||
440 | |||
441 | void 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 | |||
453 | Game::Game( playerList pla ) | ||
454 | { | ||
455 | players = pla; | ||
456 | } | ||
457 | |||