From: Andy Spencer Date: Wed, 24 Apr 2013 08:48:19 +0000 (+0000) Subject: Fix null pointers and pile parsing X-Git-Url: http://pileus.org/git/?p=~andy%2Fspades;a=commitdiff_plain;h=db1bf55fc47cea610a1f1ae4baa4cecba3685886 Fix null pointers and pile parsing --- diff --git a/src/org/pileus/spades/Cards.java b/src/org/pileus/spades/Cards.java index 1cf4c3e..8703c87 100644 --- a/src/org/pileus/spades/Cards.java +++ b/src/org/pileus/spades/Cards.java @@ -429,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; diff --git a/src/org/pileus/spades/Spades.java b/src/org/pileus/spades/Spades.java index 3c023c9..17eacfa 100644 --- a/src/org/pileus/spades/Spades.java +++ b/src/org/pileus/spades/Spades.java @@ -41,8 +41,8 @@ public class Spades this.cards.hand = Spades.getCards(txt, "You have: (.*)"); this.cards.requestRender(); } - if (txt.matches("turn!")) { - this.cards.pile = Spades.getCards(txt, ".*turn! (.*)"); + if (txt.matches(".*turn!.*")) { + this.cards.pile = Spades.getCards(txt, ".*turn! \\((.*)\\)"); this.cards.requestRender(); } }