Viergewinnt (four-in-a-row) implementation in c++ and QT
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

viergewinnt.h 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* VierGewinnt - A simple 4-in-a-row network game
  2. *
  3. * Copyright (c) 2008 by Sebastian Lohff, seba@seba-geek.de
  4. * http://www.seba-geek.de
  5. *
  6. * This file is part of VierGewinnt.
  7. *
  8. * VierGewinnt is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 2 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * VierGewinnt is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with VierGewinnt. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __VIERGEWINNT_H
  22. #define __VIERGEWINNT_H
  23. #include <QDialog>
  24. #include <QWidget>
  25. #include <QTcpSocket>
  26. #include <QPushButton>
  27. #include <QLCDNumber>
  28. #include <QVBoxLayout>
  29. #include <QHBoxLayout>
  30. #include <QMessageBox>
  31. #include <QLabel>
  32. #include <QDebug>
  33. #include <queue>
  34. #include "newgame.h"
  35. #include "playerwait.h"
  36. class RenderArea;
  37. class VierGewinntWidget : public QDialog {
  38. Q_OBJECT
  39. public:
  40. VierGewinntWidget(QTcpSocket *tcpsock, QWidget *parent);
  41. ~VierGewinntWidget();
  42. enum Stein {n=0, x, o};
  43. void init(int _x, int _y);
  44. void startGame();
  45. void add(int row, Stein st);
  46. void cleanFeld();
  47. void setScore(int a, int b);
  48. // called by networkstuff
  49. void setTurn(bool _myturn);
  50. void clientExited();
  51. void ackAdd(bool valid);
  52. void ackNewGame();
  53. void newGame(bool won);
  54. private slots:
  55. void closeGame();
  56. void netAdd(int row);
  57. private:
  58. void dealloc();
  59. int fx, fy;
  60. Stein **feld;
  61. QTcpSocket *mysock;
  62. bool myturn;
  63. std::queue<int> pendingadd;
  64. // guistuff
  65. QVBoxLayout *layout;
  66. QHBoxLayout *upperrow;
  67. QHBoxLayout *underrow;
  68. PlayerWaitDialog *waitforplayer;
  69. NewGameDialog *newgame;
  70. QLabel *status;
  71. RenderArea *rarea;
  72. QLCDNumber *myscore;
  73. QLabel *vs;
  74. QLCDNumber *youscore;
  75. QPushButton *exit;
  76. };
  77. #endif