maximum number of teams and hedgehogs
authordisplacer
Fri, 15 Sep 2006 15:45:30 +0000
changeset 147 52a3c431db8a
parent 146 458f4f58c1b6
child 148 c0355acf07c8
maximum number of teams and hedgehogs
QTfrontend/hedgehogerWidget.cpp
QTfrontend/hedgehogerWidget.h
QTfrontend/teamselect.cpp
--- a/QTfrontend/hedgehogerWidget.cpp	Fri Sep 15 13:47:01 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.cpp	Fri Sep 15 15:45:30 2006 +0000
@@ -3,19 +3,33 @@
 #include <QMouseEvent>
 #include <QPainter>
 
+int overallHedgehogs=0;
+
 CHedgehogerWidget::CHedgehogerWidget(QWidget * parent) :
   QWidget(parent), numHedgehogs(4)
 {
+  overallHedgehogs+=numHedgehogs;
+}
+
+CHedgehogerWidget::~CHedgehogerWidget()
+{
+  overallHedgehogs-=numHedgehogs;
 }
 
 void CHedgehogerWidget::mousePressEvent ( QMouseEvent * event )
 {
   if(event->button()==Qt::LeftButton) {
     event->accept();
-    if(numHedgehogs < 8) numHedgehogs++;
+    if(numHedgehogs < 8 && overallHedgehogs<18) {
+      numHedgehogs++;
+      overallHedgehogs++;
+    }
   } else if (event->button()==Qt::RightButton) {
     event->accept();
-    if(numHedgehogs > 3) numHedgehogs--;
+    if(numHedgehogs > 3) {
+      numHedgehogs--;
+      overallHedgehogs--;
+    }
   } else {
     event->ignore();
     return;
--- a/QTfrontend/hedgehogerWidget.h	Fri Sep 15 13:47:01 2006 +0000
+++ b/QTfrontend/hedgehogerWidget.h	Fri Sep 15 15:45:30 2006 +0000
@@ -9,6 +9,7 @@
 
  public:
   CHedgehogerWidget(QWidget * parent = 0);
+  ~CHedgehogerWidget();
   unsigned char getHedgehogsNum();
 
  protected:
--- a/QTfrontend/teamselect.cpp	Fri Sep 15 13:47:01 2006 +0000
+++ b/QTfrontend/teamselect.cpp	Fri Sep 15 15:45:30 2006 +0000
@@ -34,6 +34,8 @@
     curDontPlayingTeams.push_back(*itPlay);
     curPlayingTeams.erase(itPlay);
   } else {
+    // return if max playing teams reached
+    if(curPlayingTeams.size()>2) return;
     // dont playing team => playing
     curPlayingTeams.push_back(*itDontPlay);
     curDontPlayingTeams.erase(itDontPlay);