]> Pileus Git - ~andy/spades/blobdiff - src/Spades.java
Fix .look bugs
[~andy/spades] / src / Spades.java
index 31878442460291f6564af9b8164b72e94dc39ec0..770cd1c3c6b9c0dbbea5503241f407a807d7f0ee 100644 (file)
@@ -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;
        }