From 345b597dc9245352af94527f658ea55c2de02960 Mon Sep 17 00:00:00 2001 From: jcao219 Date: Sun, 21 Aug 2011 00:39:06 -0500 Subject: [PATCH] add a player record on join in the database --- var.py | 5 +++++ wolfgame.py | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/var.py b/var.py index c4d5aac..e082c35 100644 --- a/var.py +++ b/var.py @@ -209,6 +209,11 @@ def add_away(clk): c.execute('INSERT into away VALUES (?)', (clk,)) +def add_player_record(nick, cloak): + with conn: + c.execute('INSERT OR IGNORE INTO players (nick, cloak) VALUES (?,?)', (nick, cloak)) + + def record_nick_change(from_nick, to_nick, cloak): with conn: c.execute('SELECT id FROM players WHERE nick=? AND cloak=?', (from_nick, cloak)) diff --git a/wolfgame.py b/wolfgame.py index aa256a9..71bdc2f 100644 --- a/wolfgame.py +++ b/wolfgame.py @@ -314,11 +314,17 @@ def fpinger(cli, nick, chan, rest): -@cmd("join") +@cmd("join", raw_nick=True) def join(cli, nick, chan, rest): """Either starts a new game of Werewolf or joins an existing game that has not started yet.""" pl = var.list_players() + + nick, _, __, cloak = parse_nick(nick) + if var.PHASE == "none": + if cloak: + var.add_player_record(nick, cloak) + cli.mode(chan, "+v", nick, nick+"!*@*") var.ROLES["person"].append(nick) var.PHASE = "join" @@ -335,6 +341,9 @@ def join(cli, nick, chan, rest): elif var.PHASE != "join": cli.notice(nick, "Sorry but the game is already running. Try again next time.") else: + if cloak: + var.add_player_record(nick, cloak) + cli.mode(chan, "+v", nick, nick+"!*@*") var.ROLES["person"].append(nick) cli.msg(chan, '\u0002{0}\u0002 has joined the game.'.format(nick))