PM WS13/14 Nachtrag zur HA 7

Programming Methodologies, WS1314

Auf Grund der sich häufenden Nachfragen bezüglich einiger Details zu Aufgabenblatt 7, hier ein kleiner Nachtrag mit Hinweisen.

Ich hatte in der Übung erwähnt, dass ich beide SDMLibs angepasst habe. Bei dem Beispielprojekt von uns haben wir den ColorPicker eingesetzt. Dort müsst ihr Bidirektionales Verknüpfen einsetzen welches eine javafx Color in einen String bindet. Hierfür müsst ihr ein aktuelles SDMLib einsetzen. Die Änderungen habe ich Freitag morgen bereitgestellt.

Update:

Das bereitgestellte Projekt funktioniert u.U. nicht, weil es auf Controller und Methoden verweist, die ihr erst noch implementieren müsst. Sobald die Controller und die Methodenaufrufe in den Action-Bereichen korrekt gesetzt wurden, sollte alles einwandfrei funktionieren.

Eine funktionierende Methode zum Initialisieren des Vier-Spieler-Spiels findet ihr hier:

public void initFourPlayerGame(String p0, String p1, String p2, String p3) {
        //players
        Player playerOne = new Player().withName(p0);
        Player playerTwo = new Player().withName(p1);
        Player playerThree = new Player().withName(p2);
        Player playerFour = new Player().withName(p3);

        //takes care of referential integrity
        this.withPlayer(playerOne, playerTwo, playerThree, playerFour)
        .withCurrentPlayer(playerOne);

        //meeples
        playerOne.withMeeple(new Meeple().withColor("black"));
        playerTwo.withMeeple(new Meeple().withColor("white"));
        playerThree.withMeeple(new Meeple().withColor("red"));
        playerFour.withMeeple(new Meeple().withColor("green"));

        //walls (3 per player)
        for(int i = 0; i < 3; i++){             playerOne.withWall(new Wall().withQuoridorGame(this));             playerTwo.withWall(new Wall().withQuoridorGame(this));             playerThree.withWall(new Wall().withQuoridorGame(this));             playerFour.withWall(new Wall().withQuoridorGame(this));         }         //board         BoardElement[][] boardArray = new BoardElement[11][11];         //board creation         for(int i = 1; i < 10; i++){             for(int k = 1; k < 10; k++){                 /*                  * i0k0 i0k1 i0k2 ... i0k8                  * i1k0 i1k1 i1k2            i1k8                  * i2k0                i2k8                  * ...                ...                  * i8k0 i8k1 i8k2 ... i8k8                  */                 //i == 0 first row                 //i == 8 last row                 //k == 0 first column                 //k == 8 last column                 BoardElement newElement;                 //odd rows are field gap field gap...                 //even rows are gap intersection gap intersection gap ...                 if((i & 1) == 0){                     //even                     if((k & 1) == 0){                         newElement = new Intersection();                     }else{                         newElement = new Gap();                     }                 }else{                     //odd                     if((k & 1) == 0){                         newElement = new Gap();                     }else{                         newElement = new Field();                         if(i == 1) {                             playerOne.withTargetField((Field)newElement);                             if(k == 5){                                 playerTwo.withStartField((Field) newElement);                                 playerTwo.getMeeple().setField((Field) newElement);                             }                         }                         if(i == 9) {                             playerTwo.withTargetField((Field)newElement);                             if(k == 5){                                 playerOne.withStartField((Field) newElement);                                 playerOne.getMeeple().setField((Field) newElement);                             }                         }                         if(k == 1) {                             playerThree.withTargetField((Field)newElement);                             if(i == 5){                                 playerFour.withStartField((Field) newElement);                                 playerFour.getMeeple().setField((Field) newElement);                             }                         }                         if(k == 9) {                             playerFour.withTargetField((Field)newElement);                             if(i == 5){                                 playerThree.withStartField((Field) newElement);                                 playerThree.getMeeple().setField((Field) newElement);                             }                         }                     }                 }                 //add newly created element to the game and to the array for later linking                 newElement                 .withX(i)                 .withY(k)                 .withQuoridorGame(this);                 boardArray[i][k] = newElement;             }         }         //board linking         for(int i = 1; i < 10; i++){             for(int k = 1; k < 10; k++){                 BoardElement toConnect = boardArray[i][k];                 toConnect                 .withLeft(boardArray[i][k-1])                 .withRight(boardArray[i][k+1])                 .withLower(boardArray[i-1][k])                 .withUpper(boardArray[i+1][k]);             }         }     }