X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;ds=sidebyside;f=src%2FSpades.java;h=770cd1c3c6b9c0dbbea5503241f407a807d7f0ee;hb=944e1df0262f4b37df99964737fae501e3c22ee0;hp=31878442460291f6564af9b8164b72e94dc39ec0;hpb=35e1b13fb6ba50c0dbc6284f6dda35f562b8b94a;p=~andy%2Fspades diff --git a/src/Spades.java b/src/Spades.java index 3187844..770cd1c 100644 --- a/src/Spades.java +++ b/src/Spades.java @@ -6,7 +6,7 @@ public class Spades public Task task; public Cards cards; public String admin; - public boolean looked; + public boolean look; /* Static methods */ private static String[] getCards(String msg, String regex) @@ -38,27 +38,38 @@ public class Spades return; String txt = msg.txt; - if (txt.matches(".*turn!.*") && !this.looked) { + if (txt.matches(".*turn!.*") && this.look) { this.send(this.admin, ".look"); - this.looked = true; + this.look = false; } if (txt.startsWith("You have: ")) { this.cards.hand = Spades.getCards(txt, "You have: (.*)"); this.cards.requestRender(); + this.look = false; } if (txt.matches(".*turn!.*")) { 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") && msg.to != "") { + this.cards.turn = msg.to; + this.cards.state = txt.replaceAll("it is your (\\w+)!", "$1"); + this.cards.requestRender(); + } } /* UI Callbacks */ public boolean onConnect() { Os.debug("Spades: onConnect"); - this.looked = false; this.send(this.admin, ".status"); this.send(this.admin, ".turn"); + this.look = true; return true; }