use of common.tetfu.TetfuElement in project solution-finder by knewjade.
the class SequenceFumenParser method parse.
@Override
public String parse(List<MinoOperationWithKey> operations, Field field, int maxClearLine) {
Operations operations2 = OperationTransform.parseToOperations(field, operations, maxClearLine);
List<? extends Operation> operationsList = operations2.getOperations();
// ブロック順に変換
List<Piece> pieceList = operationsList.stream().map(Operation::getPiece).collect(Collectors.toList());
// テト譜を作成
String quiz = Tetfu.encodeForQuiz(pieceList);
ArrayList<TetfuElement> tetfuElements = new ArrayList<>();
// 最初のelement
Operation firstKey = operationsList.get(0);
ColorType colorType1 = colorConverter.parseToColorType(firstKey.getPiece());
ColoredField coloredField = createInitColoredField(field, maxClearLine);
TetfuElement firstElement = new TetfuElement(coloredField, colorType1, firstKey.getRotate(), firstKey.getX(), firstKey.getY(), quiz);
tetfuElements.add(firstElement);
// 2番目以降のelement
if (1 < operationsList.size()) {
operationsList.subList(1, operationsList.size()).stream().map(operation -> {
ColorType colorType = colorConverter.parseToColorType(operation.getPiece());
return new TetfuElement(colorType, operation.getRotate(), operation.getX(), operation.getY(), quiz);
}).forEach(tetfuElements::add);
}
Tetfu tetfu = new Tetfu(minoFactory, colorConverter);
return tetfu.encode(tetfuElements);
}
use of common.tetfu.TetfuElement in project solution-finder by knewjade.
the class EasyTetfu method encodeUrl.
public <T extends OperationWithKey> String encodeUrl(Field initField, List<T> operationWithKeys, int height) {
Tetfu tetfu = new Tetfu(minoFactory, colorConverter);
BlockField blockField = OperationTransform.parseToBlockField(operationWithKeys, minoFactory, height);
TetfuElement elementOnePage = parseBlockFieldToTetfuElement(initField, colorConverter, blockField, "");
return "http://fumen.zui.jp/?v115@" + tetfu.encode(Collections.singletonList(elementOnePage));
}
use of common.tetfu.TetfuElement in project solution-finder by knewjade.
the class EasyTetfu method parseBlockFieldToTetfuElement.
private TetfuElement parseBlockFieldToTetfuElement(Field initField, ColorConverter colorConverter, BlockField blockField, String comment) {
ColoredField coloredField = ColoredFieldFactory.createGrayField(initField);
for (Piece piece : Piece.values()) {
Field target = blockField.get(piece);
ColorType colorType = colorConverter.parseToColorType(piece);
fillInField(coloredField, colorType, target);
}
return new TetfuElement(coloredField, ColorType.Empty, Rotate.Reverse, 0, 0, comment);
}
use of common.tetfu.TetfuElement in project solution-finder by knewjade.
the class MoveEntryPoint method encodeOnePage.
private String encodeOnePage(MinoFactory minoFactory, ColorConverter colorConverter, TetfuElement tetfuElement) {
Tetfu tetfu = new Tetfu(minoFactory, colorConverter);
List<TetfuElement> elementOnePage = Collections.singletonList(tetfuElement);
return "v115@" + tetfu.encode(elementOnePage);
}
use of common.tetfu.TetfuElement in project solution-finder by knewjade.
the class MoveEntryPoint method parseColorElement.
private TetfuElement parseColorElement(Field initField, ColorConverter colorConverter, BlockField blockField, String comment) {
ColoredField coloredField = ColoredFieldFactory.createGrayField(initField);
for (Piece piece : Piece.values()) {
Field target = blockField.get(piece);
ColorType colorType = colorConverter.parseToColorType(piece);
fillInField(coloredField, colorType, target);
}
return new TetfuElement(coloredField, ColorType.Empty, Rotate.Reverse, 0, 0, comment);
}
Aggregations