diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java index 3ea8f65..b400d60 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/controller/GameController.java @@ -414,6 +414,7 @@ public class GameController implements IModelChangedListener, Parcelable { return gameBoard.toString(); } + public String getCodeOfField() { return gameBoard.transformToCode(); } diff --git a/app/src/main/java/org/secuso/privacyfriendlysudoku/game/GameBoard.java b/app/src/main/java/org/secuso/privacyfriendlysudoku/game/GameBoard.java index ba7c64f..9bf90fc 100644 --- a/app/src/main/java/org/secuso/privacyfriendlysudoku/game/GameBoard.java +++ b/app/src/main/java/org/secuso/privacyfriendlysudoku/game/GameBoard.java @@ -3,6 +3,7 @@ package org.secuso.privacyfriendlysudoku.game; import android.os.Parcel; import android.os.Parcelable; +import org.secuso.privacyfriendlysudoku.controller.Symbol; import org.secuso.privacyfriendlysudoku.game.listener.IModelChangedListener; import java.util.LinkedList; @@ -214,6 +215,20 @@ public class GameBoard implements Cloneable, Parcelable { return sb.toString(); } + public String transformToCode () { + StringBuilder sb = new StringBuilder(); + for(int i = 0; i < field.length; i++) { + for (int j = 0; j < field[0].length; j++) { + if (field[i][j].getValue() == 0) { + sb.append(0); + } else { + sb.append(Symbol.getSymbol(Symbol.SaveFormat, field[i][j].getValue()-1)); + } + } + } + return sb.toString(); + } + public boolean isFilled() { return actionOnCells(new ICellAction() { @Override