Index: code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxy.cc
===================================================================
--- code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxy.cc	(revision 12086)
+++ code/branches/TixyTaxyTorxy_HS18/src/modules/TixyTaxyTorxy/TixyTaxyTorxy.cc	(revision 12149)
@@ -83,8 +83,14 @@
 #include "core/CoreIncludes.h"
 #include "Highscore.h"
+#include <iostream>
+#include "TixyTaxyTorxyField.h"
+using namespace std;
 
 namespace orxonox
 {
+
     RegisterUnloadableClass(TixyTaxyTorxy);
+
+
 
     
@@ -103,8 +109,11 @@
         this->waveSize_ = 0;
         offset_ = Vector3(0,0,10);
+
     }
 
 TixyTaxyTorxy::~TixyTaxyTorxy()
     {
+
+
         if (this->isInitialized())
         {
@@ -186,16 +195,131 @@
     void TixyTaxyTorxy::addTower(int x,int y)
     {
+        int mini;
+         
         TixyTaxyTorxyCoordinate* coord = new TixyTaxyTorxyCoordinate(x,y);
         x = coord->GetX();
         y = coord->GetY();
-
+        mini = coord->Getmini();
+
+        orxout() <<"addTower("<<x<<", "<<y<<") "<<mini<<"" <<endl;
         int cost = center_->getTowerCost(1);
 
-        if (fields_[x][y]->isFree() == true && getCredit() >= cost)
+        if (fields_[x][y]->isFree())
         {
             payCredit(cost);
             fields_[x][y]->createTower(1);
         }
-    }
+    
+    bool player1=player2=0;
+    int A1,B1,C1,D1,E1,F1,G1,H1,I1;
+    int A2,B2,C2,D2,E2,F2,G2,H2,I2;
+    A1=B1=C1=D1=E1=F1=G1=H1=I1=0;
+    A2=B2=C2=D2=E2=F2=G2=H2=I2=0;
+
+
+
+    if (checkMinigame(0,10) == 1) A1=1;
+    if (checkMinigame(4,10) == 1) B1=2;
+    if (checkMinigame(8,10) == 1) C1=4;
+    if (checkMinigame(0,6) == 1) D1=8;
+    if (checkMinigame(4,6) == 1) E1=16;
+    if (checkMinigame(8,6) == 1) F1=32;
+    if (checkMinigame(0,2) == 1) G1=64;
+    if (checkMinigame(4,2) == 1) H1=128;
+    if (checkMinigame(8,2) == 1) I1=256;
+
+    if (checkMinigame(0,10) == 2) A2=1;
+    if (checkMinigame(4,10) == 2) B2=2;
+    if (checkMinigame(8,10) == 2) C2=4;
+    if (checkMinigame(0,6) == 2) D2=8;
+    if (checkMinigame(4,6) == 2) E2=16;
+    if (checkMinigame(8,6) == 2) F2=32;
+    if (checkMinigame(0,2) == 2) G2=64;
+    if (checkMinigame(4,2) == 2) H2=128;
+    if (checkMinigame(8,2) == 2) I2=256;
+
+    orxout()<<"A1: "<<A1<<"B1: "<<B1<<endl;
+
+    if(A1+B1+C1 == 7 || D1+E1+F1 == 56 || G1+H1+I1 == 448 || A1+D1+G1 == 73 || B1+E1+H1 == 146 || C1+F1+I1 == 294 || A1+E1+I1 == 273 || C1+E1+G1 == 84){
+
+        player1=1;
+        orxout()<<"player1 has won" << endl;
+    }
+
+     if(A2+B2+C2 == 7 || D2+E2+F2 == 56 || G2+H2+I2 == 448 || A2+D2+G2 == 73 || B2+E2+H2 == 146 || C2+F2+I2 == 294 || A2+E2+I2 == 273 || C2+E2+G2 == 84){
+
+        player2=1;
+        orxout()<<"player1 has won" << endl;
+    }
+    }
+
+    int TixyTaxyTorxy::checkMinigame(int x, int y){
+        if (checkRow(x,y)==1 || checkColumn(x,y)==1 || checkDiagLtR(x,y)==1 ||checkDiagRtL(x,y)==1) return 1;
+        else if (checkRow(x,y)==2 || checkColumn(x,y)==2 || checkDiagLtR(x,y)==2 || checkDiagRtL (x,y)==2) return 2;
+        return 0;
+         }  
+
+    int TixyTaxyTorxy::checkRow(int x, int y){
+        for(int i=0; i<2; i++){
+
+            if(fields_[x+i][y]-> isTower1() && fields_[x+i][y-1]-> isTower1() && fields_[x+i][y-2]-> isTower1()){
+                return 1;
+
+            }else if(fields_[x+i][y]-> isTower2() && fields_[x+i][y-1]-> isTower2() && fields_[x+i][y-2]-> isTower2()){
+                return 2;}   
+        }
+        return 0;
+
+    }
+    int TixyTaxyTorxy::checkColumn(int x, int y){
+        for(int i=0; i<2; i++){
+
+            if(fields_[x][y-i]-> isTower1() && fields_[x+1][y-i]-> isTower1() && fields_[x+2][y-i]-> isTower1()){
+                return 1;
+
+            }else if (fields_[x][y-i]-> isTower2() && fields_[x+1][y-i]-> isTower2() && fields_[x+2][y-i]-> isTower2()){
+            return 2;            }
+        }
+            return 0;
+        
+        
+    }
+    //Cheeck the diagonal achsis from top left to bottom right
+    int TixyTaxyTorxy::checkDiagLtR(int x, int y){
+
+        if (fields_[x][y]-> isTower1() && fields_[x+1][y-1]-> isTower1() && fields_[x+2][y-2]-> isTower1()){
+            return 1;
+        }
+        else if (fields_[x][y]-> isTower2() && fields_[x+1][y-1]-> isTower2() && fields_[x+2][y-2]-> isTower2()){
+            return 2;
+        }
+        return 0;
+        
+    }
+    //Cheeck the diagonal achsis from top right to bottom left
+    int TixyTaxyTorxy::checkDiagRtL (int x, int y){
+
+        if(fields_[x+2][y]-> isTower1() && fields_[x+1][y-1]-> isTower1() && fields_[x][y-2]-> isTower1()){
+            return 1;
+        }
+        else if(fields_[x+2][y]-> isTower2() && fields_[x+1][y-1]-> isTower2() && fields_[x][y-2]-> isTower2()){
+            return 2;
+        }
+        
+        else return 0;
+        }
+
+    bool TixyTaxyTorxy::getPlayer1Value(){
+    return player1;
+}
+    bool TixyTaxyTorxy::getPlayer2Value(){
+    return player2;
+}
+    
+
+
+
+
+
 
     /*adds Tower at Position (x,y) and reduces credit and adds the point to the towermatrix. template ("towerturret")
@@ -253,7 +377,7 @@
         std::string fields = center_->getFields();
         int pos = 0;
-        for (int j = 15; j >= 0; --j)
-        {
-            for (int i = 0; i < 16; ++i)
+        for (int j = 10; j >= 0; --j)
+        {
+            for (int i = 0; i < 11; ++i)
             {
                 coord.Set(i,j);
