Skip to content

Commit

Permalink
refactor: rename Axis to WordAxis (#524)
Browse files Browse the repository at this point in the history
* refactor: rename Axis to WordAxis

* chore: update generated files
  • Loading branch information
jsgalarraga authored May 23, 2024
1 parent 05636e8 commit b035220
Show file tree
Hide file tree
Showing 37 changed files with 212 additions and 202 deletions.
3 changes: 2 additions & 1 deletion api/packages/board_renderer/bin/board_render.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ void main(List<String> args) async {
final x = int.parse(values[0]);
final y = int.parse(values[1]);
final answer = values[2];
final axis = values[3] == 'horizontal' ? Axis.horizontal : Axis.vertical;
final axis =
values[3] == 'horizontal' ? WordAxis.horizontal : WordAxis.vertical;
final word = Word(
id: '$x,$y',
position: Point(x, y),
Expand Down
14 changes: 7 additions & 7 deletions api/packages/board_renderer/lib/src/board_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ extension on List<Word> {
minPositionX = math.min(minPositionX, word.position.x);
minPositionY = math.min(minPositionY, word.position.y);

final sizeX = word.axis == Axis.horizontal
final sizeX = word.axis == WordAxis.horizontal
? word.position.x + word.length
: word.position.x;

final sizeY = word.axis == Axis.vertical
final sizeY = word.axis == WordAxis.vertical
? word.position.y + word.length
: word.position.y;

Expand Down Expand Up @@ -191,7 +191,7 @@ class BoardRenderer {
word.position.y * cellSize,
);

final isHorizontal = word.axis == Axis.horizontal;
final isHorizontal = word.axis == WordAxis.horizontal;
final wordCharacters = word.answer.split('');

for (var i = 0; i < wordCharacters.length; i++) {
Expand Down Expand Up @@ -287,10 +287,10 @@ class BoardRenderer {
final charIndex = char.codeUnitAt(0) - 65;

final (dstX, dstY) = (
word.axis == Axis.horizontal
word.axis == WordAxis.horizontal
? (position.$1 + c) * _textureCellSize
: position.$1 * _textureCellSize,
word.axis == Axis.vertical
word.axis == WordAxis.vertical
? (position.$2 + c) * _textureCellSize
: position.$2 * _textureCellSize
);
Expand Down Expand Up @@ -445,10 +445,10 @@ class BoardRenderer {
final charIndex = char.codeUnitAt(0) - 65;

final (dstX, dstY) = (
word.axis == Axis.horizontal
word.axis == WordAxis.horizontal
? (position.$1 + c) * _textureCellSize
: position.$1 * _textureCellSize,
word.axis == Axis.vertical
word.axis == WordAxis.vertical
? (position.$2 + c) * _textureCellSize
: position.$2 * _textureCellSize
);
Expand Down
42 changes: 21 additions & 21 deletions api/packages/board_renderer/test/src/board_renderer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,14 @@ void main() {
Word(
id: '1',
position: Point(1, 1),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
),
Word(
id: '2',
position: Point(2, 7),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand Down Expand Up @@ -117,14 +117,14 @@ void main() {
Word(
id: '1',
position: Point(1, 1),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
),
Word(
id: '2',
position: Point(2, 7),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand Down Expand Up @@ -175,7 +175,7 @@ void main() {
Word(
id: '1',
position: Point(1, 1),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
),
Expand Down Expand Up @@ -249,14 +249,14 @@ void main() {
Word(
id: '1',
position: Point(1, 1),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
),
Word(
id: '2',
position: Point(2, 7),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand Down Expand Up @@ -289,14 +289,14 @@ void main() {
Word(
id: '1',
position: Point(18, 12),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
),
Word(
id: '2',
position: Point(10, 11),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand Down Expand Up @@ -594,14 +594,14 @@ void main() {
Word(
id: '1',
position: Point(18, 12),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
),
Word(
id: '2',
position: Point(10, 11),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand All @@ -617,14 +617,14 @@ void main() {
Word(
id: '1',
position: Point(18, 12),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
),
Word(
id: '2',
position: Point(10, 11),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand All @@ -640,15 +640,15 @@ void main() {
Word(
id: '1',
position: Point(18, 22),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
solvedTimestamp: DateTime.now().millisecondsSinceEpoch,
),
Word(
id: '2',
position: Point(10, 21),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand All @@ -664,15 +664,15 @@ void main() {
Word(
id: '1',
position: Point(28, 12),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
solvedTimestamp: DateTime.now().millisecondsSinceEpoch,
),
Word(
id: '1',
position: Point(20, 11),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand All @@ -688,15 +688,15 @@ void main() {
Word(
id: '1',
position: Point(28, 12),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
solvedTimestamp: DateTime.now().millisecondsSinceEpoch,
),
Word(
id: '2',
position: Point(20, 11),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand Down Expand Up @@ -1018,15 +1018,15 @@ void main() {
Word(
id: '1',
position: Point(18, 12),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hello',
clue: '',
solvedTimestamp: DateTime.now().millisecondsSinceEpoch,
),
Word(
id: '2',
position: Point(10, 11),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: 'there',
clue: '',
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,31 +149,31 @@ void main() {
final word = Word(
id: '1',
position: const Point(1, 1),
axis: Axis.vertical,
axis: WordAxis.vertical,
answer: ' ',
clue: '',
);

final word2 = Word(
id: '2',
position: const Point(1, 1),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'b ',
clue: '',
);

final word3 = Word(
id: '3',
position: const Point(1, 1),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'hap y',
clue: '',
);

final word4 = Word(
id: '4',
position: const Point(1, 4),
axis: Axis.horizontal,
axis: WordAxis.horizontal,
answer: 'solved',
clue: '',
solvedTimestamp: 12343,
Expand Down
6 changes: 3 additions & 3 deletions api/packages/game_domain/lib/src/models/word.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Word extends Equatable {

/// The axis of the word in the board.
@JsonKey()
final Axis axis;
final WordAxis axis;

/// The clue to show users when guessing for the first time.
@JsonKey()
Expand Down Expand Up @@ -91,7 +91,7 @@ class Word extends Equatable {
Word copyWith({
String? id,
Point<int>? position,
Axis? axis,
WordAxis? axis,
String? clue,
String? answer,
int? solvedTimestamp,
Expand Down Expand Up @@ -121,7 +121,7 @@ class Word extends Equatable {
}

/// The two possible axis for a word in the board.
enum Axis {
enum WordAxis {
/// From left to right.
horizontal,

Expand Down
10 changes: 5 additions & 5 deletions api/packages/game_domain/lib/src/models/word.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b035220

Please sign in to comment.