Skip to content
Snippets Groups Projects
Commit 3c1d2280 authored by Benoît Harrault's avatar Benoît Harrault
Browse files

Avoid print calls in production code

parent 596f89c6
No related branches found
No related tags found
1 merge request!38Resolve "Avoid print calls in production code"
Pipeline #5259 passed
org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=0.1.14
app.versionCode=35
app.versionName=0.1.15
app.versionCode=36
Avoid print calls in production code.
Supprime les appels à print dans le code de production.
......@@ -2,6 +2,7 @@ import 'dart:math';
import 'package:minehunter/entities/cell.dart';
import 'package:minehunter/provider/data.dart';
import 'package:minehunter/utils/tools.dart';
class BoardUtils {
static printGrid(List cells) {
......@@ -13,12 +14,12 @@ class BoardUtils {
const String exploredSafeCell = '.';
const String unkownState = ' ';
print('');
printlog('');
String line = '--';
for (int i = 0; i < cells[0].length; i++) {
line += '-';
}
print('$line $line');
printlog('$line $line');
for (int rowIndex = 0; rowIndex < cells.length; rowIndex++) {
String currentLine = '';
String solvedLine = '';
......@@ -38,10 +39,10 @@ class BoardUtils {
}
currentLine += cellString;
}
print('|$currentLine| |$solvedLine|');
printlog('|$currentLine| |$solvedLine|');
}
print('$line $line');
print('');
printlog('$line $line');
printlog('');
}
static List<List<Cell>> createEmptyBoard(int sizeHorizontal, int sizeVertical) {
......@@ -84,7 +85,7 @@ class BoardUtils {
final int minesCount = ((sizeHorizontal * sizeVertical) * minesCountRatio / 100).round();
print('Mines count: $minesCount');
printlog('Mines count: $minesCount');
return minesCount;
}
......@@ -255,7 +256,7 @@ class BoardUtils {
}
}
print('-> ok all mines found!');
printlog('-> ok all mines found!');
myProvider.updateGameWin(true);
return true;
......
import 'package:minehunter/provider/data.dart';
import 'package:minehunter/utils/board_animate.dart';
import 'package:minehunter/utils/board_utils.dart';
import 'package:minehunter/utils/tools.dart';
class GameUtils {
static Future<void> quitGame(Data myProvider) async {
......@@ -11,7 +12,7 @@ class GameUtils {
}
static void startNewGame(Data myProvider) {
print('Starting game: ${myProvider.parameterSize} - ${myProvider.parameterLevel}');
printlog('Starting game: ${myProvider.parameterSize} - ${myProvider.parameterLevel}');
myProvider.updateParameterSize(myProvider.parameterSize);
myProvider.updateMinesCount(BoardUtils.getMinesCount(
myProvider.sizeHorizontal, myProvider.sizeVertical, myProvider.parameterLevel));
......@@ -36,7 +37,7 @@ class GameUtils {
BoardUtils.createBoardFromSavedState(myProvider, savedState['board']));
myProvider.updateGameIsRunning(true);
} catch (e) {
print('Failed to resume game. Will start new one instead.');
printlog('Failed to resume game. Will start new one instead.');
myProvider.resetCurrentSavedState();
myProvider.initParametersValues();
startNewGame(myProvider);
......
import 'package:flutter/foundation.dart';
void printlog(String message) {
if (!kReleaseMode) {
debugPrint(message);
}
}
......@@ -151,10 +151,10 @@ packages:
dependency: "direct main"
description:
name: provider
sha256: "9a96a0a19b594dbc5bf0f1f27d2bc67d5f95957359b461cd9feb44ed6ae75096"
sha256: c8a055ee5ce3fd98d6fc872478b03823ffdb448699c6ebdbbc71d59b596fd48c
url: "https://pub.dev"
source: hosted
version: "6.1.1"
version: "6.1.2"
shared_preferences:
dependency: "direct main"
description:
......
name: minehunter
description: A minehunter game application.
publish_to: 'none'
version: 0.1.14+35
version: 0.1.15+36
environment:
sdk: '^3.0.0'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment