X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;ds=sidebyside;f=spades.awk;h=740d1b8e347003b11fc6acf764fe22719521374f;hb=HEAD;hp=46278eb245f7e0248af723919ec25d5a0cd7d41b;hpb=70ba0fca067fa97079f74be13e313472050ac619;p=~andy%2Frhawk diff --git a/spades.awk b/spades.awk index 46278eb..740d1b8 100644 --- a/spades.awk +++ b/spades.awk @@ -164,7 +164,7 @@ function sp_say(msg) { say(sp_channel, msg) print msg |& sp_sock - print strftime("%Y-%m-%d %H:%M:%S | ") msg >> "logs/" sp_log + print strftime("%Y-%m-%d %H:%M:%S | ") sp_ugly(msg) >> "logs/" sp_log fflush("logs/" sp_log) } @@ -183,6 +183,16 @@ function sp_pretty(cards, who) return cards } +function sp_ugly(cards, who) +{ + gsub(/[\2\17]|\3[14],00|/, "", cards) + gsub(/♠/, "s", cards) + gsub(/♥/, "h", cards) + gsub(/♦/, "d", cards) + gsub(/♣/, "c", cards) + return cards +} + function sp_next(who, prev) { prev = sp_turn @@ -609,14 +619,27 @@ match($0, /^\.newgame ?([1-9][0-9]*) *- *([1-9][0-9]*)$/, _arr) { } } -(sp_from == sp_owner || AUTH == OWNER) && -/^\.endgame$/ { +/^\.(endgame|fliptable)$/ { if (sp_state == "new") { reply("There is no game in progress.") - } else { + } + else if (!(sp_from in sp_players)) { + reply("You are not playing") + } + else if (sp_state == "join") { sp_say(FROM " ends the game") sp_reset(2) } + else { + _looser = (sp_players[sp_from]+0) % 2; + _winner = (sp_players[sp_from]+1) % 2; + sp_say(FROM " goes on a rampage") + say(CHANNEL, sp_team(_winner) " wins the game " \ + sp_scores[_winner] " to " sp_scores[_looser]) + say(CHANNEL, sp_order[_winner+0] "++") + say(CHANNEL, sp_order[_winner+2] "++") + sp_reset(2) + } } /^\.join/ { @@ -638,6 +661,8 @@ match($0, /^\.newgame ?([1-9][0-9]*) *- *([1-9][0-9]*)$/, _arr) { sp_say(FROM " joins the game!") } if (sp_state == "join" && sp_turn == 0) { + sp_scores[0] = 0 + sp_scores[1] = 0 sp_shuf() sp_deal() } @@ -997,6 +1022,6 @@ sp_state == "play" && sp_stats("logs/" $2 ".log"); } -/^\.((new|end|load)game|join|look|bid|pass|play|allow|deny|team|notify)/ { +/^\.((new|end|load)game|fliptable|join|look|bid|pass|play|allow|deny|team|notify)/ { sp_save("var/sp_cur.json"); }