Example #1
0
    def handle_chat(self, player, msg, channel):
        message = msg

        if player.clean_name.lower() == 'iouonegirl':
            return #minqlbot.console_command("print i'll ignore waht u said")

        if self.contains(msg, "shit"):
            minqlbot.console_print("'{}'\n".format(msg))
            channel.reply("^7Do you need a SHEET of paper, {}?".format(player.clean_name.lower()))

        elif self.contains(msg, "bitch"):
            strings = ["^7Perhaps you meant to say 'female dog'?",
                "^7I'd love to go to the BEACH right now! How about you, {}?"]
            idx = random.randrange(0, len(strings))
            formatted = strings[idx].format(player.clean_name.lower())
            channel.reply(formatted)

        elif self.contains(msg, "f**k"):
            minqlbot.console_command("print " + player)
            channel.reply("^7Watch your language! GOD sees everything!")

        elif self.contains(msg, "rape"):
            strings = ["^7You call that ^1RAPE^7? Where I come from we call that tickling!",
                "^7There are NO breaks on the ^1RAPE ^7train!"]
            idx = random.randrange(0, len(strings))
            channel.reply(strings[idx])
Example #2
0
 def return_permission(self, user):
     minqlbot.console_print("User: {}".format(user))
     c = self.db_query("SELECT permission FROM Players WHERE name = ?", user)
     row = c.fetchone()
     if not row:
         return 0
     else:
         return row[0]
Example #3
0
    def cmd_dance(self, player, msg, channel):
        minqlbot.console_print("'good game!'\n") # komt in console
        minqlbot.console_command("print good game!") # komt in text fields
        if self.score_backup is None:
            return
        min_score = 999
        min_player = "999"

        minqlbot.console_print("--{}!".format(self.score_backup)) # komt in text fields
        for score in self.score_backup:
            if score.score > min_score:
                continue
            min_score = score.score
            min_player = score.player.clean_name

        #minqlbot.console_print("[*] dudududududu!") # komt in text fields
        channel.reply("^7.{} has lowest score: {}".format(score.player.clean_name, score.score))
Example #4
0
 def console(self, text):
     """Send text to be printed by the console.
     
     """
     minqlbot.console_print(str(text))
Example #5
0
 def console(cls, text):
     """Send text to be printed by the console.
     
     """
     minqlbot.console_print(str(text))
Example #6
0
    def cmd_debug(self, player, msg, channel):
        if player.clean_name.lower() != 'iouonegirl':
            return


        listt = ['p1', 'p2', 'p3', 'p4', 'p5']
        for n in range(len(listt)):
            string = "Delay {} for player: {}".format(n*2, listt[n])
            self.debug(string)
            self.delay(n*2, lambda: self.msg(string))
        return
        if self.score_backup is None:
            minqlbot.console_print("<none>")
            return

        minqlbot.console_print(str(dir(self.score_backup[0])))
        minqlbot.console_print("\n\ngot it?\n\n")
        for cascore in self.score_backup:
            minqlbot.console_print(str(cascore.player.clean_name))
            minqlbot.console_print("\n")
            minqlbot.console_print(str(cascore.score))
Example #7
0
 def reply(self, msg):
     minqlbot.console_print("{}\n".format(msg))
Example #8
0
 def reply(self, msg):
     minqlbot.console_print("{}\n".format(msg))
Example #9
0
    def handle_scores(self, scores):

        # Update scores
        self.scores_live = scores

        # If there is no flag set, it's not the end of a round yet
        if not self.flag:
            return

        winner = self.flag
        losers = 'redblue'.replace(winner, '')

        self.flag = '' # Reset flag for next time

        # Calculate if we are in a special case
        amount_of_rounds = (self.game().red_score + self.game().blue_score)
        special_case =  (self.scores_snapshot == {}) and (amount_of_rounds > 1)
        # After the loop that creates the snapshot is done, end the calculations

        if LIST_ALL_CONSOLE:
            minqlbot.console_print("^7> Round ended. Here are the damage results:\n")

        # Store the current damage differences from this round in this dict
        round_diffs = []

        # Store the messages for personal damages, so we can display it after the lowest-highest message
        personal_messages = []

        # This loop will create the snapshot of the round scores/damages for next round
        for s in self.scores_live:

            # ignore players that are not actively playing
            if s.team not in ['red', 'blue']:
                continue

            # Iteration variables
            name = s.player.clean_name.lower()
            team = s.team
            prev_dmg = self.get_player_score(name)
            curr_dmg = s.damage_done
            diff = curr_dmg - prev_dmg
            tc = self.get_team_color(team)
            matches_completed = self.get_completed_matches(name)
            bool_matches_required = matches_completed >= COMPLETED_MATCHES

            if LIST_ALL_CONSOLE:
                minqlbot.console_print("^7> ^{}{}^7: {} damage\n".format(tc, name, diff))

            # Make sure the player is known in the usefull damages counter, starting with 0.
            # Partly to evade a try/catch statement, partly so 0 damages can be shown
            if not self.scores_usefull.get(name):
                self.scores_usefull[name] = [team, 0]

            # If the player is in the winning team, count the usefull damage for after the game
            # and it's not the special case, because it wouldnt be fair to the players
            # that won the round just after the plugin was restarted
            if team == winner and not special_case:
                val = self.scores_usefull[name]
                previous_usefull_damage = val[1]

                # Note that this sets the team to where the user is in now.
                # If he switched teams, the usefull damage will be switched with him
                self.scores_usefull[name] = [winner, previous_usefull_damage + diff]

            # Store the difference for calculations after the iteration
            # Handicapped people need to have their differences recalculated.
            diff = self.calculate_handicap(diff, max(s.player['hc'], self.handicaps[name]))

            round_diffs.append([name, team, diff, bool_matches_required])
            # Add it to the snapshot to compare it to the next time.
            self.scores_snapshot[name] = [team, curr_dmg]


        # SPECIAL CASE: plugin was reloaded during a game:
        # scores snapshot would have been empty, but it wasn't be the first round
        if special_case:
            # Ignore this round because the game is on and plugin was reloaded
            self.msg("^7Skipping damage calculations since plugin was restarted mid-game...")
            # But do save the current scores for the next end of round:
            return

        # Now iterate over differences to find greatest and lowest values
        lowest_names = []
        lowest_dmg = 9000
        highest_names = []
        highest_dmg = -1

        round_diffs.sort(key=lambda el: el[2], reverse = True) # sort on damage high>low

        # Find highest damage doers for winning team
        for record in round_diffs:
            name, team, diff, bool_matches_required = record
            tc = self.get_team_color(team)

            # Highest damage doer for winning team:
            if team == winner and diff > highest_dmg:
                highest_names = [[tc,name]]
                highest_dmg = diff
            elif team == winner and diff == highest_dmg:
                highest_names.append([tc,name])

            # Lowest from losing team
            if team == losers and diff < lowest_dmg:
                lowest_names = [[tc,name]]
                lowest_dmg = diff
            elif team == losers and diff == lowest_dmg:
                lowest_names.append([tc,name])

            # Also check if the highest damage is a top record for the map
            curr_map = self.game().short_map
            bool_still_space = len(self.top_damages) < 10
            # If there isnt still space, we are able to always get index [-1] (lowest one)
            if (team == winner) and bool_matches_required and (bool_still_space or (diff > self.top_damages[-1]['dmg'])):


                # If we are only here because we are filling this map up (<10)
                # Just insert it and make no big deal about it
                if bool_still_space:
                    self.db_insert_top_damage(name, curr_map, diff)
                    self.top_damages = self.db_get_top_damages(curr_map)
                else:

                    lowest_top = self.top_damages[-1]

                    # Insert into database. If False then not inserted, but continue
                    if not self.db_insert_top_damage(name, curr_map, diff):
                        continue
                    # Remove lowest value
                    # commented out because we'll just accumulate these values in the DB
                    # self.db_remove_top_damage(lowest_top['name'], curr_map, lowest_top['dmg'])
                    # Update the top damages for this map
                    self.top_damages = self.db_get_top_damages(curr_map)

                    for el in self.top_damages:
                        if el['name'] == name and el['dmg'] == diff:
                            pos = self.top_damages.index(el)
                            #self.msg("^7Holy shit! ^2{}^7's damage (^3{}^7) earned position ^2{}^7 in the maptopdmg list!".format(name, diff, pos+1))
                            personal_messages.append("^7Holy shit! ^2{}^7's damage (^1{}^7) earned position ^3{}^7 in the maptopdmg list!".format(name, diff, pos+1))
                            break

            # If winning team (and completed matches required), check if this is a personal best:
            if team == winner and bool_matches_required:
                player_prev_top, mapname = self.db_get_top_damage_for_players(name)
                if player_prev_top > 0 and  diff > player_prev_top:
                    #self.msg("^7New ^2personal^7 record for ^6{}^7: ^3{}^7 useful damage!".format(name, diff))
                    personal_messages.append("^7New personal record for ^3{}^7: ^5{}^7 useful damage!".format(name, diff))


            if self.get_tell_preference(name) == 1:
                self.debug("Trying to tell {} his score({}) ".format(name,diff))
                player_ = self.find_player(name)
                if player_:
                    player_.tell("You have done {} damage this round.".format(diff))
                else:
                    minqlbot.console_command("tell {} You have done {} damage this round.".format(name, diff))


        # If SHOW_LAST_ROUND is turned off and we hit last round, we don't display last message
        if  not SHOW_LAST_ROUND and self.game().roundlimit in self.game().scores:
            return

        # Shame/Praise those people:
        say = "^7Least dmg: {} ({})  --  Most dmg: {} ({})"
        self.msg(say.format(self.pretty_print(lowest_names), lowest_dmg, self.pretty_print(highest_names), highest_dmg))

        # Then display the (personal) messages
        personal_messages.reverse()
        for record in personal_messages:
            self.delay(0.8, self.msg, args=(record,))