X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=src%2Forg%2Fpileus%2Fspades%2FCards.java;h=8703c87a4b0b67df59359b3176abd6171195a4e3;hb=db1bf55fc47cea610a1f1ae4baa4cecba3685886;hp=9085a8f94c679347de34a1dca201f776975c04d5;hpb=d2d6e7280584690d8ffa9a4f27278284b9b2bf6c;p=~andy%2Fspades diff --git a/src/org/pileus/spades/Cards.java b/src/org/pileus/spades/Cards.java index 9085a8f..8703c87 100644 --- a/src/org/pileus/spades/Cards.java +++ b/src/org/pileus/spades/Cards.java @@ -124,6 +124,7 @@ public class Cards extends GLSurfaceView implements GLSurfaceView.Renderer private Map index; // card name to index map /* Properties */ + public Spades game; // the spades game public String[] hand; // cards to display public String[] pile; // played cards to display @@ -143,14 +144,8 @@ public class Cards extends GLSurfaceView implements GLSurfaceView.Renderer this.ylim = 0.4f; - this.hand = new String[] { - "As", "7s", "6s", "6h", "2h", "Ac", - "Kc", "3c", "10d", "9d", "8d", "7d", "2d" - }; - - this.pile = new String[] { - "As", "7s", "6s" - }; + this.hand = "As Ks Qs Js 10s 9s 8s 7s 6s 5s 4s 3s 2s".split(" "); + this.pile = "Ah Ac Ad".split(" "); this.index = new HashMap(52); for (int i = 0; i < 52; i++) @@ -293,6 +288,7 @@ public class Cards extends GLSurfaceView implements GLSurfaceView.Renderer } if (y >= this.ylim && this.drag && up) { //Os.debug("Cards: onTouchEvent - playing card"); + this.game.onPlay(this.hand[this.pick]); } if (up) { //Os.debug("Cards: onTouchEvent - ending drag"); @@ -433,6 +429,8 @@ public class Cards extends GLSurfaceView implements GLSurfaceView.Renderer private void drawCard(String name) { + if (!this.index.containsKey(name)) + return; int idx = this.index.get(name); int front = this.face[idx]; int back = this.red;