]> Pileus Git - ~andy/rhawk/commitdiff
Add player shuffling
authorAndy Spencer <andy753421@gmail.com>
Thu, 31 Oct 2013 04:29:24 +0000 (04:29 +0000)
committerAndy Spencer <andy753421@gmail.com>
Thu, 31 Oct 2013 04:29:49 +0000 (04:29 +0000)
spades.awk
test.txt

index 41d2ab8816b29d558fcaa869888c89a853833118..1686806fc031cd0ee7996576147587845f5bb039 100644 (file)
@@ -161,6 +161,15 @@ function sp_next(who, prev)
        return prev
 }
 
        return prev
 }
 
+function sp_shuf(i, mixed)
+{
+       asorti(sp_players, mixed, "sp_usort")
+       for (i in mixed) {
+               sp_order[i-1] = mixed[i]
+               sp_players[mixed[i]] = i-1
+       }
+}
+
 function sp_deal(      shuf)
 {
        say("/me deals the cards")
 function sp_deal(      shuf)
 {
        say("/me deals the cards")
@@ -470,8 +479,10 @@ sp_state == "play" &&
                sp_order[i] = FROM
                say(FROM " joins the game!")
        }
                sp_order[i] = FROM
                say(FROM " joins the game!")
        }
-       if (sp_state == "join" && sp_turn == 0)
+       if (sp_state == "join" && sp_turn == 0) {
+               sp_shuf()
                sp_deal()
                sp_deal()
+       }
 }
 
 /^\.allow \S+$/ {
 }
 
 /^\.allow \S+$/ {
index 9ba0ddffd10d9f3426eeb55facc3281b21c36238..801460dbf0a97ad6a3cdb77be614a10cacf2f797 100644 (file)
--- a/test.txt
+++ b/test.txt
 #          |          |      |- Is not playing for
 #          |          |      |- Can no longer play
 #          |          |      |- Is not playing for
 #          |          |      |- Is not playing for
 #          |          |      |- Can no longer play
 #          |          |      |- Is not playing for
-auth/auth: .        . .      .     . .  .     -As
-nope:      .        . Yauth  Nauth . .  .      .
-a/aa:      n        . Ya     Na    d b1 Yauth +As
-b/bb:      Ynewgame j Ynope  Nnope d b1 .      Ah
-c/cc:      Nnewgame j Yauth  Nauth d b1 .      Ad
-d/dd:      .        j Yauth  Nauth d b1 .      Ac
+#auth/auth: .        . .      .     . .  .     -As
+#nope:      .        . Yauth  Nauth . .  .      .
+#a/aa:      n        . Ya     Na    d b1 Yauth +As
+#b/bb:      Ynewgame j Ynope  Nnope d b1 .      Ah
+#c/cc:      Nnewgame j Yauth  Nauth d b1 .      Ad
+#d/dd:      .        j Yauth  Nauth d b1 .      Ac
+
+# Test sorting
+a: n j s
+b: . j .
+c: . j .
+d: . j .
 
 # Test scoring
 #x: s s s s s s s  s  s  s  s  s
 
 # Test scoring
 #x: s s s s s s s  s  s  s  s  s