use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.
the class TetfuTest method decode5.
@Test
void decode5() throws Exception {
String value = "bhzhFeH8Bex4OvhAAAA";
MinoFactory factory = new MinoFactory();
ColorConverter converter = new ColorConverter();
Tetfu tetfu = new Tetfu(factory, converter);
List<TetfuPage> pages = tetfu.decode(value);
assertThat(pages).hasSize(2);
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());
assertThat(pages.get(1)).returns(ColorType.Empty, TetfuPage::getColorType).returns("", TetfuPage::getComment);
assertField(ColoredFieldFactory.createColoredField("" + "__IIIIIIII" + "__XXXXXXXX"), pages.get(1).getField());
}
use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.
the class TetfuTest method encodeQuiz1.
@Test
void encodeQuiz1() throws Exception {
List<Piece> orders = Collections.singletonList(L);
String quiz = Tetfu.encodeForQuiz(orders);
List<TetfuElement> elements = Collections.singletonList(new TetfuElement(ColorType.L, Rotate.Right, 0, 1, quiz));
MinoFactory factory = new MinoFactory();
ColorConverter converter = new ColorConverter();
Tetfu tetfu = new Tetfu(factory, converter);
String encode = tetfu.encode(elements);
assertThat(encode).isEqualTo("vhAKJYUAFLDmClcJSAVDEHBEooRBMoAVB");
}
use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.
the class TetfuTest method encode2.
@Test
void encode2() throws Exception {
List<TetfuElement> elements = Arrays.asList(new TetfuElement(ColorType.L, Rotate.Spawn, 4, 0), new TetfuElement(ColorType.J, Rotate.Spawn, 8, 0), new TetfuElement(ColorType.I, Rotate.Left, 6, 1), new TetfuElement(ColorType.S, Rotate.Spawn, 4, 1), new TetfuElement(ColorType.Z, Rotate.Spawn, 8, 1), new TetfuElement(ColorType.T, Rotate.Spawn, 4, 3), new TetfuElement(ColorType.O, Rotate.Spawn, 0, 0), new TetfuElement(ColorType.J, Rotate.Right, 0, 3));
MinoFactory factory = new MinoFactory();
ColorConverter converter = new ColorConverter();
Tetfu tetfu = new Tetfu(factory, converter);
String encode = tetfu.encode(elements);
assertThat(encode).isEqualTo("vhHSQJWyBJnBXmBUoBVhBTpBOfB");
}
use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.
the class TetfuTest method decode8.
@Test
void decode8() throws Exception {
String value = "bhD8hlD8JeAgHbhD8h0D8JeAAA";
MinoFactory factory = new MinoFactory();
ColorConverter converter = new ColorConverter();
Tetfu tetfu = new Tetfu(factory, converter);
List<TetfuPage> pages = tetfu.decode(value);
assertThat(pages).hasSize(2);
assertThat(pages.get(0)).returns(ColorType.Empty, TetfuPage::getColorType);
assertThat(pages.get(1)).returns(ColorType.Empty, TetfuPage::getColorType);
assertField(ColoredFieldFactory.createColoredField("XXXXJJXXXX"), pages.get(1).getField());
}
use of common.tetfu.common.ColorConverter in project solution-finder by knewjade.
the class DevRandomEntryPoint method run.
@Override
public void run() throws FinderException {
PatternGenerator generator = createBlockGenerator(pattern);
List<Pieces> blocks = generator.blocksStream().collect(Collectors.toList());
int index = new Random().nextInt(blocks.size());
Pieces selected = blocks.get(index);
String quiz = Tetfu.encodeForQuiz(selected.getPieces());
MinoFactory minoFactory = new MinoFactory();
ColorConverter converter = new ColorConverter();
ColoredField coloredField = getTetfu(minoFactory, converter);
Tetfu tetfu = new Tetfu(minoFactory, converter);
TetfuElement element = new TetfuElement(coloredField, quiz);
String encode = tetfu.encode(Collections.singletonList(element));
System.out.println("v115@" + encode);
}
Aggregations