]> Pileus Git - ~andy/rhawk/blobdiff - spades.awk
Fix number regex again
[~andy/rhawk] / spades.awk
index a68db4a5a0e52f23557e3552f08561ea6d196059..75d12b93d0c9b4aa6ebb15cad11e5dd0b8f8b909 100644 (file)
@@ -299,9 +299,9 @@ function sp_score(  bids, times, tricks)
                        (sp_tricks[i] == 0 ? 1 : -1)
        }
        if (sp_scores[0] > sp_scores[1])
-               say(sp_team(0) " lead " sp_scores[0] " to " sp_scores[1])
+               say(sp_team(0) " lead " sp_scores[0] " to " sp_scores[1] " of " sp_playto)
        else if (sp_scores[1] > sp_scores[0])
-               say(sp_team(1) " lead " sp_scores[1] " to " sp_scores[0])
+               say(sp_team(1) " lead " sp_scores[1] " to " sp_scores[0] " of " sp_playto)
        else
                say("tied at " sp_scores[0])
 }
@@ -461,12 +461,12 @@ sp_state == "play" &&
 
 
 # Setup
-match($0, /^\.newgame ?([0-9]+) *- *([0-9]+)$/, _arr) {
+match($0, /^\.newgame ?([1-9][0-9]*) *- *([1-9][0-9]*)$/, _arr) {
        if (_arr[2] > _arr[1])
                $0 = $1 " " int(rand() * (_arr[2]-_arr[1])+_arr[1])
 }
 
-/^\.newgame ?([0-9]+)?$/ {
+/^\.newgame ?([1-9][0-9]*)?$/ {
        if (sp_state != "new") {
                reply("There is already a game in progress.")
        } else {
@@ -579,7 +579,7 @@ sp_state ~ "(bid|pass|play)" &&
 
 sp_valid &&
 sp_state == "bid" &&
-/^\.bid [0-9]+$/ {
+/^\.bid (0|[1-9][0-9]*)$/ {
        if ($2 < 0 || $2 > 13) {
                say("You can only bid from 0 to 13")
        } else {
@@ -701,16 +701,23 @@ sp_state == "play" &&
 
 /^\.bids/ && sp_state == "bid" ||
 /^\.turn/ && sp_state ~ "(bid|pass|play)" {
-       _bids = sp_bidders()
-       _pile = sp_pretty(sp_piles, FROM)
+       _bids  = sp_bidders()
+       _pile  = sp_pretty(sp_piles, FROM)
+       _extra = ""
+
+       for (_i in sp_share)
+               if (/!/ && sp_share[_i] == sp_player)
+                       _extra = _extra " " _i "!"
+
        if (sp_state == "bid" && !_bids)
-               say("It is " sp_player "'s bid!")
+               say("It is " sp_player "'s bid!" _extra)
        if (sp_state == "bid" && _bids)
-               say("It is " sp_player "'s bid! (" _bids ")")
+               say("It is " sp_player "'s bid!" _extra " (" _bids ")")
        if (sp_state == "play" && !_pile)
-               say("It is " sp_player "'s turn!")
+               say("It is " sp_player "'s turn!" _extra)
        if (sp_state == "play" && _pile)
-               say("It is " sp_player "'s turn! (" _pile ")")
+               say("It is " sp_player "'s turn!" _extra " (" _pile ")")
+
        for (_i=0; sp_state == "pass" && _i<4; _i++)
                if (sp_passer(_i) && !sp_pass[_i])
                        say("Waiting for " sp_order[_i] " to pass a card!")