155 lines
4.1 KiB
Java
155 lines
4.1 KiB
Java
package ch.fritteli.maze.generator.renderer.text;
|
|
|
|
import lombok.AccessLevel;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.EqualsAndHashCode;
|
|
import lombok.NoArgsConstructor;
|
|
import lombok.experimental.FieldDefaults;
|
|
|
|
@AllArgsConstructor
|
|
@EqualsAndHashCode
|
|
@FieldDefaults(level = AccessLevel.PRIVATE)
|
|
@NoArgsConstructor
|
|
class CharDefinition {
|
|
// ─
|
|
static final String HORIZONTAL = "\u2500";
|
|
// │
|
|
static final String VERTICAL = "\u2502";
|
|
// ╴
|
|
static final String LEFT = "\u2574";
|
|
// ╵
|
|
static final String UP = "\u2575";
|
|
// ╶
|
|
static final String RIGHT = "\u2576";
|
|
// ╷
|
|
static final String DOWN = "\u2577";
|
|
// ┌
|
|
static final String DOWN_RIGHT = "\u250c";
|
|
// ┐
|
|
static final String DOWN_LEFT = "\u2510";
|
|
// └
|
|
static final String UP_RIGHT = "\u2514";
|
|
// ┘
|
|
static final String UP_LEFT = "\u2518";
|
|
// ├
|
|
static final String VERTICAL_RIGHT = "\u251c";
|
|
// ┤
|
|
static final String VERTICAL_LEFT = "\u2524";
|
|
// ┬
|
|
static final String HORIZONTAL_DOWN = "\u252c";
|
|
// ┴
|
|
static final String HORIZONTAL_UP = "\u2534";
|
|
// ┼
|
|
static final String CROSS = "\u253c";
|
|
// ╭
|
|
static final String SOLUTION_DOWN_RIGHT = "\u256d";
|
|
// ╮
|
|
static final String SOLUTION_DOWN_LEFT = "\u256e";
|
|
// ╯
|
|
static final String SOLUTION_UP_LEFT = "\u256f";
|
|
// ╰
|
|
static final String SOLUTION_UP_RIGHT = "\u2570";
|
|
boolean up = false;
|
|
boolean down = false;
|
|
boolean left = false;
|
|
boolean right = false;
|
|
boolean solution = false;
|
|
|
|
CharDefinition solution() {
|
|
this.solution = true;
|
|
return this;
|
|
}
|
|
|
|
CharDefinition up() {
|
|
this.up = true;
|
|
return this;
|
|
}
|
|
|
|
CharDefinition down() {
|
|
this.down = true;
|
|
return this;
|
|
}
|
|
|
|
CharDefinition vertical() {
|
|
return this.up().down();
|
|
}
|
|
|
|
CharDefinition left() {
|
|
this.left = true;
|
|
return this;
|
|
}
|
|
|
|
CharDefinition right() {
|
|
this.right = true;
|
|
return this;
|
|
}
|
|
|
|
CharDefinition horizontal() {
|
|
return this.left().right();
|
|
}
|
|
|
|
public String toString() {
|
|
if (this.up) {
|
|
if (this.down) {
|
|
if (this.left) {
|
|
if (this.right) {
|
|
return CROSS;
|
|
} else {
|
|
return VERTICAL_LEFT;
|
|
}
|
|
} else {
|
|
if (this.right) {
|
|
return VERTICAL_RIGHT;
|
|
} else {
|
|
return VERTICAL;
|
|
}
|
|
}
|
|
} else {
|
|
if (this.left) {
|
|
if (this.right) {
|
|
return HORIZONTAL_UP;
|
|
} else {
|
|
return this.solution ? SOLUTION_UP_LEFT : UP_LEFT;
|
|
}
|
|
} else {
|
|
if (this.right) {
|
|
return this.solution ? SOLUTION_UP_RIGHT : UP_RIGHT;
|
|
} else {
|
|
return UP;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (this.down) {
|
|
if (this.left) {
|
|
if (this.right) {
|
|
return HORIZONTAL_DOWN;
|
|
} else {
|
|
return this.solution ? SOLUTION_DOWN_LEFT : DOWN_LEFT;
|
|
}
|
|
} else {
|
|
if (this.right) {
|
|
return this.solution ? SOLUTION_DOWN_RIGHT : DOWN_RIGHT;
|
|
} else {
|
|
return DOWN;
|
|
}
|
|
}
|
|
} else {
|
|
if (this.left) {
|
|
if (this.right) {
|
|
return HORIZONTAL;
|
|
} else {
|
|
return LEFT;
|
|
}
|
|
} else {
|
|
if (this.right) {
|
|
return RIGHT;
|
|
} else {
|
|
return " ";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|