Initial check in.

This commit is contained in:
2013-04-21 23:46:09 +04:00
commit dbaf5b4720
111 changed files with 2290 additions and 0 deletions

View File

@@ -0,0 +1,94 @@
package org.dyndns.vahagn.sokoban;
//import java.lang.Exception;
import java.io.*;
import android.util.Log;
public class Puzzle
{
public enum symbole
{
FLOOR,
WALL,
BOX,
HOLE,
BOX_IN_HOLE,
WORKER;
public static int MAX_COUNT()
{
return 6;
}
};
protected static final String TAG = "Puzzle";
protected int columns;
protected int rows;
protected symbole [] board;
public Puzzle( InputStream is )
{
load( is );
}
private void load( InputStream is )
{try{
columns = is.read();
rows = is.read();
byte [] b = new byte [columns*rows];
board = new symbole[columns*rows];
is.read( b, 0, columns*rows);
for( int i = 0; i < b.length; ++i )
{
switch( b[i] )
{
case 0:
board[i] = symbole.FLOOR;
break;
case 1:
board[i] = symbole.WALL;
break;
case 2:
board[i] = symbole.BOX;
break;
case 3:
board[i] = symbole.HOLE;
break;
case 4:
board[i] = symbole.BOX_IN_HOLE;
break;
case 5:
board[i] = symbole.WORKER;
break;
default:
}
}
}
catch ( Exception e )
{
Log.d( TAG, "load()", e);
}}
public final int getColumnCount()
{
return columns;
}
public final int getRowCount()
{
return rows;
}
public static int getSymCount()
{
return symbole.MAX_COUNT();
}
/*
* r- row
* c- column
*/
public final symbole getSym( int r, int c )
{
return board[r*columns+c];
}
}