More flexible played cards
diff --git a/lib/components/board.dart b/lib/components/board.dart
index 81720c1..77c28a1 100644
--- a/lib/components/board.dart
+++ b/lib/components/board.dart
@@ -9,30 +9,42 @@
const cardWidth = 71;
class CardCluster extends widgets.Component {
- List<int> cards; // the indicies of the 4 cards in the center, in clockwise order
- CardCluster(this.cards);
+ List<int> cards; // the indicies of the cards in the center, in clockwise order
+ int startingPos;
+ CardCluster(this.startingPos, this.cards);
widgets.Widget build() {
-
- return new widgets.Container(
- child: new widgets.Stack([
- new widgets.Transform(
- transform: new vector_math.Matrix4.identity().rotateZ(math.PI).translate(0, -cardHeight / 2),
- child: new Card(logic_card.Card.All[cards[0]], true)
- ),
- new widgets.Transform(
- transform: new vector_math.Matrix4.identity().rotateZ(math.PI/2.0).translate(0, cardWidth/2),
- child: new Card(logic_card.Card.All[cards[1]], true)
- ),
- new widgets.Transform(
- transform: new vector_math.Matrix4.identity().translate(-cardWidth, cardWidth / 2),
- child: new Card(logic_card.Card.All[cards[2]], true)
- ),
- new widgets.Transform(
- transform: new vector_math.Matrix4.identity().rotateZ(math.PI/2.0).translate(0, -cardHeight/2),
- child: new Card(logic_card.Card.All[cards[3]], true)
- )
- ]));
+ var widgetsList = [];
+ for (int i = 0; i < cards.length; i++) {
+ var posMod = (startingPos + i) % 4;
+ switch (posMod) {
+ case 0:
+ widgetsList.add(new widgets.Transform(
+ transform: new vector_math.Matrix4.identity().rotateZ(math.PI).translate(0, -cardHeight / 2),
+ child: new Card(logic_card.Card.All[cards[i]], true)
+ ));
+ break;
+ case 1:
+ widgetsList.add(new widgets.Transform(
+ transform: new vector_math.Matrix4.identity().rotateZ(math.PI/2.0).translate(0, cardWidth/2),
+ child: new Card(logic_card.Card.All[cards[i]], true)
+ ));
+ break;
+ case 2:
+ widgetsList.add(new widgets.Transform(
+ transform: new vector_math.Matrix4.identity().translate(-cardWidth, cardWidth / 2),
+ child: new Card(logic_card.Card.All[cards[i]], true)
+ ));
+ break;
+ case 3:
+ widgetsList.add(new widgets.Transform(
+ transform: new vector_math.Matrix4.identity().rotateZ(math.PI/2.0).translate(0, -cardHeight/2),
+ child: new Card(logic_card.Card.All[cards[i]], true)
+ ));
+ break;
+ }
+ }
+ return new widgets.Container(child: new widgets.Stack(widgetsList));
}
}
@@ -55,8 +67,8 @@
CardCluster centerCluster;
List<PlayerHand> hands; // counts of cards in players hands, in clockwise order
- Board(List<int> cards, List<int> playerHandCount) :
- centerCluster = new CardCluster(cards) {
+ Board(int firstCardPlayedPosition, List<int> cards, List<int> playerHandCount) :
+ centerCluster = new CardCluster(firstCardPlayedPosition, cards) {
assert(playerHandCount.length == 4);
hands = new List<PlayerHand>();
for (int count in playerHandCount) {
diff --git a/lib/components/game.dart b/lib/components/game.dart
index da2c4d1..54e6c5c 100644
--- a/lib/components/game.dart
+++ b/lib/components/game.dart
@@ -17,9 +17,9 @@
Widget build() {
switch (game.gameType) {
case GameType.Hearts:
- return buildHearts();
+ //return buildHearts();
// Code to display board:
- // return new Board([2,3,4,5], [1, 2, 3, 4]);
+ return new Board(1, [2,3,4], [1, 2, 3, 4]);
default:
return null; // unsupported
}