Skip to content

Commit

Permalink
refactor: parse board as csv to render wireframe
Browse files Browse the repository at this point in the history
  • Loading branch information
jsgalarraga committed Jun 3, 2024
1 parent 1df53a6 commit 312a59e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
17 changes: 10 additions & 7 deletions api/packages/board_renderer/bin/board_render.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import 'dart:io';
import 'dart:typed_data';

import 'package:board_renderer/board_renderer.dart';
import 'package:csv/csv.dart';
import 'package:game_domain/game_domain.dart';

class RenderAssetResolver with AssetResolver {
Expand Down Expand Up @@ -36,14 +37,16 @@ void main(List<String> args) async {
final boardFile = File(args[0]);

if (boardFile.existsSync()) {
final boardRaw = boardFile.readAsLinesSync();
final boardRaw = boardFile.readAsStringSync();
final rows = const CsvToListConverter().convert(boardRaw);

final words = boardRaw.map((line) => line.split(',')).map((values) {
final x = int.parse(values[0]);
final y = int.parse(values[1]);
final answer = values[2];
final axis =
values[3] == 'horizontal' ? WordAxis.horizontal : WordAxis.vertical;
final words = rows.map((values) {
final x = values[0] as int;
final y = values[1] as int;
final answer = values[2] as String;
final axis = values[4] == WordAxis.horizontal.name
? WordAxis.horizontal
: WordAxis.vertical;
final word = Word(
id: '$x,$y',
position: Point(x, y),
Expand Down
1 change: 1 addition & 0 deletions api/packages/board_renderer/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ environment:
sdk: "^3.3.0"

dependencies:
csv: ^6.0.0
game_domain:
path: ../game_domain
http: ^1.2.1
Expand Down

0 comments on commit 312a59e

Please sign in to comment.