# Per game
if (type >= 2) {
- sp_channel = "" # channel to play in
sp_state = "new" # {new,join,bid,pass,play}
sp_owner = "" # Who started the game
sp_playto = 0 # Score the game will go to
# Persistent
if (type >= 3) {
+ sp_channel = "" # channel to play in
sp_log = "" # Log file name
delete sp_notify # [p] E-mail notification address
}
json_copy(game, "tricks", sp_tricks);
# Per game
- game["channel"] = sp_channel;
game["owner"] = sp_owner;
game["playto"] = sp_playto;
game["dealer"] = sp_dealer;
game["turn"] = sp_turn;
game["player"] = sp_player;
game["limit"] = sp_limit;
- game["log"] = sp_log;
json_copy(game, "hands", sp_hands);
json_copy(game, "players", sp_players);
json_copy(game, "auths", sp_auths);
json_copy(game, "share", sp_share);
json_copy(game, "order", sp_order);
json_copy(game, "scores", sp_scores);
+
+ # Persistent
+ game["channel"] = sp_channel;
+ game["log"] = sp_log;
json_copy(game, "notify", sp_notify);
# Save
sp_acopy(sp_tricks, game["tricks"]);
# Per game
- sp_channel = game["channel"];
sp_owner = game["owner"];
sp_playto = game["playto"];
sp_dealer = game["dealer"];
sp_turn = game["turn"];
sp_player = game["player"];
sp_limit = game["limit"];
- sp_log = game["log"];
sp_acopy(sp_hands, game["hands"]);
sp_acopy(sp_players, game["players"]);
sp_acopy(sp_auths, game["auths"]);
sp_acopy(sp_share, game["share"]);
sp_acopy(sp_order, game["order"]);
sp_acopy(sp_scores, game["scores"]);
+
+ # Persistent
+ sp_channel = game["channel"];
+ sp_log = game["log"];
sp_acopy(sp_notify, game["notify"]);
}
function sp_stats(file, line, arr, time, user, turn, start, delay)
{
# Process log file
- while (getline line < file) {
+ while ((stat = getline line < file) > 0) {
# Parse date
if (!match(line, /^([0-9\- \:]*) \| (.*)$/, arr))
continue
start = time
}
}
+ close(file)
+
+ # Check for error
+ if (stat < 0)
+ reply("File does not exist: " file);
# Output statistics
for (user in delay) {
}
}
-(DST == sp_channel) &&
+(TO == NICK || DST == sp_channel) &&
/^\.log/ {
say("http://pileus.org/andy/spades/" sp_log)
}
-(DST == sp_channel) &&
-/^\.stats/ {
+(TO == NICK || DST == sp_channel) &&
+/^\.stats$/ {
sp_stats("logs/" sp_log);
}
+(TO == NICK || DST == sp_channel) &&
+/^\.stats ([0-9]+_[0-9]+)(\.log)$/ {
+ gsub(/\.log$/, "", $2);
+ sp_stats("logs/" $2 ".log");
+}
+
/^\.((new|end|load)game|join|look|bid|pass|play|notify)/ {
sp_save("var/sp_cur.json");
}