mirror of
				https://github.com/flame-engine/flame.git
				synced 2025-10-31 17:06:50 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			30 lines
		
	
	
		
			784 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			30 lines
		
	
	
		
			784 B
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'package:flame/sprite.dart';
 | |
| import 'package:flutter/foundation.dart';
 | |
| import 'klondike_game.dart';
 | |
| 
 | |
| @immutable
 | |
| class Suit {
 | |
|   factory Suit.fromInt(int index) {
 | |
|     assert(index >= 0 && index <= 3);
 | |
|     return _singletons[index];
 | |
|   }
 | |
| 
 | |
|   Suit._(this.value, this.label, double x, double y, double w, double h)
 | |
|       : sprite = klondikeSprite(x, y, w, h);
 | |
| 
 | |
|   final int value;
 | |
|   final String label;
 | |
|   final Sprite sprite;
 | |
| 
 | |
|   static late final List<Suit> _singletons = [
 | |
|     Suit._(0, '♥', 1176, 17, 172, 183),
 | |
|     Suit._(1, '♦', 973, 14, 177, 182),
 | |
|     Suit._(2, '♣', 974, 226, 184, 172),
 | |
|     Suit._(3, '♠', 1178, 220, 176, 182),
 | |
|   ];
 | |
| 
 | |
|   /// Hearts and Diamonds are red, while Clubs and Spades are black.
 | |
|   bool get isRed => value <= 1;
 | |
|   bool get isBlack => value >= 2;
 | |
| }
 | 
