Conflicts:
	modules/wolfgame.py
This commit is contained in:
Skizzerz 2014-07-12 13:13:56 -05:00
commit 3f61a60f21
2 changed files with 68 additions and 42 deletions

View File

@ -1,11 +1,23 @@
# Copyright (c) 2011, Jimmy Cao # Copyright (c) 2011, Jimmy Cao All rights reserved.
# All rights reserved. #
# Redistribution and use in source and binary forms, with or without
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
#
# Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. # Redistributions of source code must retain the above copyright notice, this
# Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. # list of conditions and the following disclaimer. Redistributions in binary
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # form must reproduce the above copyright notice, this list of conditions and
# the following disclaimer in the documentation and/or other materials provided
# with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS
# AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
# BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER
# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
from oyoyo.parse import parse_nick from oyoyo.parse import parse_nick
import settings.wolfgame as var import settings.wolfgame as var
@ -3101,74 +3113,85 @@ def _flastgame(cli, nick, chan, rest):
flastgame(cli, nick, rest) flastgame(cli, nick, rest)
@cmd("gamestats", "gstats") @cmd('gamestats', 'gstats')
def game_stats(cli, nick, chan, rest): def game_stats(cli, nick, chan, rest):
"""Gets the game stats for a given game size or lists game totals for all game sizes if no game size is given.""" """Gets the game stats for a given game size or lists game totals for all game sizes if no game size is given."""
if (chan != nick and var.LAST_GSTATS and if (chan != nick and var.LAST_GSTATS and var.GSTATS_RATE_LIMIT and
var.LAST_GSTATS + timedelta(seconds=var.GSTATS_RATE_LIMIT) > datetime.now()): var.LAST_GSTATS + timedelta(seconds=var.GSTATS_RATE_LIMIT) >
cli.notice(nick, ("This command is rate-limited. " + datetime.now()):
"Please wait a while before using it again.")) cli.notice(nick, ('This command is rate-limited. Please wait a while '
'before using it again.'))
return return
if chan != nick: if chan != nick:
var.LAST_GSTATS = datetime.now() var.LAST_GSTATS = datetime.now()
if var.PHASE not in ("none", "join"): if var.PHASE not in ('none', 'join'):
cli.notice(nick, "Wait until the game is over to view stats.") cli.notice(nick, 'Wait until the game is over to view stats.')
return return
# List all games sizes and totals if no size is given. # List all games sizes and totals if no size is given
if rest == "": if not rest:
if chan == nick: if chan == nick:
pm(cli, nick, var.get_game_totals()) pm(cli, nick, var.get_game_totals())
else: else:
cli.msg(chan, var.get_game_totals()) cli.msg(chan, var.get_game_totals())
return return
# Check for invalid input # Check for invalid input
rest = rest.strip() rest = rest.strip()
if not rest.isdigit() or int(rest) > var.MAX_PLAYERS or int(rest) < var.MIN_PLAYERS: if not rest.isdigit() or int(rest) > var.MAX_PLAYERS or int(rest) < var.MIN_PLAYERS:
cli.notice(nick, "Please enter an integer between {0} and {1}.".format(var.MIN_PLAYERS, var.MAX_PLAYERS)) cli.notice(nick, ('Please enter an integer between {} and '
'{}.').format(var.MIN_PLAYERS, var.MAX_PLAYERS))
return return
# Attempt to find game stats for the given game size. # Attempt to find game stats for the given game size
if chan == nick: if chan == nick:
pm(cli, nick, var.get_game_stats(int(rest))) pm(cli, nick, var.get_game_stats(int(rest)))
else: else:
cli.msg(chan, var.get_game_stats(int(rest))) cli.msg(chan, var.get_game_stats(int(rest)))
@pmcmd("gamestats", "gstats")
@pmcmd('gamestats', 'gstats')
def game_stats_pm(cli, nick, rest): def game_stats_pm(cli, nick, rest):
game_stats(cli, nick, nick, rest) game_stats(cli, nick, nick, rest)
@cmd("playerstats", "pstats", "player", "p")
@cmd('playerstats', 'pstats', 'player', 'p')
def player_stats(cli, nick, chan, rest): def player_stats(cli, nick, chan, rest):
"""Gets the stats for the given player and role or a list of role totals if no role is given.""" """Gets the stats for the given player and role or a list of role totals if no role is given."""
#if (chan != nick and var.LAST_PSTATS and if (chan != nick and var.LAST_PSTATS and var.PSTATS_RATE_LIMIT and
# var.LAST_PSTATS + timedelta(seconds=var.PSTATS_RATE_LIMIT) > datetime.now()): var.LAST_PSTATS + timedelta(seconds=var.PSTATS_RATE_LIMIT) >
# cli.notice(nick, ("This command is rate-limited. " + datetime.now()):
# "Please wait a while before using it again.")) cli.notice(nick, ('This command is rate-limited. Please wait a while '
# return 'before using it again.'))
return
if chan != nick: if chan != nick:
var.LAST_PSTATS = datetime.now() var.LAST_PSTATS = datetime.now()
if var.PHASE not in ("none", "join"): if var.PHASE not in ('none', 'join'):
cli.notice(nick, "Wait until the game is over to view stats.") cli.notice(nick, 'Wait until the game is over to view stats.')
return return
# Check if we have enough parameters.
params = rest.split() params = rest.split()
if len(params) < 1:
user = nick
else:
user = params[0]
# Find the player's account if possible. # Check if we have enough parameters
if params:
user = params[0]
else:
user = nick
# Find the player's account if possible
if user in var.USERS: if user in var.USERS:
acc = var.USERS[user]["account"] acc = var.USERS[user]['account']
if acc == "*": if acc == '*':
cli.notice(nick, "{0} is not identified with NickServ.".format(user)) if user == nick:
cli.notice(nick, 'You are not identified with NickServ.')
else:
cli.notice(nick, user + ' is not identified with NickServ.')
return return
else: else:
acc = user acc = user
@ -3180,17 +3203,20 @@ def player_stats(cli, nick, chan, rest):
else: else:
cli.msg(chan, var.get_player_totals(acc)) cli.msg(chan, var.get_player_totals(acc))
else: else:
role = " ".join(params[1:]) role = ' '.join(params[1:])
# Attempt to find the player's stats.
# Attempt to find the player's stats
if chan == nick: if chan == nick:
pm(cli, nick, var.get_player_stats(acc, role)) pm(cli, nick, var.get_player_stats(acc, role))
else: else:
cli.msg(chan, var.get_player_stats(acc, role)) cli.msg(chan, var.get_player_stats(acc, role))
@pmcmd("playerstats", "pstats", "player", "p")
@pmcmd('playerstats', 'pstats', 'player', 'p')
def player_stats_pm(cli, nick, rest): def player_stats_pm(cli, nick, rest):
player_stats(cli, nick, nick, rest) player_stats(cli, nick, nick, rest)
@cmd("fpull", admin_only=True) @cmd("fpull", admin_only=True)
def fpull(cli, nick, chan, rest): def fpull(cli, nick, chan, rest):
output = None output = None

View File

@ -8,8 +8,8 @@ MAXIMUM_WAITED = 3 # limit for amount of !wait's
STATS_RATE_LIMIT = 60 STATS_RATE_LIMIT = 60
VOTES_RATE_LIMIT = 60 VOTES_RATE_LIMIT = 60
ADMINS_RATE_LIMIT = 300 ADMINS_RATE_LIMIT = 300
GSTATS_RATE_LIMIT = 15 GSTATS_RATE_LIMIT = 0
PSTATS_RATE_LIMIT = 15 PSTATS_RATE_LIMIT = 0
TIME_RATE_LIMIT = 60 TIME_RATE_LIMIT = 60
SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given SHOTS_MULTIPLIER = .12 # ceil(shots_multiplier * len_players) = bullets given
SHARPSHOOTER_MULTIPLIER = 0.06 SHARPSHOOTER_MULTIPLIER = 0.06