use of common.tetfu.common.ActionFlags in project solution-finder by knewjade.
the class Tetfu method encode.
// コメント・フィールドは初期設定のみ設定可能
public String encode(List<TetfuElement> elements) {
ColoredField prevField = ColoredFieldFactory.createField(TETFU_MAX_HEIGHT);
String prevComment = "";
for (int index = 0; index < elements.size(); index++) {
TetfuElement element = elements.get(index);
ColoredField field = element.getField().orElse(prevField);
// field settings
// prevFieldは、ひとつ前のミノを置いてできたフィールド
// fieldは次に表示させたいフィールド。今回は、最初をのぞいてひとつ前のミノを置いてできたフィールドをそのまま利用
encodeField(prevField, field);
String comment = element.getEscapedComment();
ActionFlags flags = new ActionFlags(comment, prevComment, index, element);
parseAction(element, flags);
ColorType colorType = element.getColorType();
if (flags.isLock) {
if (ColorType.isMinoBlock(colorType)) {
Piece piece = converter.parseToBlock(colorType);
Mino mino = minoFactory.create(piece, element.getRotate());
field.putMino(mino, element.getX(), element.getY());
}
field.clearLine();
if (flags.isBlockUp) {
throw new UnsupportedOperationException();
// currentField.blockUp();
// for (int x = 0; x < TETFU_FIELD_WIDTH; x++)
// currentField.setBlockNumber(x, 0, blockUp[x]);
}
if (flags.isMirror) {
throw new UnsupportedOperationException();
// currentField.mirror();
}
}
// next field
prevField = field;
prevComment = comment;
}
StringBuilder builder = new StringBuilder();
for (int index = 0; index < encodedValues.size(); index++) {
Integer value = encodedValues.get(index);
String encoded = TetfuTable.encodeData(value);
builder.append(encoded);
if (index % 47 == 41)
builder.append('?');
}
return builder.toString();
}
Aggregations