Search in sources :

Example 6 with ColorConverter

use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.

the class TetfuTest method decode3.

@Test
void decode3() throws Exception {
    // empty
    String value = "vhAAgH";
    MinoFactory factory = new MinoFactory();
    ColorConverter converter = new ColorConverter();
    Tetfu tetfu = new Tetfu(factory, converter);
    List<TetfuPage> pages = tetfu.decode(value);
    assertThat(pages).hasSize(1);
    assertThat(pages.get(0)).returns(ColorType.Empty, TetfuPage::getColorType).returns(Rotate.Reverse, TetfuPage::getRotate).returns(0, TetfuPage::getX).returns(22, TetfuPage::getY).returns("", TetfuPage::getComment);
    assertField(ColoredFieldFactory.createColoredField(""), pages.get(0).getField());
}
Also used : ColorConverter(common.tetfu.common.ColorConverter) MinoFactory(core.mino.MinoFactory) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest)

Example 7 with ColorConverter

use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.

the class TetfuTest method encode3.

@Test
void encode3() throws Exception {
    List<TetfuElement> elements = Arrays.asList(new TetfuElement(ColorType.I, Rotate.Reverse, 5, 0, "a"), new TetfuElement(ColorType.S, Rotate.Reverse, 5, 2, "b"), new TetfuElement(ColorType.J, Rotate.Left, 9, 1, "c"), new TetfuElement(ColorType.O, Rotate.Right, 0, 1, "d"), new TetfuElement(ColorType.Z, Rotate.Left, 3, 1, "e"), new TetfuElement(ColorType.L, Rotate.Right, 0, 3, "日本語"), new TetfuElement(ColorType.T, Rotate.Reverse, 7, 1));
    MinoFactory factory = new MinoFactory();
    ColorConverter converter = new ColorConverter();
    Tetfu tetfu = new Tetfu(factory, converter);
    String encode = tetfu.encode(elements);
    assertThat(encode).isEqualTo("vhGBQYBABBAAAnmQBACBAAA+tQBADBAAALpQBAEBAA?AcqQBAFBAAAKfQSAlfrHBFwDfE2Cx2Bl/PwB53AAAlsQAA");
}
Also used : ColorConverter(common.tetfu.common.ColorConverter) MinoFactory(core.mino.MinoFactory) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest)

Example 8 with ColorConverter

use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.

the class TetfuTest method decode6.

@Test
void decode6() throws Exception {
    String value = "VhRpHeRpNeAgHvhIAAAAAAAAAAAAAAAAAAAAAAAAAA?A";
    MinoFactory factory = new MinoFactory();
    ColorConverter converter = new ColorConverter();
    Tetfu tetfu = new Tetfu(factory, converter);
    List<TetfuPage> pages = tetfu.decode(value);
    assertThat(pages).hasSize(10);
    for (int index = 0; index < 10; index++) {
        assertThat(pages.get(index)).returns(ColorType.Empty, TetfuPage::getColorType).returns("", TetfuPage::getComment);
    }
    assertField(ColoredFieldFactory.createColoredField("" + "____OO____" + "____OO____"), pages.get(9).getField());
}
Also used : ColorConverter(common.tetfu.common.ColorConverter) MinoFactory(core.mino.MinoFactory) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest)

Example 9 with ColorConverter

use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.

the class TetfuTest method decode1.

@Test
void decode1() throws Exception {
    String value = "bhzhPexAN";
    MinoFactory factory = new MinoFactory();
    ColorConverter converter = new ColorConverter();
    Tetfu tetfu = new Tetfu(factory, converter);
    List<TetfuPage> pages = tetfu.decode(value);
    assertThat(pages).hasSize(1);
    assertThat(pages.get(0)).returns(ColorType.I, TetfuPage::getColorType).returns(Rotate.Spawn, TetfuPage::getRotate).returns(5, TetfuPage::getX).returns(0, TetfuPage::getY).returns("", TetfuPage::getComment);
    assertField(ColoredFieldFactory.createColoredField("IIII______"), pages.get(0).getField());
}
Also used : ColorConverter(common.tetfu.common.ColorConverter) MinoFactory(core.mino.MinoFactory) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest)

Example 10 with ColorConverter

use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.

the class TetfuTest method decode7.

@Test
void decode7() throws Exception {
    String value = "+gH8AeI8BeH8AeI8KeAgHvhBpoBAAA";
    MinoFactory factory = new MinoFactory();
    ColorConverter converter = new ColorConverter();
    Tetfu tetfu = new Tetfu(factory, converter);
    List<TetfuPage> pages = tetfu.decode(value);
    assertThat(pages).hasSize(3);
    assertThat(pages.get(0)).returns(ColorType.Empty, TetfuPage::getColorType);
    assertThat(pages.get(1)).returns(ColorType.I, TetfuPage::getColorType);
    assertThat(pages.get(2)).returns(ColorType.Empty, TetfuPage::getColorType);
    assertField(ColoredFieldFactory.createColoredField("" + "_XXXXXXXXI" + "_XXXXXXXXI"), pages.get(2).getField());
}
Also used : ColorConverter(common.tetfu.common.ColorConverter) MinoFactory(core.mino.MinoFactory) Test(org.junit.jupiter.api.Test) LongTest(module.LongTest)

Aggregations

ColorConverter (common.tetfu.common.ColorConverter)38 MinoFactory (core.mino.MinoFactory)36 LongTest (module.LongTest)18 Test (org.junit.jupiter.api.Test)18 Tetfu (common.tetfu.Tetfu)13 ColoredField (common.tetfu.field.ColoredField)11 ColorType (common.tetfu.common.ColorType)10 FinderParseException (exceptions.FinderParseException)10 Field (core.field.Field)9 Piece (core.mino.Piece)8 Mino (core.mino.Mino)7 Rotate (core.srs.Rotate)7 List (java.util.List)7 Collectors (java.util.stream.Collectors)7 TetfuPage (common.tetfu.TetfuPage)6 ColoredFieldFactory (common.tetfu.field.ColoredFieldFactory)6 IOException (java.io.IOException)6 Arrays (java.util.Arrays)5 Optional (java.util.Optional)5 BlockField (common.datastore.BlockField)4