return bids
}
+function sp_extra( n, s)
+{
+ n = sp_bids[0] + sp_bids[1] + sp_bids[2] + sp_bids[3];
+ s = n == 12 || n == 14 ? "" : "s";
+
+ return n<13 ? "Playing with " 13-n " bag" s "!" :
+ n>13 ? "Fighting for " n-13 " trick" s "!" : "No bags!";
+}
+
function sp_score( bids, times, tricks)
{
for (i=0; i<2; i++) {
sp_reset(2)
} else {
- if (sp_scores[0] == sp_scores[1] &&
+ if (sp_scores[0] == sp_scores[1] &&
sp_scores[0] >= sp_playto)
sp_say("It's tie! Playing an extra round!");
sp_reset(1)
{
return (sec > 60*60*24 ? int(sec/60/60/24) "d " : "") \
(sec > 60*60 ? int(sec/60/60)%24 "h " : "") \
- int(sec/60)%60 "m"
+ int(sec/60)%60 "m"
}
function sp_max(list, i, max)
return sum / length(list)
}
-function sp_stats(file, line, arr, time, user, turn, start, delay)
+function sp_cur(list)
+{
+ return list[length(list)-1]
+}
+
+function sp_stats(file, line, arr, time, user, turn, start, delay, extra)
{
# Process log file
while ((stat = getline line < file) > 0) {
delay[turn][length(delay[turn])] = time - start
turn = 0
}
- if (match(arr[2], /^it is your.*$/, arr)) {
+ if (match(arr[2], /^(it is your|you .*(first|lead)!$)/, arr)) {
turn = user
start = time
- }
+ }
}
close(file)
+ # Add current latency
+ if (turn) {
+ delay[turn][length(delay[turn])] = systime() - start
+ debug("time: " (systime() - start))
+ }
+
# Check for error
if (stat < 0)
reply("File does not exist: " file);
# Output statistics
for (user in delay) {
+ extra = (user != turn) ? "" : \
+ ", " sp_delay(sp_cur(delay[user])) " (cur)";
say("latency for " user \
": " sp_delay(sp_avg(delay[user])) " (avg)" \
- ", " sp_delay(sp_max(delay[user])) " (max)")
+ ", " sp_delay(sp_max(delay[user])) " (max)" extra)
}
}
}
}
+/^\.whoami/ {
+ if (!(sp_from in sp_players))
+ reply("You are not playing")
+ else if (sp_from == FROM)
+ say(FROM " has an existential crisis")
+ else
+ reply("You are playing for " sp_from);
+}
+
/^\.notify$/ {
if (sp_from in sp_notify)
reply("Your address is " sp_notify[sp_from])
if (sp_turn != sp_dealer) {
sp_say(sp_player ": it is your bid! (" sp_bidders() ")")
} else {
+ sp_say(sp_extra() " (" sp_bidders() ")")
for (p in sp_players)
say(p, "You have: " sp_hand(p, p))
sp_state = "play"