function sp_reset(type)
{
# Per message
- if (type >= 0) {
+ if (type < 0) {
sp_from = "" # The speakers player name
sp_valid = "" # It is the speaker turn
}
function sp_load(file, game)
{
# Load
- json_load(file, game);
+ if (!json_load(file, game))
+ return
# Per hand
sp_suit = game["suit"];
say("Bidding starts with " sp_player "!")
}
-function sp_hand(who, sort, str)
+function sp_hand(to, who, sort, str)
{
asorti(sp_hands[who], sort, "sp_csort")
for (i=0; i<length(sort); i++)
str = str "" sprintf("%4s", sort[i])
gsub(/^ +| +$/, "", str)
- return sp_pretty(str, who)
+ return sp_pretty(str, to)
}
function sp_hasa(who, expr)
say("Bidding goes to " sp_player "!")
} else {
for (p in sp_players)
- say(p, "You have: " sp_hand(p))
+ say(p, "You have: " sp_hand(p, p))
sp_state = "play"
for (i=0; i<2; i++) {
if (sp_nil[i] == 2 || sp_nil[i+2] == 2) {
}
say(sp_channel, "Cards have been passed, play starts with " sp_player "!")
for (p in sp_players)
- say(p, "You have: " sp_hand(p))
+ say(p, "You have: " sp_hand(p, p))
sp_state = "play"
}
}
-sp_state ~ "(play|bid)" &&
+sp_state ~ "(bid|pass|play)" &&
/^\.look$/ {
if (!(sp_from in sp_players)) {
say(".slap " FROM ", you are not playing.")
} else {
sp_looked[sp_players[sp_from]] = 1
- say(FROM, "You have: " sp_hand(sp_from))
+ say(FROM, "You have: " sp_hand(FROM, sp_from))
}
}
sp_play(card)
if (sp_state == "play") {
if (length(sp_hands[sp_from]))
- say(FROM, "You have: " sp_hand(sp_from))
+ say(FROM, "You have: " sp_hand(FROM, sp_from))
if (sp_piles)
say(sp_player ": it is your turn! " \
"(" sp_pretty(sp_piles, sp_player) ")")
sp_order[2] " " sp_order[3])
}
if (sp_state == "bid" || sp_state == "play") {
+ say("playing to: " \
+ sp_playto " points, " \
+ sp_limit " bags")
say(sp_team(0) ": " \
int(sp_scores[0]) " points, " \
int(sp_bags(0)) " bags")