Esempio n. 1
0
def invite_player(bot, trigger):
    bot.say("Welcome to the game " + trigger.group(1) +
            ", here's 50 sf::Tokens!")
    bot.playerdb.set_nick_value(trigger.group(1), "balance", 50)
    bot.playerdb.set_nick_value(trigger.group(1), "health", 50)
    bot.playerdb.set_nick_value(trigger.group(1), "attack", 50)
    bot.playerdb.set_nick_value(trigger.group(1), "defense", 50)
Esempio n. 2
0
def fight(bot, trigger):
    attackerBalance = bot.playerdb.get_nick_value(trigger.nick, "balance")
    if attackerBalance is None:
        bot.reply("You are not part of the game :(")
        return
    defenderBalance = bot.playerdb.get_nick_value(trigger.group(1), "balance")
    if defenderBalance is None:
        bot.reply(trigger.group(1) + " is not part of the game :(")
        return

    if trigger.nick == trigger.group(1):
        bot.reply("You hurt yourself and lost one sf::Token")
        bot.playerdb.set_nick_value(trigger.nick, "balance",
                                    int(attackerBalance) - 1)
        return

    #check they haven't already fought in the last 5 mins
    lastFightTime = bot.playerdb.get_nick_value(trigger.nick, trigger.group(1))
    if lastFightTime is not None:
        if lastFightTime > time.time() - 300:
            bot.reply("Don't be such a bully")
            return

    bot.playerdb.set_nick_value(trigger.nick, trigger.group(1), time.time())

    attackerAttack = bot.playerdb.get_nick_value(trigger.nick, "attack")
    if attackerAttack is None:
        attackerAttack = 50
        bot.playerdb.set_nick_value(trigger.nick, "attack", attackerAttack)
    defenderDefense = bot.playerdb.get_nick_value(trigger.group(1), "defense")
    if defenderDefense is None:
        defenderDefense = 50
        bot.playerdb.set_nick_value(trigger.group(1), "defense",
                                    defenderDefense)
    result = random.randint(0, int(attackerAttack) + int(defenderDefense))
    if result < attackerAttack:
        winner = trigger.nick
        loser = trigger.group(1)
    else:
        winner = trigger.group(1)
        loser = trigger.nick
    bot.say(winner + " was victorious! They won 1 sf::Token from " + loser)
    winnerbalance = bot.playerdb.get_nick_value(winner, "balance")
    loserbalance = bot.playerdb.get_nick_value(loser, "balance")
    bot.playerdb.set_nick_value(winner, "balance", winnerbalance + 1)
    bot.playerdb.set_nick_value(loser, "balance", loserbalance - 1)
    winnerWins = bot.playerdb.get_nick_value(winner, "wins")
    loserLosses = bot.playerdb.get_nick_value(loser, "losses")
    if winnerWins is None:
        winnerWins = 0
    if loserLosses is None:
        loserLosses = 0
    bot.playerdb.set_nick_value(winner, "wins", int(winnerWins) + 1)
    bot.playerdb.set_nick_value(loser, "losses", int(loserLosses) + 1)
Esempio n. 3
0
def bug_subject(bot, trigger):
    bot.rm.key = bot.rmdb.get_channel_value(trigger.sender,"apikey")
    bot.rm.url = bot.rmdb.get_channel_value(trigger.sender,"url")
    matches = re.findall(r"#(\d+)",trigger.group(0))
    for match in matches:
        try:
            issue = bot.rm.issue.get(int(match))
        except Exception as ex:
            bot.say(ex)
        else:
            bot.say(issue.subject)
            bot.say(bot.rm.url + "issues/" + match)
Esempio n. 4
0
def bug_subject(bot, trigger):
    bot.rm.key = bot.rmdb.get_channel_value(trigger.sender, "apikey")
    bot.rm.url = bot.rmdb.get_channel_value(trigger.sender, "url")
    matches = re.findall(r"#(\d+)", trigger.group(0))
    for match in matches:
        try:
            issue = bot.rm.issue.get(int(match))
        except Exception as ex:
            bot.say(ex)
        else:
            bot.say(issue.subject)
            bot.say(bot.rm.url + "issues/" + match)
Esempio n. 5
0
def give_tokens(bot, trigger):
    if int(trigger.group(2)) == 0:
        bot.reply("Are you mugging me off?")
    if trigger.nick == trigger.group(1):
        bot.reply("You sf::Muppet")
        return
    giverBalance = bot.playerdb.get_nick_value(trigger.nick, "balance")
    if giverBalance is None:
        bot.reply("You aren't part of the game :(")
        return
    receiverBalance = bot.playerdb.get_nick_value(trigger.group(1), "balance")
    if receiverBalance is None:
        bot.say(trigger.group(1) + " is not part of the game :(")
        return
    if int(trigger.group(2)) > int(giverBalance):
        bot.reply("you wish you had that many sf::Tokens")
        return
    bot.say(trigger.nick + " has generously given " + trigger.group(1) + " " +
            trigger.group(2) + " sf::Tokens")
    bot.playerdb.set_nick_value(trigger.group(1), "balance",
                                receiverBalance + int(trigger.group(2)))
    bot.playerdb.set_nick_value(trigger.nick, "balance",
                                giverBalance - int(trigger.group(2)))
Esempio n. 6
0
def explore_location(bot, trigger):
    location = int(trigger.group(2)) - 1

    #check they haven't already explored this hour
    lastExploreTime = bot.playerdb.get_nick_value(trigger.nick,
                                                  "lastExploration")
    if lastExploreTime is not None:
        if lastExploreTime > time.time() - 600:
            bot.reply("You're too tired to explore again, chill")
            return

    bot.playerdb.set_nick_value(trigger.nick, "lastExploration",
                                int(time.time()))
    message = monsters[location]
    win = random.randint(0, 100)
    if win < winPercs[location]:
        message += winStrings[location]
        change = 100 / winPercs[location]
    else:
        change = -100 / winPercs[location]
        message += loseStrings[location]

    #chance of stat change related to difficulty
    if random.randint(0, 100) > winPercs[location]:
        message += "Your stats have been affected: "
        #50\50 attack or defense
        if random.randint(0, 1) == 0:
            stat = "attack"
        else:
            stat = "defense"
        message += str(stat) + " "
        current = int(bot.playerdb.get_nick_value(trigger.nick, stat))
        bot.playerdb.set_nick_value(trigger.nick, stat, current + change)
        message += str(change)

    if random.randint(0, 100) > winPercs[location]:
        message += " Your balance has been affected: "
        balance = int(bot.playerdb.get_nick_value(trigger.nick, "balance"))
        bot.playerdb.set_nick_value(
            trigger.nick, "balance",
            int(balance) + int(change / abs(change) *
                               (100 - winPercs[location])))
        message += str(change / abs(change) * (100 - winPercs[location]))
    bot.reply(message)
Esempio n. 7
0
def set_project(bot,trigger):
    if trigger.owner is True:
        bot.rmdb.set_channel_value(trigger.group(3),"project",trigger.group(4))
        bot.reply("Redmine key for channel " + trigger.group(3) + " set to " + trigger.group(4))
Esempio n. 8
0
def set_url(bot, trigger):
    if trigger.owner is True:
        bot.rmdb.set_channel_value(trigger.group(3),"url",trigger.group(4))
        bot.reply("Redmine URL for channel " + trigger.group(3) + " set to " + trigger.group(4))
Esempio n. 9
0
def set_project(bot, trigger):
    if trigger.owner is True:
        bot.rmdb.set_channel_value(trigger.group(3), "project",
                                   trigger.group(4))
        bot.reply("Redmine key for channel " + trigger.group(3) + " set to " +
                  trigger.group(4))
Esempio n. 10
0
def set_url(bot, trigger):
    if trigger.owner is True:
        bot.rmdb.set_channel_value(trigger.group(3), "url", trigger.group(4))
        bot.reply("Redmine URL for channel " + trigger.group(3) + " set to " +
                  trigger.group(4))