From: Andy Spencer Date: Fri, 6 Nov 2015 23:07:32 +0000 (+0000) Subject: Show turn in title bar X-Git-Url: http://pileus.org/git/?p=~andy%2Fspades;a=commitdiff_plain;h=a4c319d3946b574e75e591e6615826c9fc40de89 Show turn in title bar --- diff --git a/src/Cards.java b/src/Cards.java index 8506e21..0d5686a 100644 --- a/src/Cards.java +++ b/src/Cards.java @@ -129,6 +129,8 @@ public class Cards extends GLSurfaceView implements GLSurfaceView.Renderer public Spades game; // the spades game public String[] hand; // cards to display public String[] pile; // played cards to display + public String turn; // whos turn it is + public String state; // state of the game (turn, bid, etc) /* GLSurfaceView Methods */ public Cards(Context context) @@ -148,6 +150,7 @@ public class Cards extends GLSurfaceView implements GLSurfaceView.Renderer this.hand = "As Ks Qs Js 10s 9s 8s 7s 6s 5s 4s 3s 2s".split(" "); this.pile = "Ah Ac Ad".split(" "); + this.turn = ""; this.index = new HashMap(52); for (int i = 0; i < 52; i++) diff --git a/src/Main.java b/src/Main.java index 0b29dba..362af12 100644 --- a/src/Main.java +++ b/src/Main.java @@ -195,6 +195,12 @@ public class Main extends Activity break; } this.lscroll.smoothScrollTo(0, this.log.getBottom()); + + // Update title + if (this.cards.turn != null && this.cards.turn != "" && + this.cards.state != null && this.cards.state != "") { + this.setTitle("Spades - " + this.cards.turn + "'s " + this.cards.state); + } } private void onNotify(String text) diff --git a/src/Spades.java b/src/Spades.java index 3187844..b1d9d74 100644 --- a/src/Spades.java +++ b/src/Spades.java @@ -50,6 +50,15 @@ public class Spades this.cards.pile = Spades.getCards(txt, ".*turn! \\((.*)\\)"); this.cards.requestRender(); } + if (txt.startsWith("It is")) { + this.cards.turn = txt.replaceAll("It is (\\w+)'s (\\w+)!.*", "$1"); + this.cards.state = txt.replaceAll("It is (\\w+)'s (\\w+)!.*", "$2"); + this.cards.requestRender(); + } + if (txt.startsWith("^it is your")) { + this.cards.turn = msg.to; + this.cards.requestRender(); + } } /* UI Callbacks */