@Nullable
private Map<Face, Integer> faces = null;
public DummyCanvas(@NotNull final String fileName)
throws IOException, ParsingFailException {
final FileLevelParser parser = new AssertValidGraphParser();
File levelsPath = GameSettings.getRelativeDirectory( GameSettings
.getInstance().getValue(
GameSettings.STRING_SETTINGS_TYPE.LEVELS_PATH ));
File levelFile = new File( levelsPath, fileName );
if ( ! levelFile.canRead() ) {
for (String extension : COMMON_EXTENSIONS) {
levelFile = new File( levelsPath, fileName + extension );
if ( levelFile.canRead() ) {
break;
}
}
}
if ( ! levelFile.canRead() ) {
throw new LevelNotFoundException( "Couldn't find level: " + levelFile
.getAbsolutePath() );
}
Path path = Paths.get( levelFile.getAbsolutePath() );
ByteBuffer buffer = ByteBuffer.wrap( Files.readAllBytes( path ) );
parser.parseData( buffer );
this.levelMap = parser.getLevelMap();
this.rawFacesMap = parser.getFacesMap();
this.playerPosition = parser.getPlayerPosition();
this.monstersPositions = parser.getMonstersPosition();
this.levelBounds = makeBoundRectangle( this.levelMap );
this.facesMap = new HashMap<>( this.rawFacesMap.size() );
for (Map.Entry<Integer, Set<Segment>> faceEntry : this.rawFacesMap.entrySet()) {