X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=spades.awk;h=fa79e88dd6d27654ec8e3cce7a63934ef08d7f1d;hb=7f222111278da0a210ba0078bef57ae2a0d5d531;hp=9a1332e0c28d87bdf783987dec95b8ea34a25b86;hpb=2cc4461062b8496408f7ae49f864a5067faf4645;p=~andy%2Frhawk diff --git a/spades.awk b/spades.awk index 9a1332e..fa79e88 100644 --- a/spades.awk +++ b/spades.awk @@ -17,7 +17,7 @@ function sp_init(cards, tmp0, tmp1) 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 } @@ -52,7 +52,7 @@ function sp_reset(type) sp_limit = 10 # Bag out limit delete sp_hands # [p] Each players cards delete sp_players # [p] Player names players["name"] -> i - delete sp_cloaks # [c] Player cloaks cloaks["cloak"] -> "name" + delete sp_auths # [c] Player auth names auths["auth"] -> "name" delete sp_order # [i] Player order order[i] -> "name" delete sp_scores # [i] Teams score } @@ -91,7 +91,7 @@ function sp_save(file, game) game["limit"] = sp_limit; json_copy(game, "hands", sp_hands); json_copy(game, "players", sp_players); - json_copy(game, "cloaks", sp_cloaks); + json_copy(game, "auths", sp_auths); json_copy(game, "order", sp_order); json_copy(game, "scores", sp_scores); @@ -102,7 +102,8 @@ function sp_save(file, game) function sp_load(file, game) { # Load - json_load(file, game); + if (!json_load(file, game)) + return # Per hand sp_suit = game["suit"]; @@ -128,7 +129,7 @@ function sp_load(file, game) sp_limit = game["limit"]; sp_acopy(sp_hands, game["hands"]); sp_acopy(sp_players, game["players"]); - sp_acopy(sp_cloaks, game["cloaks"]); + sp_acopy(sp_auths, game["auths"]); sp_acopy(sp_order, game["order"]); sp_acopy(sp_scores, game["scores"]); } @@ -168,13 +169,13 @@ function sp_deal( shuf) 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