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