]> Pileus Git - ~andy/rhawk/blobdiff - spades.awk
Convert privmsg to say
[~andy/rhawk] / spades.awk
index 844326a076483817d87c6a72a7eac733b10dbfa7..d8bfef4f943f9245f5ebed01bb548423aa32d6b9 100644 (file)
@@ -1,7 +1,3 @@
-# Todo:
-#   - highest bidder leads
-#   - show card after play
-
 # Functions
 function sp_init(cards, tmp0, tmp1)
 {
@@ -149,7 +145,7 @@ function sp_score(  bids, tricks)
                bids   = sp_bids[i]   + sp_bids[i+2]
                tricks = sp_tricks[i] + sp_tricks[i+2]
                bags   = tricks - bids
-               if (sp_bags(i) + bags > 10) {
+               if (sp_bags(i) + bags >= 10) {
                        say(sp_team(i) " bag out")
                        sp_scores[i] -= 100
                }
@@ -269,12 +265,12 @@ FROM == OWNER &&
        delete sp_hands[$2]
        for (i=3; i<=NF; i++)
                sp_hands[$2][$i] = 1
-       privmsg(sp_channel, FROM " is cheating for " $2)
+       say(sp_channel, FROM " is cheating for " $2)
 }
 
 
 # Setup
-/^\.newgame ?([0-9]+)?$/ {
+/^\.newgame ?([0-9]+)?/ {
        if (sp_state != "new") {
                reply("There is already a game in progress.")
        } else {
@@ -283,7 +279,7 @@ FROM == OWNER &&
                sp_state   = "join"
                sp_channel = DST
                say(sp_owner " starts a game of Spades to " sp_playto "!")
-               #privmsg("#rhnoise", sp_owner " starts a game of Spades in " DST "!")
+               #say("#rhnoise", sp_owner " starts a game of Spades in " DST "!")
        }
 }
 
@@ -319,7 +315,7 @@ FROM == OWNER &&
 
 !sp_valid &&
 (sp_state "bid" || sp_state == "play") &&
-/^\.(bid|play)\>$/ {
+/^\.(bid|play)\>/ {
        if (FROM in sp_players)
                say(".slap " FROM ", it is not your turn.")
        else
@@ -345,7 +341,7 @@ sp_state == "bid" &&
                        say("Bidding goes to " sp_player "!")
                } else {
                        for (p in sp_players)
-                               privmsg(p, "You have: " sp_hand(p))
+                               say(p, "You have: " sp_hand(p))
                        sp_state = "play"
                        for (i=0; i<2; i++) {
                                if (sp_nil[i] == 2 || sp_nil[i+2] == 2) {
@@ -381,7 +377,7 @@ sp_state == "pass" &&
        }
        else {
                sp_pass[sp_players[FROM]] = $2
-               privmsg(sp_channel, FROM " passes a card")
+               say(sp_channel, FROM " passes a card")
        }
        if (((sp_nil[0] != 2 && sp_nil[2] != 2) || (sp_pass[0] && sp_pass[2])) &&
            ((sp_nil[1] != 2 && sp_nil[3] != 2) || (sp_pass[1] && sp_pass[3]))) {
@@ -391,9 +387,9 @@ sp_state == "pass" &&
                        delete sp_hands[sp_order[i]][card]
                        sp_hands[sp_order[partner]][card] = 1
                }
-               privmsg(sp_channel, "Cards have been passed, play starts with " sp_player "!")
+               say(sp_channel, "Cards have been passed, play starts with " sp_player "!")
                for (p in sp_players)
-                       privmsg(p, "You have: " sp_hand(p))
+                       say(p, "You have: " sp_hand(p))
                sp_state = "play"
        }
 }
@@ -404,7 +400,7 @@ sp_state ~ "(play|bid)" &&
                say(".slap " FROM ", you are not playing.")
        } else {
                sp_looked[sp_players[FROM]] = 1
-               privmsg(FROM, "You have: " sp_hand(FROM))
+               say(FROM, "You have: " sp_hand(FROM))
        }
 }
 
@@ -429,7 +425,7 @@ sp_state == "play" &&
        }
        else {
                sp_play(card)
-               privmsg(FROM, "You have: " sp_hand(FROM))
+               say(FROM, "You have: " sp_hand(FROM))
                if (sp_state == "play") {
                        if (sp_piles)
                                say(sp_player ": it is your turn! " \
@@ -456,12 +452,13 @@ sp_state == "play" &&
            sp_order[3] " took " int(sp_tricks[3]) "/" int(sp_bids[3]))
 }
 
+(TO == NICK || DST == sp_channel) &&
 /^\.(score|status)$/ {
        if (sp_state == "new") {
                say("There is no game in progress")
        }
        if (sp_state == "join") {
-               say("Waiting for palyers: " \
+               say("Waiting for players: " \
                    sp_order[0] " " sp_order[1] " " \
                    sp_order[2] " " sp_order[3])
        }