Skip to content

Commit

Permalink
Add player shuffling
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy753421 committed Oct 31, 2013
1 parent 828095c commit 069896b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
13 changes: 12 additions & 1 deletion spades.awk
Expand Up @@ -161,6 +161,15 @@ function sp_next(who, 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")
Expand Down Expand Up @@ -470,8 +479,10 @@ sp_state == "play" &&
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()
}
}

/^\.allow \S+$/ {
Expand Down
18 changes: 12 additions & 6 deletions test.txt
Expand Up @@ -42,12 +42,18 @@
# | | |- 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
Expand Down

0 comments on commit 069896b

Please sign in to comment.