Refactoring
parent
7cf6ab5f4d
commit
aab6fc4af5
|
@ -1,12 +1,12 @@
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import 'package:bubbletwist/game/stone/SpecialStone.dart';
|
import 'package:bubbletwist/game/stone/special_stone.dart';
|
||||||
|
|
||||||
import '../enums/StoneColor.dart';
|
import '../enums/stone_color.dart';
|
||||||
import 'Game.dart';
|
import 'game.dart';
|
||||||
import 'stone/PentaSpecialStone.dart';
|
import 'stone/penta_special_stone.dart';
|
||||||
import 'stone/Stone.dart';
|
import 'stone/stone.dart';
|
||||||
import 'stone/StoneLocation.dart';
|
import 'stone/stone_location.dart';
|
||||||
|
|
||||||
class Board {
|
class Board {
|
||||||
static const int boardSize = 8;
|
static const int boardSize = 8;
|
|
@ -1,10 +1,10 @@
|
||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
|
||||||
import '../enums/StoneColor.dart';
|
import '../enums/stone_color.dart';
|
||||||
import 'Board.dart';
|
import 'board.dart';
|
||||||
import 'IGameConsumer.dart';
|
import 'i_game_consumer.dart';
|
||||||
import 'stone/Stone.dart';
|
import 'stone/stone.dart';
|
||||||
import 'stone/StoneLocation.dart';
|
import 'stone/stone_location.dart';
|
||||||
|
|
||||||
class Game {
|
class Game {
|
||||||
IGameConsumer gameConsumer;
|
IGameConsumer gameConsumer;
|
||||||
|
@ -67,7 +67,7 @@ class Game {
|
||||||
points = 0;
|
points = 0;
|
||||||
board = Board(this);
|
board = Board(this);
|
||||||
gameConsumer.updateStones();
|
gameConsumer.updateStones();
|
||||||
counterTimer = Timer.periodic(Duration(seconds: 1), (_) => countDown());
|
counterTimer = Timer.periodic(const Duration(seconds: 1), (_) => countDown());
|
||||||
gameConsumer.updatePoints();
|
gameConsumer.updatePoints();
|
||||||
running = true;
|
running = true;
|
||||||
}
|
}
|
|
@ -1,14 +1,16 @@
|
||||||
import '../Board.dart';
|
import '../board.dart';
|
||||||
import 'SpecialStone.dart';
|
import 'special_stone.dart';
|
||||||
import 'StoneLocation.dart';
|
import 'stone_location.dart';
|
||||||
|
|
||||||
class PentaSpecialStone extends SpecialStone {
|
class PentaSpecialStone extends SpecialStone {
|
||||||
PentaSpecialStone(Board board) : super(board);
|
PentaSpecialStone(super.board);
|
||||||
|
|
||||||
|
@override
|
||||||
int getSpecialStoneNumber() {
|
int getSpecialStoneNumber() {
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
void performSpecialStoneAction() {
|
void performSpecialStoneAction() {
|
||||||
StoneLocation sl = StoneLocation(row: -1, column: -1);
|
StoneLocation sl = StoneLocation(row: -1, column: -1);
|
||||||
for (int i = 0; i < Board.boardSize; ++i) {
|
for (int i = 0; i < Board.boardSize; ++i) {
|
||||||
|
@ -18,7 +20,7 @@ class PentaSpecialStone extends SpecialStone {
|
||||||
if (this == board.getStone(sl)) {
|
if (this == board.getStone(sl)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (board.getStone(sl)?.getStoneColor() == this.getStoneColor()) {
|
if (board.getStone(sl)?.getStoneColor() == getStoneColor()) {
|
||||||
board.removeStone(sl);
|
board.removeStone(sl);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
import '../Board.dart';
|
import '../board.dart';
|
||||||
import 'Stone.dart';
|
import 'stone.dart';
|
||||||
|
|
||||||
abstract class SpecialStone extends Stone {
|
abstract class SpecialStone extends Stone {
|
||||||
final Board board;
|
final Board board;
|
|
@ -1,6 +1,6 @@
|
||||||
import 'dart:math';
|
import 'dart:math';
|
||||||
|
|
||||||
import '../../enums/StoneColor.dart';
|
import '../../enums/stone_color.dart';
|
||||||
|
|
||||||
/// Class to represent a stone on the board.
|
/// Class to represent a stone on the board.
|
||||||
class Stone {
|
class Stone {
|
|
@ -1,10 +1,10 @@
|
||||||
import 'package:bubbletwist/enums/StoneColor.dart';
|
import 'package:bubbletwist/enums/stone_color.dart';
|
||||||
import 'package:bubbletwist/game/Game.dart';
|
import 'package:bubbletwist/game/game.dart';
|
||||||
import 'package:bubbletwist/game/IGameConsumer.dart';
|
import 'package:bubbletwist/game/i_game_consumer.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
import 'game/stone/Stone.dart';
|
import 'game/stone/stone.dart';
|
||||||
import 'game/stone/StoneLocation.dart';
|
import 'game/stone/stone_location.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
runApp(const MyApp());
|
runApp(const MyApp());
|
||||||
|
@ -20,11 +20,12 @@ class MyApp extends StatelessWidget {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return MaterialApp(
|
return MaterialApp(
|
||||||
title: 'Bubble-Twist',
|
title: 'Bubble-Twist',
|
||||||
|
debugShowCheckedModeBanner: false, // This removes the debug banner
|
||||||
theme: ThemeData(
|
theme: ThemeData(
|
||||||
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
|
||||||
useMaterial3: true,
|
useMaterial3: true,
|
||||||
),
|
),
|
||||||
home: const MyHomePage(title: 'Flutter Demo Home Page', gridSize: 8),
|
home: const MyHomePage(title: 'Bubble-Twist', gridSize: 8),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +72,7 @@ class _MyHomePageState extends State<MyHomePage> implements IGameConsumer {
|
||||||
title: Text(widget.title),
|
title: Text(widget.title),
|
||||||
actions: [
|
actions: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.only(right: 20.0),
|
padding: const EdgeInsets.only(right: 20.0),
|
||||||
child: Text("Time: $_time s"),
|
child: Text("Time: $_time s"),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
Loading…
Reference in New Issue