Search in sources :

Example 1 with TetfuElement

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);
}
Also used : Piece(core.mino.Piece) ColorType(common.tetfu.common.ColorType) OperationTransform(common.parser.OperationTransform) MinoOperationWithKey(common.datastore.MinoOperationWithKey) Tetfu(common.tetfu.Tetfu) TetfuElement(common.tetfu.TetfuElement) ColorConverter(common.tetfu.common.ColorConverter) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Operations(common.datastore.Operations) List(java.util.List) Field(core.field.Field) ColoredFieldFactory(common.tetfu.field.ColoredFieldFactory) MinoFactory(core.mino.MinoFactory) Operation(common.datastore.Operation) ColoredField(common.tetfu.field.ColoredField) ColoredField(common.tetfu.field.ColoredField) ArrayList(java.util.ArrayList) Operation(common.datastore.Operation) Piece(core.mino.Piece) ColorType(common.tetfu.common.ColorType) Operations(common.datastore.Operations) Tetfu(common.tetfu.Tetfu) TetfuElement(common.tetfu.TetfuElement)

Example 2 with TetfuElement

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));
}
Also used : BlockField(common.datastore.BlockField) Tetfu(common.tetfu.Tetfu) TetfuElement(common.tetfu.TetfuElement)

Example 3 with TetfuElement

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);
}
Also used : BlockField(common.datastore.BlockField) Field(core.field.Field) ColoredField(common.tetfu.field.ColoredField) ColoredField(common.tetfu.field.ColoredField) Piece(core.mino.Piece) ColorType(common.tetfu.common.ColorType) TetfuElement(common.tetfu.TetfuElement)

Example 4 with TetfuElement

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);
}
Also used : Tetfu(common.tetfu.Tetfu) TetfuElement(common.tetfu.TetfuElement)

Example 5 with TetfuElement

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);
}
Also used : BlockField(common.datastore.BlockField) Field(core.field.Field) ColoredField(common.tetfu.field.ColoredField) ColoredField(common.tetfu.field.ColoredField) Piece(core.mino.Piece) ColorType(common.tetfu.common.ColorType) TetfuElement(common.tetfu.TetfuElement)

Aggregations

TetfuElement (common.tetfu.TetfuElement)12 Tetfu (common.tetfu.Tetfu)8 ColoredField (common.tetfu.field.ColoredField)7 ColorType (common.tetfu.common.ColorType)6 Field (core.field.Field)6 Piece (core.mino.Piece)6 BlockField (common.datastore.BlockField)5 ColorConverter (common.tetfu.common.ColorConverter)4 MinoFactory (core.mino.MinoFactory)4 MinoOperationWithKey (common.datastore.MinoOperationWithKey)2 ColoredFieldFactory (common.tetfu.field.ColoredFieldFactory)2 Collectors (java.util.stream.Collectors)2 ColumnParityLimitation (_implements.parity_based_pack.step1.ColumnParityLimitation)1 DeltaLimitedMino (_implements.parity_based_pack.step1.DeltaLimitedMino)1 EstimateBuilder (_implements.parity_based_pack.step1.EstimateBuilder)1 FullLimitedMino (_implements.parity_based_pack.step2.FullLimitedMino)1 PositionLimitParser (_implements.parity_based_pack.step2.PositionLimitParser)1 CrossBuilder (_implements.parity_based_pack.step3.CrossBuilder)1 BuildUp (common.buildup.BuildUp)1 OperationWithKeyComparator (common.comparator.OperationWithKeyComparator)1