Skip to content
Snippets Groups Projects
Select Git revision
  • bf8bd0496ea2b5188b9baff06cdaa7496047ae97
  • master default protected
  • 48-add-show-available-moves-toggle-button
  • 41-highlight-picked-cell
  • 42-add-rule-game-ends-if-player-has-no-more-seeds
  • 43-add-rule-game-ends-if-board-contains-3-or-less-seeds
  • 44-highlight-earned-cell
  • 45-pick-and-earn-seeds-one-by-one
  • 38-add-button-to-give-tip-for-human-player
  • 40-improve-get-move-weight-function
  • 34-allow-more-seeds-in-holes
  • 14-improve-app-metadata
  • Release_0.8.10_35 protected
  • Release_0.8.9_34 protected
  • Release_0.8.8_33 protected
  • Release_0.8.7_32 protected
  • Release_0.8.6_31 protected
  • Release_0.8.5_30 protected
  • Release_0.8.4_29 protected
  • Release_0.8.3_28 protected
  • Release_0.8.2_27 protected
  • Release_0.8.1_26 protected
  • Release_0.8.0_25 protected
  • Release_0.7.2_24 protected
  • Release_0.7.1_23 protected
  • Release_0.7.0_22 protected
  • Release_0.6.0_21 protected
  • Release_0.5.0_20 protected
  • Release_0.4.0_19 protected
  • Release_0.3.2_18 protected
  • Release_0.3.1_17 protected
  • Release_0.3.0_16 protected
32 results

game_house.dart

Blame
  • game_house.dart 1.71 KiB
    import 'package:flutter/material.dart';
    import 'package:flutter_bloc/flutter_bloc.dart';
    
    import 'package:awale/cubit/game_cubit.dart';
    import 'package:awale/models/game/game.dart';
    import 'package:awale/ui/widgets/game/game_seeds.dart';
    import 'package:awale/utils/color_extensions.dart';
    
    class GameHouseWidget extends StatelessWidget {
      const GameHouseWidget({
        super.key,
        required this.cellIndex,
      });
    
      final int cellIndex;
    
      @override
      Widget build(BuildContext context) {
        return BlocBuilder<GameCubit, GameState>(
          builder: (BuildContext context, GameState gameState) {
            final Game currentGame = gameState.currentGame;
    
            final bool isTapAllowed = currentGame.isCurrentPlayerHouse(cellIndex);
            final int seedsCount = currentGame.board.cells[cellIndex];
    
            final Color baseColor =
                isTapAllowed ? Colors.white : const Color.fromARGB(255, 230, 230, 230);
    
            return GestureDetector(
              onTap: () {
                if (isTapAllowed && !currentGame.animationInProgress) {
                  BlocProvider.of<GameCubit>(context).tapOnCell(cellIndex);
                }
              },
              child: AspectRatio(
                aspectRatio: 1,
                child: Container(
                  margin: const EdgeInsets.all(2),
                  padding: const EdgeInsets.all(2),
                  decoration: BoxDecoration(
                    color: baseColor,
                    borderRadius: BorderRadius.circular(100),
                    border: Border.all(
                      color: baseColor.darken(),
                      width: 4,
                    ),
                  ),
                  width: 60,
                  child: GameSeedsWidget(seedsCount: seedsCount),
                ),
              ),
            );
          },
        );
      }
    }