Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision
  • 27-improve-app-metadata
  • 6-fix-display-grid
  • master
  • Release_1.0.10_11
  • Release_1.0.11_12
  • Release_1.0.12_13
  • Release_1.0.13_14
  • Release_1.0.14_15
  • Release_1.0.15_16
  • Release_1.0.16_17
  • Release_1.0.17_18
  • Release_1.0.18_19
  • Release_1.0.19_20
  • Release_1.0.20_21
  • Release_1.0.21_22
  • Release_1.0.5_6
  • Release_1.0.6_7
  • Release_1.0.7_8
  • Release_1.0.8_9
  • Release_1.0.9_10
  • Release_1.1.0_23
  • Release_1.2.0_24
  • Release_1.2.1_25
  • Release_1.3.0_26
  • Release_1.3.1_27
  • Release_1.4.0_28
  • Release_1.4.1_29
  • Release_1.4.2_30
  • Release_1.4.3_31
  • Release_1.5.0_32
  • Release_1.6.0_33
  • Release_1.7.0_34
  • Release_1.8.0_35
  • Release_1.8.1_36
  • Release_1.8.2_37
  • Release_1.9.0_38
  • Release_1.9.1_39
37 results

Target

Select target project
  • android/puissance4
1 result
Select Git revision
  • 27-improve-app-metadata
  • 6-fix-display-grid
  • master
  • Release_1.0.10_11
  • Release_1.0.11_12
  • Release_1.0.12_13
  • Release_1.0.13_14
  • Release_1.0.14_15
  • Release_1.0.15_16
  • Release_1.0.16_17
  • Release_1.0.17_18
  • Release_1.0.18_19
  • Release_1.0.19_20
  • Release_1.0.20_21
  • Release_1.0.21_22
  • Release_1.0.5_6
  • Release_1.0.6_7
  • Release_1.0.7_8
  • Release_1.0.8_9
  • Release_1.0.9_10
  • Release_1.1.0_23
  • Release_1.2.0_24
  • Release_1.2.1_25
  • Release_1.3.0_26
  • Release_1.3.1_27
  • Release_1.4.0_28
  • Release_1.4.1_29
  • Release_1.4.2_30
  • Release_1.4.3_31
  • Release_1.5.0_32
  • Release_1.6.0_33
  • Release_1.7.0_34
  • Release_1.8.0_35
  • Release_1.8.1_36
  • Release_1.8.2_37
  • Release_1.9.0_38
  • Release_1.9.1_39
37 results
Show changes

Commits on Source 2

org.gradle.jvmargs=-Xmx1536M
android.useAndroidX=true
android.enableJetifier=true
app.versionName=1.0.10
app.versionCode=11
app.versionName=1.0.11
app.versionCode=12
......@@ -3,7 +3,7 @@ import 'package:puissance4/coordinate.dart';
import 'match_page.dart';
class Board {
List<List<Color>> _boxes = List.generate(
List<List<Color?>> _boxes = List.generate(
7,
(i) => List.generate(
7,
......@@ -13,33 +13,34 @@ class Board {
Board();
Board.from(List<List<Color>> boxes) {
Board.from(List<List<Color?>> boxes) {
_boxes = boxes;
}
Color getBox(Coordinate coordinate) => _boxes[coordinate.col][coordinate.row];
Color? getBox(Coordinate coordinate) =>
_boxes[coordinate.col ?? 0][coordinate.row ?? 0];
int getColumnTarget(int col) => _boxes[col].lastIndexOf(null);
int getColumnTarget(int? col) => _boxes[col ?? 0].lastIndexOf(null);
void setBox(Coordinate coordinate, Color player) =>
_boxes[coordinate.col][coordinate.row] = player;
void setBox(Coordinate coordinate, Color? player) =>
_boxes[coordinate.col ?? 0][coordinate.row ?? 0] = player;
void reset() {
_boxes.forEach((r) => r.forEach((p) => p = null));
}
bool checkWinner(Coordinate coordinate, Color player) {
bool checkWinner(Coordinate coordinate, Color? player) {
return checkHorizontally(coordinate, player) ||
checkVertically(coordinate, player) ||
checkDiagonally(coordinate, player);
}
bool checkHorizontally(Coordinate coordinate, Color player) {
bool checkHorizontally(Coordinate coordinate, Color? player) {
var r = 0;
for (;
coordinate.col + r < 7 &&
(coordinate.col ?? 0) + r < 7 &&
r < 4 &&
getBox(coordinate.copyWith(col: coordinate.col + r)) == player;
getBox(coordinate.copyWith(col: (coordinate.col ?? 0) + r)) == player;
++r) {}
if (r >= 4) {
return true;
......@@ -47,9 +48,9 @@ class Board {
var l = 0;
for (;
coordinate.col - l >= 0 &&
(coordinate.col ?? 0) - l >= 0 &&
l < 4 &&
getBox(coordinate.copyWith(col: coordinate.col - l)) == player;
getBox(coordinate.copyWith(col: (coordinate.col ?? 0) - l)) == player;
++l) {}
if (l >= 4 || l + r >= 5) {
return true;
......@@ -58,15 +59,15 @@ class Board {
return false;
}
bool checkDiagonally(Coordinate coordinate, Color player) {
bool checkDiagonally(Coordinate coordinate, Color? player) {
var ur = 0;
for (;
coordinate.col + ur < 7 &&
coordinate.row + ur < 7 &&
(coordinate.col ?? 0) + ur < 7 &&
(coordinate.row ?? 0) + ur < 7 &&
ur < 4 &&
getBox(coordinate.copyWith(
col: coordinate.col + ur,
row: coordinate.row + ur,
col: (coordinate.col ?? 0) + ur,
row: (coordinate.row ?? 0) + ur,
)) ==
player;
++ur) {}
......@@ -75,12 +76,12 @@ class Board {
}
var dl = 0;
for (;
coordinate.col - dl >= 0 &&
coordinate.row - dl >= 0 &&
(coordinate.col ?? 0) - dl >= 0 &&
(coordinate.row ?? 0) - dl >= 0 &&
dl < 4 &&
getBox(coordinate.copyWith(
col: coordinate.col - dl,
row: coordinate.row - dl,
col: (coordinate.col ?? 0) - dl,
row: (coordinate.row ?? 0) - dl,
)) ==
player;
++dl) {}
......@@ -90,12 +91,12 @@ class Board {
var dr = 0;
for (;
coordinate.col + dr < 7 &&
coordinate.row - dr >= 0 &&
(coordinate.col ?? 0) + dr < 7 &&
(coordinate.row ?? 0) - dr >= 0 &&
dr < 4 &&
getBox(coordinate.copyWith(
col: coordinate.col + dr,
row: coordinate.row - dr,
col: (coordinate.col ?? 0) + dr,
row: (coordinate.row ?? 0) - dr,
)) ==
player;
++dr) {}
......@@ -105,12 +106,12 @@ class Board {
var ul = 0;
for (;
coordinate.col - ul >= 0 &&
coordinate.row + ul < 7 &&
(coordinate.col ?? 0) - ul >= 0 &&
(coordinate.row ?? 0) + ul < 7 &&
ul < 4 &&
getBox(coordinate.copyWith(
col: coordinate.col - ul,
row: coordinate.row + ul,
col: (coordinate.col ?? 0) - ul,
row: (coordinate.row ?? 0) + ul,
)) ==
player;
++ul) {}
......@@ -120,13 +121,13 @@ class Board {
return false;
}
bool checkVertically(Coordinate coordinate, Color player) {
bool checkVertically(Coordinate coordinate, Color? player) {
var u = 0;
for (;
coordinate.row + u < 7 &&
(coordinate.row ?? 0) + u < 7 &&
u < 4 &&
getBox(coordinate.copyWith(
row: coordinate.row + u,
row: (coordinate.row ?? 0) + u,
)) ==
player;
++u) {}
......@@ -135,10 +136,10 @@ class Board {
}
var d = 0;
for (;
coordinate.row - d >= 0 &&
(coordinate.row ?? 0) - d >= 0 &&
d < 4 &&
getBox(coordinate.copyWith(
row: coordinate.row - d,
row: (coordinate.row ?? 0) - d,
)) ==
player;
++d) {}
......
class Coordinate {
final int row, col;
final int? row, col;
Coordinate(
this.col,
......@@ -7,8 +7,8 @@ class Coordinate {
);
Coordinate copyWith({
int col,
int row,
int? col,
int? row,
}) =>
Coordinate(
col ?? this.col,
......
......@@ -37,13 +37,13 @@ class HarderCpu extends Cpu {
@override
Future<int> chooseCol(Board board) async {
final List<double> scores = List.filled(7, 0);
final List<double?> scores = List.filled(7, 0.0);
await Future.delayed(Duration(seconds: 1 + _random.nextInt(2)));
return _compute(board, 0, 1, scores);
}
int _compute(Board board, int step, int deepness, List<double> scores) {
int _compute(Board board, int step, int deepness, List<double?> scores) {
for (var i = 0; i < 7; ++i) {
final boardCopy = board.clone();
......@@ -57,7 +57,7 @@ class HarderCpu extends Cpu {
boardCopy.setBox(coordinate, color);
if (boardCopy.checkWinner(coordinate, color)) {
scores[i] += deepness / (step + 1);
scores[i] = (scores[i] ?? 0) + deepness / (step + 1);
continue;
}
......@@ -71,7 +71,7 @@ class HarderCpu extends Cpu {
boardCopy.setBox(coordinate, otherPlayer);
if (boardCopy.checkWinner(coordinate, otherPlayer)) {
scores[i] -= deepness / (step + 1);
scores[i] = (scores[i] ?? 0) - deepness / (step + 1);
continue;
}
......@@ -84,11 +84,11 @@ class HarderCpu extends Cpu {
return _getBestScoreIndex(scores);
}
int _getBestScoreIndex(List<double> scores) {
int _getBestScoreIndex(List<double?> scores) {
int bestScoreIndex = scores.indexWhere((s) => s != null);
scores.asMap().forEach((index, score) {
if (score != null &&
(score > scores[bestScoreIndex] ||
(score > (scores[bestScoreIndex] ?? 0) ||
(score == scores[bestScoreIndex] && _random.nextBool()))) {
bestScoreIndex = index;
}
......@@ -105,7 +105,7 @@ class HardestCpu extends HarderCpu {
@override
Future<int> chooseCol(Board board) async {
final List<double> scores = List.filled(7, 0);
final List<double?> scores = List.filled(7, 0);
await Future.delayed(Duration(seconds: 2 + _random.nextInt(2)));
return _compute(board, 0, 4, scores);
......
......@@ -19,15 +19,15 @@ class CpuLevelPage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
FlatButton(
color: Colors.yellow,
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.yellow,
padding: EdgeInsets.all(15),
),
child: Text(
'☺️ FACILE',
style: Theme.of(context)
.textTheme
.headline4
.copyWith(color: Colors.black),
style:
Theme.of(context).textTheme.headline4?.copyWith(color: Colors.black),
),
onPressed: () {
Navigator.pushNamed(
......@@ -35,21 +35,20 @@ class CpuLevelPage extends StatelessWidget {
'/match',
arguments: {
'mode': Mode.PVC,
'cpu':
DumbCpu(Random().nextBool() ? Color.RED : Color.YELLOW),
'cpu': DumbCpu(Random().nextBool() ? Color.RED : Color.YELLOW),
},
);
},
),
FlatButton(
color: Colors.red,
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.red,
padding: EdgeInsets.all(15),
),
child: Text(
'🤔 DIFFICILE',
style: Theme.of(context)
.textTheme
.headline4
.copyWith(color: Colors.white),
style:
Theme.of(context).textTheme.headline4?.copyWith(color: Colors.white),
),
onPressed: () {
Navigator.pushNamed(
......@@ -57,21 +56,20 @@ class CpuLevelPage extends StatelessWidget {
'/match',
arguments: {
'mode': Mode.PVC,
'cpu': HarderCpu(
Random().nextBool() ? Color.RED : Color.YELLOW),
'cpu': HarderCpu(Random().nextBool() ? Color.RED : Color.YELLOW),
},
);
},
),
FlatButton(
color: Colors.deepPurpleAccent,
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.deepPurpleAccent,
padding: EdgeInsets.all(15),
),
child: Text(
'🤯 TRES DIFFICILE',
style: Theme.of(context)
.textTheme
.headline4
.copyWith(color: Colors.white),
style:
Theme.of(context).textTheme.headline4?.copyWith(color: Colors.white),
),
onPressed: () {
Navigator.pushNamed(
......@@ -79,8 +77,7 @@ class CpuLevelPage extends StatelessWidget {
'/match',
arguments: {
'mode': Mode.PVC,
'cpu': HardestCpu(
Random().nextBool() ? Color.RED : Color.YELLOW),
'cpu': HardestCpu(Random().nextBool() ? Color.RED : Color.YELLOW),
},
);
},
......
......@@ -4,13 +4,13 @@ import 'match_page.dart';
class GameChip extends StatelessWidget {
const GameChip({
Key key,
Key? key,
this.translation,
@required this.color,
this.color,
}) : super(key: key);
final Animation<double> translation;
final Color color;
final Animation<double>? translation;
final Color? color;
@override
Widget build(BuildContext context) {
......
......@@ -16,15 +16,15 @@ class HomePage extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.max,
children: <Widget>[
FlatButton(
color: Colors.green,
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.green,
padding: EdgeInsets.all(15),
),
child: Text(
'🧑 2 JOUEURS 🧑',
style: Theme.of(context)
.textTheme
.headline4
.copyWith(color: Colors.white),
style:
Theme.of(context).textTheme.headline4?.copyWith(color: Colors.white),
),
onPressed: () {
Navigator.pushNamed(
......@@ -36,15 +36,15 @@ class HomePage extends StatelessWidget {
);
},
),
FlatButton(
color: Colors.orange,
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.orange,
padding: EdgeInsets.all(15),
),
child: Text(
'🧑 1 JOUEUR 🤖',
style: Theme.of(context)
.textTheme
.headline4
.copyWith(color: Colors.white),
style:
Theme.of(context).textTheme.headline4?.copyWith(color: Colors.white),
),
onPressed: () {
Navigator.pushNamed(
......@@ -56,15 +56,15 @@ class HomePage extends StatelessWidget {
);
},
),
FlatButton(
color: Colors.white,
TextButton(
style: TextButton.styleFrom(
backgroundColor: Colors.white,
padding: EdgeInsets.all(15),
),
child: Text(
'🤖 DEMO 🤖',
style: Theme.of(context)
.textTheme
.headline4
.copyWith(color: Colors.black),
style:
Theme.of(context).textTheme.headline4?.copyWith(color: Colors.black),
),
onPressed: () {
final harderCpu =
......
......@@ -14,7 +14,7 @@ class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter fiar',
title: 'Puissance 4',
theme: ThemeData(
primarySwatch: Colors.blue,
),
......
......@@ -21,14 +21,14 @@ enum Mode {
class MatchPage extends StatefulWidget {
final Mode mode;
final Cpu cpu;
final Cpu cpu2;
final Cpu? cpu;
final Cpu? cpu2;
const MatchPage({
Key key,
this.mode,
this.cpu,
this.cpu2,
Key? key,
required this.mode,
required this.cpu,
required this.cpu2,
}) : super(key: key);
@override
......@@ -37,10 +37,10 @@ class MatchPage extends StatefulWidget {
class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
final board = Board();
Color turn;
Color winner;
Color? turn;
Color? winner;
List<List<Animation<double>>> translations = List.generate(
List<List<Animation<double>?>> translations = List.generate(
7,
(i) => List.generate(
7,
......@@ -73,7 +73,6 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
child: Padding(
padding: const EdgeInsets.only(top: 32.0),
child: Stack(
overflow: Overflow.clip,
fit: StackFit.loose,
children: <Widget>[
Positioned.fill(
......@@ -99,7 +98,7 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
style: Theme.of(context)
.textTheme
.headline6
.copyWith(color: Colors.white),
?.copyWith(color: Colors.white),
)
: Column(
children: <Widget>[
......@@ -109,11 +108,13 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
style: Theme.of(context)
.textTheme
.headline5
.copyWith(color: Colors.white),
?.copyWith(color: Colors.white),
),
Padding(
padding: const EdgeInsets.all(8.0),
child: GameChip(color: turn),
child: GameChip(
color: turn,
),
),
_buildPlayerName(context),
],
......@@ -130,7 +131,7 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
String name;
if (widget.mode == Mode.PVC) {
if (turn == widget.cpu.color) {
if (turn == widget.cpu?.color) {
name = 'CPU - ${widget.cpu.toString()}';
} else {
name = 'USER';
......@@ -142,7 +143,7 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
name = 'PLAYER2';
}
} else {
if (turn == widget.cpu.color) {
if (turn == widget.cpu?.color) {
name = 'CPU1 - ${widget.cpu.toString()}';
} else {
name = 'CPU2 - ${widget.cpu2.toString()}';
......@@ -151,22 +152,18 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
return Text(
name,
textAlign: TextAlign.center,
style: Theme.of(context)
.textTheme
.headline5
.copyWith(color: Colors.white),
style: Theme.of(context).textTheme.headline5?.copyWith(color: Colors.white),
);
}
@override
void initState() {
super.initState();
turn = widget.cpu?.otherPlayer ??
(Random().nextBool() ? Color.RED : Color.YELLOW);
if (widget.mode == Mode.PVC && turn == widget.cpu.color) {
turn = Random().nextBool() ? Color.RED : Color.YELLOW;
if (widget.mode == Mode.PVC && turn == widget.cpu?.color) {
cpuMove(widget.cpu);
} else if (widget.mode == Mode.DEMO) {
if (turn == widget.cpu.color) {
if (turn == widget.cpu?.color) {
cpuMove(widget.cpu);
} else {
cpuMove(widget.cpu2);
......@@ -179,8 +176,7 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
padding: const EdgeInsets.all(0),
shrinkWrap: true,
physics: NeverScrollableScrollPhysics(),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 7),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 7),
childrenDelegate: SliverChildBuilderDelegate(
(context, i) {
final col = i % 7;
......@@ -204,8 +200,7 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
return GridView.custom(
padding: const EdgeInsets.all(0),
physics: NeverScrollableScrollPhysics(),
gridDelegate:
SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 7),
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(crossAxisCount: 7),
shrinkWrap: true,
childrenDelegate: SliverChildBuilderDelegate(
(context, i) {
......@@ -236,12 +231,12 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
}
}
void cpuMove(Cpu cpu) async {
int col = await cpu.chooseCol(board);
void cpuMove(Cpu? cpu) async {
int? col = await cpu?.chooseCol(board);
putChip(col);
if (winner == null && widget.mode == Mode.DEMO) {
if (turn == widget.cpu.color) {
if (turn == widget.cpu?.color) {
cpuMove(widget.cpu);
} else {
cpuMove(widget.cpu2);
......@@ -249,7 +244,7 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
}
}
void putChip(int col) {
void putChip(int? col) {
final target = board.getColumnTarget(col);
final player = turn;
......@@ -273,7 +268,7 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
});
}
translations[col][target] = Tween(
translations[col ?? 0][target] = Tween(
begin: 0.0,
end: 1.0,
).animate(CurvedAnimation(
......@@ -293,7 +288,7 @@ class _MatchPageState extends State<MatchPage> with TickerProviderStateMixin {
}
}
void showWinnerDialog(BuildContext context, Color player) {
void showWinnerDialog(BuildContext context, Color? player) {
setState(() {
winner = player;
});
......
......@@ -42,14 +42,14 @@ packages:
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "1.15.0"
version: "1.16.0"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
version: "1.3.0"
flutter:
dependency: "direct main"
description: flutter
......@@ -73,7 +73,7 @@ packages:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
version: "0.1.4"
meta:
dependency: transitive
description:
......@@ -87,7 +87,7 @@ packages:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.0"
version: "1.8.1"
sky_engine:
dependency: transitive
description: flutter
......@@ -99,7 +99,7 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.8.1"
version: "1.8.2"
stack_trace:
dependency: transitive
description:
......@@ -134,20 +134,13 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.4.8"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
version: "0.4.9"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
version: "2.1.2"
sdks:
dart: ">=2.14.0 <3.0.0"
dart: ">=2.17.0-0 <3.0.0"
......@@ -4,7 +4,7 @@ publish_to: 'none'
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
sdk: ">=2.12.0 <3.0.0"
dependencies:
flutter:
......