Beispiel #1
0
def bet(server=None, nick=None, channel=None, text=None, **kwargs):
    rawpoint = text.split(' ', 1)[1]

    times = 1
    if "*" in rawpoint:
        times = try_parse_int(rawpoint.split('*', 1)[1])
        times = times if times is not None else 1

    player = pointsgame.select_player_by_name(nick)

    if times > 5000:
        return

    if rawpoint == "max":
        point = player[2]
    elif times is 1:
        point = try_parse_int(rawpoint)
    else:
        point = try_parse_int(rawpoint.split("*", 1)[0])

    if point is None or point > 100000:
        return

    last_bet = times_win = times_lose = 0
    for time in range(times):
        last_bet = pointsgame.enter_bet(player[0], point)
        if last_bet > 0:
            times_win += 1
        elif last_bet < 0:
            times_lose += 1

    player = pointsgame.select_player_by_name(nick)
    if times > 1:
        message = BotChat.MultiBet.format(nick, times_win,
                                          times_win * point * 2, times_lose,
                                          times_lose * point, player[2])
        if times_win > times_lose:
            server.privmsg(channel, message)
        else:
            server.notice(nick, message)
    else:
        if last_bet > 0:
            server.privmsg(channel, BotChat.BetWin.format(nick, player[2]))
        elif last_bet < 0:
            server.notice(nick, BotChat.BetLose.format(nick, player[2]))
        elif last_bet == 0:
            server.notice(nick, BotChat.BetNotEnoughPoints.format(nick))
Beispiel #2
0
def kick(server=None, channel=None, text=None, nick=None, **kwargs):
    kick_nick = (text.strip().split(" ", 1)[1]).lower()
    if kick_nick in KICK_IGNORE: return

    player = pointsgame.select_player_by_name(nick)
    if pointsgame.has_item(player[0], 5) and pointsgame.use_item(
            player[0], 5) is not False:
        server.kick(channel, kick_nick, "kicked by %s" % nick)
Beispiel #3
0
def reward_punish_player(text=None, **kwargs):
    npr = parse_nickpointreason(text)
    if npr is False: return
    npr[1] = try_parse_int(npr[1])
    if npr[1] is None: return
    player = pointsgame.select_player_by_name(npr[0])
    if text[1:7] == "reward":
        pointsgame.reward_player(player[0], npr[1], npr[2])
    elif text[1:7] == "punish":
        pointsgame.punish_player(player[0], npr[1], npr[2])
Beispiel #4
0
def my_stats(server=None, nick=None, channel=None, text=None, **kwargs):
    # TODO: Show bought items that aren't expired
    params = text.strip().split(' ', 1)
    query_nick = params[1] if len(params) > 1 else nick
    player = pointsgame.select_player_by_name(query_nick)
    server.privmsg(
        channel,
        BotChat.Stats.format(
            BotChat.Stats_My.format(nick)
            if query_nick == nick else BotChat.Stats_NotMy.format(query_nick),
            player[2] if query_nick != config.NICK else u"∞"))
Beispiel #5
0
def store(server=None, nick=None, **kwargs):
    server.notice(
        nick,
        BotChat.Stats.format(BotChat.Stats_My.format(nick),
                             pointsgame.select_player_by_name(nick)[2]))
    index = 0
    for item in pointsgame.items:
        server.notice(
            nick, BotChat.StoreItem %
            (item['name'], item['price'], str(
                item['duration']), str(item['count']), index))
        index += 1
Beispiel #6
0
def buy_item(server=None, nick=None, channel=None, text=None, **kwargs):
    item_id = try_parse_int(text.split(' ', 1)[1])
    if item_id is None: return
    player = pointsgame.select_player_by_name(nick)
    ret = pointsgame.buy_item(player[0], item_id)
    if ret >= 0:
        server.privmsg(
            channel,
            BotChat.BuyItemSuccessful.format(
                nick, pointsgame.items[item_id]['name']))
        if ret == 3:
            server.kick(channel, nick, "KAWAII KICK!")
    else:
        server.privmsg(channel, BotChat.BuyItemUnsuccessful.format(nick))
Beispiel #7
0
def give(server=None, channel=None, nick=None, text=None, **kwargs):
    command, target_nick, points = text.split(' ', 2)

    source_player = pointsgame.select_player_by_name(nick)
    target_player = pointsgame.select_player_by_name(target_nick)

    if points == "max":
        points = source_player[2]
    else:
        points = try_parse_int(points)

    if points <= 0:
        server.notice(nick, BotChat.RequiresMorePoints)
        return

    if server.inchannel(channel, target_nick) is False:
        server.notice(nick, BotChat.Requires2People)
        return

    if pointsgame.transfer_points(source_player[0], target_player[0], points):
        server.notice(nick, BotChat.TransferSuccessful)
    else:
        server.notice(nick, BotChat.TransferUnsuccessful)
Beispiel #8
0
def join_check(server=None, nick=None, channel=None, **kwargs):
    global channel_to_check
    channel_to_check = channel
    player = pointsgame.select_player_by_name(nick)

    if player is not None:
        user_id = player[0]
        if pointsgame.has_item(user_id, 1):
            server.send_raw("MODE %s +v %s" % (channel, nick))
        if pointsgame.has_item(user_id, 0):
            server.action(channel, BotChat.Pets.format(nick))
        if pointsgame.has_item(user_id, 2):
            msg = pointsgame.get_welcome(nick)
            msg = msg[1].format(
                nick) if msg is not None else BotChat.WelcomeDefault.format(
                    nick)
            server.privmsg(channel, msg)

        pointsgame.daily_player_check(nick)
    else:
        register_player(nick)
Beispiel #9
0
def nick_change_check(channel=None, **kwargs):
    if pointsgame.select_player_by_name(channel) is None:
        register_player(channel)
Beispiel #10
0
def register_player(nick):
    pointsgame.add_player(nick)
    player = pointsgame.select_player_by_name(nick)
    pointsgame.logger.info("User (#%s) %s registered!", player[0], nick)
    pointsgame.daily_player_check(nick)