Skip to content

Commit

Permalink
Merge branch 'main' into chore/unifies-leaderboard-score-card
Browse files Browse the repository at this point in the history
  • Loading branch information
AyadLaouissi authored Apr 16, 2024
2 parents 988aae9 + e48cbf4 commit 6ed1656
Show file tree
Hide file tree
Showing 46 changed files with 8,615 additions and 5,207 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 @@ -44,11 +44,12 @@ void main(List<String> args) async {
final answer = values[2];
final axis = values[3] == 'horizontal' ? Axis.horizontal : Axis.vertical;
final word = Word(
id: '$x,$y',
position: Point(x, y),
axis: axis,
answer: answer,
length: answer.length,
clue: '',
solvedTimestamp: null,
);

return word;
Expand Down
10 changes: 5 additions & 5 deletions api/packages/board_renderer/lib/src/board_renderer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ extension on List<Word> {
minPositionY = math.min(minPositionY, word.position.y);

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

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

maxPositionX = math.max(maxPositionX, sizeX);
Expand Down Expand Up @@ -192,7 +192,7 @@ class BoardRenderer {
);

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

for (var i = 0; i < wordCharacters.length; i++) {
final x1 =
Expand Down Expand Up @@ -280,7 +280,7 @@ class BoardRenderer {

final position = (x, y);

final wordCharacters = word.answer.split('');
final wordCharacters = word.answer!.split('');

for (var c = 0; c < wordCharacters.length; c++) {
final char = wordCharacters.elementAt(c).toUpperCase();
Expand Down Expand Up @@ -438,7 +438,7 @@ class BoardRenderer {

final position = (x, y);

final wordCharacters = word.answer.split('');
final wordCharacters = word.answer!.split('');

for (var c = 0; c < wordCharacters.length; c++) {
final char = wordCharacters.elementAt(c).toUpperCase();
Expand Down
63 changes: 44 additions & 19 deletions api/packages/board_renderer/test/src/board_renderer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,18 +58,20 @@ void main() {

final words = [
Word(
id: '1',
position: Point(1, 1),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: null,
),
Word(
id: '2',
position: Point(2, 7),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
];

Expand Down Expand Up @@ -115,18 +117,20 @@ void main() {

final words = [
Word(
id: '1',
position: Point(1, 1),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: null,
),
Word(
id: '2',
position: Point(2, 7),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
];

Expand Down Expand Up @@ -173,11 +177,12 @@ void main() {

final words = [
Word(
id: '1',
position: Point(1, 1),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: null,
),
];

Expand Down Expand Up @@ -247,18 +252,20 @@ void main() {

final words = [
Word(
id: '1',
position: Point(1, 1),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: null,
),
Word(
id: '2',
position: Point(2, 7),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
];

Expand Down Expand Up @@ -287,18 +294,20 @@ void main() {

final words = [
Word(
id: '1',
position: Point(18, 12),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: null,
),
Word(
id: '2',
position: Point(10, 11),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
];

Expand Down Expand Up @@ -590,20 +599,22 @@ void main() {
id: '',
position: Point(1, 1),
size: 10,
words: [
words: const [
Word(
id: '1',
position: Point(18, 12),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: null,
),
Word(
id: '2',
position: Point(10, 11),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
],
borderWords: const [],
Expand All @@ -613,20 +624,22 @@ void main() {
id: '',
position: Point(2, 1),
size: 10,
words: [
words: const [
Word(
id: '1',
position: Point(18, 12),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: null,
),
Word(
id: '2',
position: Point(10, 11),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
],
borderWords: const [],
Expand All @@ -638,18 +651,21 @@ void main() {
size: 10,
words: [
Word(
id: '1',
position: Point(18, 22),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: DateTime.now().millisecondsSinceEpoch,
),
Word(
id: '2',
position: Point(10, 21),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
],
borderWords: const [],
Expand All @@ -661,18 +677,21 @@ void main() {
size: 10,
words: [
Word(
id: '1',
position: Point(28, 12),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: DateTime.now().millisecondsSinceEpoch,
),
Word(
id: '1',
position: Point(20, 11),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
],
borderWords: const [],
Expand All @@ -684,18 +703,21 @@ void main() {
size: 10,
words: [
Word(
id: '1',
position: Point(28, 12),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: DateTime.now().millisecondsSinceEpoch,
),
Word(
id: '2',
position: Point(20, 11),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
],
borderWords: const [],
Expand Down Expand Up @@ -1013,18 +1035,21 @@ void main() {

final words = [
Word(
id: '1',
position: Point(18, 12),
axis: Axis.horizontal,
answer: 'hello',
length: 5,
clue: '',
solvedTimestamp: DateTime.now().millisecondsSinceEpoch,
),
Word(
id: '2',
position: Point(10, 11),
axis: Axis.vertical,
answer: 'there',
length: 5,
clue: '',
solvedTimestamp: null,
),
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,12 @@ void main() {
group('answerWord', () {
late CrosswordRepository repository;
final word = Word(
id: '1',
position: const Point(1, 1),
axis: Axis.vertical,
answer: 'flutter',
length: 7,
clue: '',
solvedTimestamp: null,
);

setUp(() {
Expand All @@ -157,7 +158,10 @@ void main() {
'position': {'x': 1, 'y': 1},
'size': 300,
'words': [
word.toJson(),
{
'id': '1',
...word.toJson(),
},
],
'borderWords': const <dynamic>[],
},
Expand Down
Loading

0 comments on commit 6ed1656

Please sign in to comment.