use of common.tetfu.common.ColorType in project solution-finder by knewjade.
the class OneFumenParser method createTetfuElement.
private TetfuElement createTetfuElement(Field initField, BlockField blockField, String comment, int maxClearLine) {
ColoredField coloredField = createInitColoredField(initField, maxClearLine);
for (Piece piece : Piece.values()) {
Field target = blockField.get(piece);
ColorType colorType = this.colorConverter.parseToColorType(piece);
fillInField(coloredField, colorType, target, maxClearLine);
}
return new TetfuElement(coloredField, ColorType.Empty, Rotate.Reverse, 0, 0, comment);
}
use of common.tetfu.common.ColorType in project solution-finder by knewjade.
the class PercentSettingParser method loadTetfu.
private CommandLineWrapper loadTetfu(String data, CommandLineParser parser, Options options, CommandLineWrapper wrapper, PercentSettings settings) throws FinderParseException {
// テト譜面のエンコード
List<TetfuPage> decoded = encodeTetfu(data);
// 指定されたページを抽出
int page = wrapper.getIntegerOption("page").orElse(1);
TetfuPage tetfuPage = extractTetfuPage(decoded, page);
// コメントの抽出
// 先頭が数字ではない(--clear-line -p *p7のようになる)場合でも、parserはエラーにならない
// データ取得時にOptional.emptyがかえるだけ
String comment = "--clear-line " + tetfuPage.getComment();
List<String> splitComment = Arrays.stream(comment.split(" ")).map(String::trim).filter(s -> !s.isEmpty()).collect(Collectors.toList());
// コマンド引数を配列に変換
String[] commentArgs = new String[splitComment.size()];
splitComment.toArray(commentArgs);
// オプションとして読み込む
try {
CommandLine commandLineTetfu = parseToCommandLine(options, parser, commentArgs);
CommandLineWrapper newWrapper = new NormalCommandLineWrapper(commandLineTetfu);
// 削除ラインが読み取れればOK
newWrapper.getIntegerOption("clear-line");
wrapper = new PriorityCommandLineWrapper(Arrays.asList(wrapper, newWrapper));
} catch (FinderParseException ignore) {
}
// 最大削除ラインの設定
Optional<Integer> maxClearLineOption = wrapper.getIntegerOption("clear-line");
maxClearLineOption.ifPresent(settings::setMaxClearLine);
// フィールドを設定
ColoredField coloredField = tetfuPage.getField();
if (tetfuPage.isPutMino()) {
ColorType colorType = tetfuPage.getColorType();
Rotate rotate = tetfuPage.getRotate();
int x = tetfuPage.getX();
int y = tetfuPage.getY();
ColorConverter colorConverter = new ColorConverter();
Mino mino = new Mino(colorConverter.parseToBlock(colorType), rotate);
coloredField.putMino(mino, x, y);
}
settings.setField(coloredField, settings.getMaxClearLine());
return wrapper;
}
Aggregations