コード例 #1
0
def symmetric_triangle(n: int = None, **kwargs: dict) -> Optional[List[int]]:
    """Symmetric Triangle with n >= 2

    Returns a numpy array of the nth row of Symmetric Triangle.
    n=4  => triangle: [1, 2, 2, 1]
         => weighted: [0.16666667 0.33333333 0.33333333 0.16666667]
    """
    n = int(npFabs(n)) if n is not None else 2

    triangle = None
    if n == 2:
        triangle = [1, 1]

    if n > 2:
        if n % 2 == 0:
            front = [i + 1 for i in range(0, mfloor(n / 2))]
            triangle = front + front[::-1]
        else:
            front = [i + 1 for i in range(0, mfloor(0.5 * (n + 1)))]
            triangle = front.copy()
            front.pop()
            triangle += front[::-1]

    if kwargs.pop("weighted", False) and isinstance(triangle, list):
        triangle_sum = npSum(triangle)
        triangle_weights = triangle / triangle_sum
        return triangle_weights

    return triangle
コード例 #2
0
ファイル: getxpamount.py プロジェクト: AudioVisuaali/audiobot
async def user_xp(message, client, arguments):

    # For user request
    if len(arguments) == 0:

        # Calculating xp and level
        response = users_get_xp(message.author.id)
        levels = level_check_command(message.author.id)
        progress = str(mfloor((levels[2] / levels[3])*100))

        await client.send_message(message.channel, ":b:  **| " + message.author.name + " you are level "+str(levels[1])+" and you have " + str(response[0]) + " xp in total! "+progress+"% done on the current level!**")

    # user request on others
    if len(arguments) == 1:
        if not message.author.id in owners:
            return
        # Getting user
        user = await get_user_instance(message, arguments[0])

        # Getting xp and calculating level for id
        response = users_get_xp(user.id)
        levels = level_check_command(user.id)
        progress = str(mfloor((levels[2] / levels[3])*100))

        # Sending message
        await client.send_message(message.channel, ":b:  **| "+ user.name + " is level "+str(levels[1])+" and has " + str(response[0]) + " xp in total! "+progress+"% done on the current level!**")
コード例 #3
0
ファイル: tuplat.py プロジェクト: AudioVisuaali/audiobot
async def tuplat(message, client, arguments):

    if len(arguments) == 0:
        # Getting stats
        user = message.author
        stats = users_get_roll_stats(message.author.id)

    else:

        user = await get_user_instance(message, arguments[0])
        try:
            stats = users_get_roll_stats(user.id)
        except:
            send(1, "No user found")
            await client.send_message(message.channel, ":game_die: **| User not found!**")
            return

    # Name
    if user.nick is None:
        name = user.name
    else:
        name = user.nick

    # name
    user_mention = " for: " + name

    # Calculating winrate
    try:
        win_rate = mfloor(int(stats[1]) / int(stats[0]) * 100)
    except:
        win_rate = "0"
    # Memes
    if stats[2] == 0:
        memes = ""
    else:
        try:
            memes = "\n:money_with_wings: Memes gained: {}".format(mfloor(stats[2]))
        except:
            memes = ""

        # Tokens
    if stats[3] == 0:
        tokens = ""
    else:
        try:
            tokens = "\n:trophy: Tokens gained: {}".format(mfloor(stats[3]))
        except:
            tokens = ""

    # Creating message
    letter = ":game_die: **| Roll stats{}\n\n:arrows_counterclockwise: Rolled: {}\n:tada: Doubles: {}\n:thinking: Win-rate: {}%{}{}**".format(user_mention, stats[0], stats[1], win_rate, memes, tokens)

    await client.send_message(message.channel, letter)
コード例 #4
0
 def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)
     self.controller = controller
     MenuPage.__init__(self, parent, controller)
     buttonWidth = mfloor((windowWidth / 7) / 7.5)
     tk.Label(self,
              text="Menu",
              font=controller.title_font,
              bg=controller.bgCol).grid(sticky="W",
                                        row=1,
                                        column=1,
                                        columnspan=7,
                                        padx=10)
     #tk.Button(self, text="Save", command=lambda: controller.save_game('sav1'), width = buttonWidth, bg=color0hex).grid(row=3, column=4)
     tk.Button(self,
               text="Load",
               command=lambda: controller.load_game("EscPage"),
               width=buttonWidth,
               bg=color0hex).grid(row=4, column=4)
     tk.Button(self,
               text="Options",
               command=lambda: controller.show_frame("EscPage"),
               width=buttonWidth,
               bg=color0hex).grid(row=5, column=4)
     tk.Button(self,
               text="Exit to main menu",
               command=lambda: controller.show_frame("MenuMenu"),
               width=buttonWidth,
               bg=color0hex).grid(row=6, column=4)
     tk.Button(self,
               text="Exit to OS",
               command=lambda: sys.exit(),
               width=buttonWidth,
               bg=color0hex).grid(row=7, column=4)
コード例 #5
0
def total_weeks(offset=3):

    # Calculating time from epoch
    epoch_start = datetime.utcfromtimestamp(0)
    now = datetime.today()
    delta = now - epoch_start

    # calculating week with offset and returning it
    week_amount = mfloor((delta.days + offset) / 7)
    return week_amount
コード例 #6
0
    async def main(self, bot, database, message, arguments):

        if len(arguments) == 0:
            owner = message.author
        else:
            owner = await bot.utils.get_user_instance(message.server,
                                                      arguments[0])

        stats = bot.database.double.get_stats_user(owner.id)

        if stats is None:
            return

        name = bot.utils.author_nickanme(owner)
        user_mention = " for: " + name

        # Calculating winrate
        try:
            win_rate = mfloor(int(stats.doubles) / int(stats.rows) * 100)
        except:
            win_rate = "0"

        if stats.memes == 0:
            memes = ""
        else:
            try:
                memes = "\n:money_with_wings: Memes gained: {}".format(
                    mfloor(stats.memes))
            except:
                memes = ""

        if stats.tokens == 0:
            tokens = ""
        else:
            try:
                tokens = "\n:trophy: Tokens gained: {}".format(
                    mfloor(stats.tokens))
            except:
                tokens = ""

        letter = ":game_die: **| Roll stats{}\n\n:arrows_counterclockwise: Rolled: {}\n:tada: Doubles: {}\n:thinking: Win-rate: {}%{}{}**".format(
            user_mention, stats.rows, stats.doubles, win_rate, memes, tokens)
        await bot.say(message.channel, letter)
コード例 #7
0
ファイル: online.py プロジェクト: AudioVisuaali/audiobot
async def online(message, client, arguments):

    cooldown_lists_time = global_cd_list_per_command()
    asd = cooldown_lists_time.bot_start_up_time
    # Calc time
    time_now = datetime.now()
    #asd = bot_start_up_time()
    time_in_seconds = mfloor((time_now - asd).total_seconds())

    #time
    if time_in_seconds < 60:
        asd = str(time_in_seconds) + " seconds"
    elif time_in_seconds < 3600:
        asd = str(mfloor(time_in_seconds / 60)) + " minutes"
    elif time_in_seconds < 86400:
        asd = str(mfloor(time_in_seconds / 3600)) + " hours"
    elif time_in_seconds < 604800:
        asd = str(mfloor(time_in_seconds / 86400)) + " days"
    elif time_in_seconds < 2419200:
        asd = str(mfloor(time_in_seconds / 604800)) + " weeks"
    elif time_in_seconds >= 2419200:
        asd = str(mfloor(time_in_seconds / 2419200)) + " months"

    # sending message ///UNDER CONSTRUCTION
    asdaa = server_stats_restarts()
    await client.send_message(
        message.channel, ":clock10: **| bot has been online for " + asd +
        " and has been restarted " + asdaa + " times**")
コード例 #8
0
    async def main(self, bot, database, message, arguments):

        if not arguments:
            letter = ":clock11: **| Servers time is {}**".format(
                str(datetime.fromtimestamp(mfloor(time())).strftime('%H:%M')))
            await bot.say(message.channel, letter)

        else:
            google = quote(str(arguments[0]))
            query = "https://maps.googleapis.com/maps/api/geocode/json?address={}&key={}&language={}".format(
                google, bot.config.google.key, "en")

            json_data = await bot.utils.web.get_content(query)
            geo = bot.utils.json2obj(json_data)

            if geo.status == "OK":
                lat = str(
                    float("{0:.4f}".format(
                        geo.results[0].geometry.location.lat)))
                lng = str(
                    float("{0:.4f}".format(
                        geo.results[0].geometry.location.lng)))

                query = "https://maps.googleapis.com/maps/api/timezone/json?location=%s,%s&timestamp=%s&key=%s&language=%s" % (
                    lat, lng, time(), bot.config.google.key, "en")
                json_data = await bot.utils.web.get_content(query)
                location = bot.utils.json2obj(json_data)

                time_now = str(
                    int(time() + location.rawOffset + location.dstOffset))
                time_in_hour_format = datetime.fromtimestamp(
                    int(time_now)).strftime('%H:%M')
                time_in_weekday = datetime.fromtimestamp(
                    int(time_now)).weekday()

                if time_in_weekday == 0: day_is = "Monday"
                elif time_in_weekday == 1: day_is = "Tuesday"
                elif time_in_weekday == 2: day_is = "Wednesday"
                elif time_in_weekday == 3: day_is = "Thursday"
                elif time_in_weekday == 4: day_is = "Friday"
                elif time_in_weekday == 5: day_is = "Saturday"
                elif time_in_weekday == 6: day_is = "Sunday"

                letter = ":clock11: **| Time in {} is {} and the day is {}**".format(
                    geo.results[0].formatted_address, time_in_hour_format,
                    day_is)
                await bot.say(message.channel, letter)
コード例 #9
0
 def __init__(self, parent, controller):
     tk.Frame.__init__(self, parent)
     self.controller = controller
     buttonWidth = mfloor((windowWidth / 7) / 7.5)
     tk.Button(self,
               text="Stats",
               command=lambda: controller.show_frame("StatsPage"),
               width=buttonWidth,
               bg=color0hex,
               fg=color1hex).grid(row=0, column=1, pady=10)
     tk.Button(self,
               text="Drivers",
               command=lambda: controller.show_frame("DriversPage"),
               width=buttonWidth,
               bg=color0hex).grid(row=0, column=2)
     tk.Button(self,
               text="Cars",
               command=lambda: controller.show_frame("CarPage"),
               width=buttonWidth,
               bg=color0hex).grid(row=0, column=3)
     tk.Button(self,
               text="Money",
               command=lambda: controller.show_frame("MoneyPage"),
               width=buttonWidth,
               bg=color0hex).grid(row=0, column=4)
     tk.Button(self,
               text="Ranks",
               command=lambda: controller.show_frame("RanksPage"),
               width=buttonWidth,
               bg=color0hex).grid(row=0, column=5)
     tk.Button(self,
               text="Wiki",
               command=lambda: controller.show_frame("WikiPage"),
               width=buttonWidth,
               bg=color0hex).grid(row=0, column=6)
     tk.Button(self,
               text="Menu",
               command=lambda: controller.show_frame("EscPage"),
               width=buttonWidth,
               bg=color0hex).grid(row=0, column=7)
     Frame(self, bg=color2hex, height=5, width=windowWidth).grid(
         row=2, column=1,
         columnspan=7)  #linia przerwy między menu, a resztą strony
     Frame(self, bg=color2hex, height=5, width=windowWidth).grid(
         row=10, column=1, columnspan=7
     )  #linia przerwy między resztą strony, a paskiem czasu, przyciski na górze
コード例 #10
0
ファイル: EDUtilsBioSaxs.py プロジェクト: gbourgh/edna
    def analyse(self):
        # Note: This algorithm was tested with data acquired at BM29 in late 2012, early 2013
        # Changes in the acquisition protocol might require adaption of parameters

        # paramterers for finding ROIs:
        smoothing_degree = 9

        # parameters for smoothing for peak finding
        nyf = 0.5
        first_butter_par = 4
        second_butter_par = 0.1 / nyf

        # parameters for peak finding algorithm
        window_min_size = 1
        window_max_size_rel = 0.2  # to be multiplied by size of ROI

        Ismooth = medfilt(self.I0, smoothing_degree)
        lab = label(Ismooth)
        Rgsmooth = medfilt(self.Rg, smoothing_degree)
        res = []
        self.merge_frames = []

        for i in range(1, int(lab.max() + 1)):
            loc = (lab == i)
            c = loc.sum()
            # Only analyse peak regions of at leat 10 subsequent frames
            if c > 10:
                idx = numpy.where(loc)[0]
                start = idx[0]
                stop = idx[-1]
                Ishort = self.I0[start:stop]
                I0med = Ismooth[start:stop]

                Rgmed = Rgsmooth[start:stop]
                Rg_Stdshort = self.Rg_Stdev[start:stop]
                Rgshort = self.Rg[start:stop]
                # This is an attempt to remove "dirt" - long broad peaks with no real peeak structure, noise on short timescales
                # Test this with Ishort vs I0med
                if datasmoothness(Ishort, I0med) < 0.25:
                    #

                    # we smooth the data with a butterworth filter to remove high-frequency noise

                    b, a = butter(first_butter_par, second_butter_par)
                    fl = filtfilt(b, a, Ishort)

                    # The parameters for the peak finding
                    window_max_size = mfloor(window_max_size_rel *
                                             len(numpy.where(fl)[0]))
                    peaks = find_peaks_cwt(
                        fl, numpy.arange(window_min_size, window_max_size))

                    for i in range(len(peaks)):
                        peak = peaks[i]

                        if peaks[i - 1] < peak:
                            minindex = (peaks[i - 1] + peak) / 2
                        else:
                            minindex = 0

                        if i < len(peaks) - 1:
                            maxindex = (peaks[i + 1] + peak) / 2
                        else:
                            maxindex = stop - start - 1

                        if peak < maxindex and len(I0med[peak:maxindex]) > 1:
                            maxindex = I0med[peak:maxindex].argmin() + peak
                        if minindex < peak and len(
                                I0med[minindex:peak + 1]) > 1:
                            minindex = I0med[minindex:peak +
                                             1].argmin() + minindex
                        maxi = I0med[minindex:maxindex].argmax() + minindex

                        if datasmoothness(Ishort[minindex:maxindex],
                                          I0med[minindex:maxindex]) < 0.3:
                            if I0med[peak] >= I0med[maxindex] and I0med[
                                    peak] >= I0med[
                                        minindex] and maxindex - minindex > 10:

                                rg0 = Rgmed[maxi]
                                srg0 = Rg_Stdshort[maxi]

                                good = ((abs(Rgmed - rg0) < srg0))
                                good[maxindex] = False

                                if not (len(
                                        numpy.where(
                                            good[minindex:maxi] == False)[0])
                                        == 0):

                                    regionstart = numpy.where(
                                        good[minindex:maxi] ==
                                        False)[0].max() + minindex
                                else:
                                    regionstart = minindex
                                if not (len(
                                        numpy.where(
                                            good[maxi:maxindex] == False)[0])
                                        == 0):
                                    regionend = numpy.where(
                                        good[maxi:maxindex] ==
                                        False)[0].min() + maxi
                                else:
                                    regionend = maxindex

                                if regionend - regionstart > 5:
                                    good[:regionstart] = 0
                                    good[regionend:] = 0
                                    lg = label(good)
                                    lv = lg[maxi]
                                    region = numpy.where(lg == lv)[0] + start
                                    res.append(region)

                                    self.merge_frames.append(
                                        [region[0], region[-1]])
        return res
コード例 #11
0
import tkinter as tk
from tkinter import *
from tkinter import ttk
from tkinter import font as tkfont
from tkinter import messagebox
from math import floor as mfloor
from faker import Faker
from PIL import Image, ImageDraw
import pickle
from colour import Color
import colorsys
import random
saveName = 'sav1'
windowWidth = 800
windowHeight = 400
buttonWidth = mfloor((windowWidth / 7) / 7.5)
with open('sav1', 'rb') as f:
    data = pickle.load(f)
color0 = data['playercolors'][0]
color1 = data['playercolors'][1]
color2 = data['playercolors'][2]
color0hex = '#%02x%02x%02x' % color0
color1hex = '#%02x%02x%02x' % color1
color2hex = '#%02x%02x%02x' % color2


class SampleApp(tk.Tk):
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)
        self.title_font = tkfont.Font(family='Lato',
                                      size=18,
コード例 #12
0
async def time_new(message, client, arguments):

    if not arguments:
        letter = ":clock11: **| Servers time is " + str(
            datetime.fromtimestamp(mfloor(time())).strftime('%H:%M')) + "**"
        await client.send_message(message.channel, letter)
        return

    else:
        google = quote(str(arguments))
        query = "https://maps.googleapis.com/maps/api/geocode/json?address={}&key={}&language={}".format(
            google, google_api_key, "en")
        response = loads(rget(query).text)

        if response["status"] == "OK":

            # getting lat and lng
            lat = str(
                float("{0:.4f}".format(
                    response["results"][0]["geometry"]["location"]["lat"])))
            lng = str(
                float("{0:.4f}".format(
                    response["results"][0]["geometry"]["location"]["lng"])))

            # Getting time by place
            query = "https://maps.googleapis.com/maps/api/timezone/json?location=%s,%s&timestamp=%s&key=%s&language=%s" % (
                lat, lng, time(), google_api_key, "en")
            time_in_location = loads(rget(query).text)

            # Calculating time
            time_now = str(
                int(time() + time_in_location["rawOffset"] +
                    time_in_location["dstOffset"]))
            time_in_hour_format = datetime.fromtimestamp(
                int(time_now)).strftime('%H:%M')
            time_in_weekday = datetime.fromtimestamp(int(time_now)).weekday()

            # Setting weekday
            if time_in_weekday == 0:
                day_is = "Monday"
            elif time_in_weekday == 1:
                day_is = "Tuesday"
            elif time_in_weekday == 2:
                day_is = "Wednesday"
            elif time_in_weekday == 3:
                day_is = "Thursday"
            elif time_in_weekday == 4:
                day_is = "Friday"
            elif time_in_weekday == 5:
                day_is = "Saturday"
            elif time_in_weekday == 6:
                day_is = "Sunday"

            # Sending message
            adsasdadsfdas = ":clock11: **| Time in {} is {} and the day is {}**".format(
                str(response["results"][0]["formatted_address"]),
                time_in_hour_format, day_is)
            await client.send_message(message.channel, adsasdadsfdas)
            return

    send(1, "Time done!")
コード例 #13
0
ファイル: EDUtilsBioSaxs.py プロジェクト: kif/edna
    def analyse(self):
        # Note: This algorithm was tested with data acquired at BM29 in late 2012, early 2013
        # Changes in the acquisition protocol might require adaption of parameters

        # paramterers for finding ROIs:
        smoothing_degree = 9

        # parameters for smoothing for peak finding
        nyf = 0.5
        first_butter_par = 4
        second_butter_par = 0.1 / nyf

        # parameters for peak finding algorithm
        window_min_size = 1
        window_max_size_rel = 0.2  # to be multiplied by size of ROI

        Ismooth = medfilt(self.I0, smoothing_degree)
        lab = label(Ismooth)
        Rgsmooth = medfilt(self.Rg, smoothing_degree)
        res = []
        self.merge_frames = []

        for i in range(1, int(lab.max() + 1)):
            loc = (lab == i)
            c = loc.sum()
            # Only analyse peak regions of at leat 10 subsequent frames
            if c > 10:
                idx = numpy.where(loc)[0]
                start = idx[0]
                stop = idx[-1]
                Ishort = self.I0[start:stop]
                I0med = Ismooth[start:stop]

                Rgmed = Rgsmooth[start:stop]
                Rg_Stdshort = self.Rg_Stdev[start:stop]
#                 Rgshort = self.Rg[start:stop]
                # This is an attempt to remove "dirt" - long broad peaks with no real peeak structure, noise on short timescales
                # Test this with Ishort vs I0med
                if datasmoothness(Ishort, I0med) < 0.25:

                    # we smooth the data with a butterworth filter to remove high-frequency noise

                    b, a = butter(first_butter_par, second_butter_par)
                    # We should take care of the pading length to avoid errors
                    if 3 * max(len(a), len(b)) > len(Ishort):
                        fl = filtfilt(b, a, Ishort)
                    else:
                        fl = filtfilt(b, a, Ishort, padlen=Ishort.shape[0] - 2)

                    # The parameters for the peak finding
                    window_max_size = mfloor(window_max_size_rel * len(numpy.where(fl)[0]))
                    peaks = find_peaks_cwt(fl, numpy.arange(window_min_size, window_max_size))

                    for i in range(len(peaks)):
                        peak = peaks[i]

                        if peaks[i - 1] < peak:
                            minindex = (peaks[i - 1] + peak) / 2
                        else:
                            minindex = 0

                        if i < len(peaks) - 1:
                            maxindex = (peaks[i + 1] + peak) / 2
                        else:
                            maxindex = stop - start - 1

                        if peak < maxindex and len(I0med[peak:maxindex]) > 1:
                            maxindex = I0med[peak:maxindex].argmin() + peak
                        if (minindex < peak) and (len(I0med[minindex:peak + 1]) > 1):
                            minindex = I0med[minindex:peak + 1].argmin() + minindex
                        maxi = I0med[minindex:maxindex].argmax() + minindex

                        if datasmoothness(Ishort[minindex:maxindex], I0med[minindex:maxindex]) < 0.3:
                            if I0med[peak] >= I0med[maxindex] and I0med[peak] >= I0med[minindex] and maxindex - minindex > 10:

                                rg0 = Rgmed[maxi]
                                srg0 = max(Rg_Stdshort[maxi], 0.1)  # The error estimate for a single frame can be unreallistically small

                                good = ((abs(Rgmed - rg0) < srg0))
                                good[maxindex] = False

                                if not (len(numpy.where(good[minindex:maxi] == False)[0]) == 0):

                                    regionstart = numpy.where(good[minindex:maxi] == False)[0].max() + minindex
                                else:
                                    regionstart = minindex
                                if not (len(numpy.where(good[maxi:maxindex] == False)[0]) == 0):
                                    regionend = numpy.where(good[maxi:maxindex] == False)[0].min() + maxi
                                else:
                                    regionend = maxindex

                                if regionend - regionstart > 5:
                                    good[:regionstart] = 0
                                    good[regionend:] = 0
                                    lg = label(good)
                                    lv = lg[maxi]
                                    region = numpy.where(lg == lv)[0] + start
                                    res.append(region)

                                    self.merge_frames.append([region[0], region[-1]])
        return res
コード例 #14
0
ファイル: roulette.py プロジェクト: AudioVisuaali/audiobot
async def roulette(message, client, arguments):

    # Catching errors so you won't get tiemd out forever
    if 1:
    #try:

        #if not message.channel.id in ["404356322595962880"]:
        #    return
        if len(arguments) == 1:

            #VALUES
            min_points = ROULETTE_MIN_POINTS
            winrate = ROULETTE_WINRATE
            special_winrate = ROULETTE_SPECIAL_WINRATE
            rand_low = ROULETTE_RAND_LOW
            rand_high = ROULETTE_RAND_HIGH
            special_channels = ROULETTE_SPECIAL_CHANNELS

            # Variables
            multiplier_outcome_str = "" # DO NOT TOUCH
            multiplier_outcome_multiplier_str = "" # DO NOT TOUCH
            amount = arguments[0] # DO NOT TOUCH

            # Getting name
            try:
                name = message.author.nick
                if name is None:
                    name = message.author.name
            except:
                name = message.author.name

            # Getting the amount of points
            user_points = users_get_daily_points(message.author.id)[0]

            #Validating input and roulette amount
            if amount != "all":

                # all in
                all_in = False

                # Checking for k=1000 points
                if "k" in amount:
                    amount = float(arguments[0].lower().replace("k","")) * 1000

                #Checking if number
                try:
                    user_gamble = int(amount)
                except ValueError:
                    return

            # Assigning users all points for !roulette all
            else:
                user_gamble = user_points
                all_in = True

            # Checking if user gambled mreo than x aoumnt of points
            if user_gamble < min_points:
                await client.send_message(message.channel, "<@{}> **You have to gamble at least {} memes!**".format(message.author.id, min_points))
                return

            # Checking pointsif user_gamble > user_points   :
            if user_gamble > user_points:
                await client.send_message(message.channel, "<@{}> **You don't have enough memes to gamble, you need {} memes!**".format(message.author.id, user_gamble - user_points))
                return

            # Cpecial channels
            if message.channel.id in special_channels:
                if randint(1,100) > special_winrate:
                    winrate = special_winrate
                    # Creating multiplier and some other stuff
                    mvalue = float(randint(rand_low, rand_high) / 100)
                    moutcome = int(mfloor(user_gamble * mvalue - user_gamble))
                    multiplier_outcome_str = "**+" + str(moutcome) + "**"
                    multiplier_outcome_multiplier_str = "Multiplier " + str(mvalue)
                    info3 = str(mvalue)
                else:
                    info3 = ""
            else:
                info3 = ""

            info1 = ""
            info2 = ""

            # Win
            if randint(1,100) < winrate:

                # Calculations for message formation later on
                outcome_total = user_gamble # + multiplier TODO
                total_points = user_points + outcome_total

                # Adding points and logging event for user
                users_set_points_to_plus(user_gamble, message.author.id)
                #points_history_roulette_add(message.author.id, "", user_gamble, "win", all_in)

                # Determine afterfix
                if all_in:
                    win_afterfix = ":confetti_ball: :confetti_ball:"
                    info2 = "All in"
                else:
                    win_afterfix = ":confetti_ball:"

                # Creating message
                letter = "** :slot_machine:  | {}, you have won {}{} memes, you now have {} memes! {} {}** ".format(name, outcome_total, multiplier_outcome_str, total_points, win_afterfix, multiplier_outcome_multiplier_str)
                try:
                    win_str_plus = "+" + str(int(outcome_total)+int(moutcome))
                    plus = int(outcome_total)+int(moutcome)
                except:
                    win_str_plus = "+" + str(int(outcome_total))
                    plus = int(outcome_total)

                minus = 0
                info1 = "Win"
            # Lose
            else:
                info3 = ""
                # Calculations for message formation later on
                outcome_total = user_gamble # + multiplier disabled cause not fair LUL
                total_points = user_points - outcome_total

                # Adding points and logging event for user
                users_set_points_to_minus(user_gamble, message.author.id)
                #points_history_roulette_add(message.author.id, "", user_gamble, "lose", all_in)

                # Determine afterfix
                if all_in:
                    win_afterfix = "<:angery:280761870447673344>"
                    info2 = "All in"
                else:
                    win_afterfix = "<:feelsrageman:318490463323553795>"



                # Creating message
                letter = "** :slot_machine:  | {}, you have lost {} memes, you now have {} memes! {}** ".format(name, outcome_total, total_points, win_afterfix)
                win_str_plus = "-" + str(user_gamble)
                plus = 0
                minus = int(user_gamble)
                info1 = "Lose"

            points_stats_insert(message.server.id, message.author.id, 5, "Roulette", str(user_gamble), "", win_str_plus, "", info1, info2, info3, "", 0, plus, minus)

            # Sending message, checking if worth of excitement
            if user_gamble / user_points > 0.8:
                                                                    # TODO add expression system to config file
                msg = await client.send_message(message.channel, "**<:VenskerChamp:313049600984612865> Rolling **")
                await sleepS(4.0)
                await client.edit_message(msg, letter)
                return

            # if not high bet do this no excitement
            else:
                await client.send_message(message.channel, letter)
コード例 #15
0
def _floor(x):
    return int(mfloor(x))
コード例 #16
0
ファイル: transfer.py プロジェクト: AudioVisuaali/AudioBot-2
    async def main(self, bot, database, message, arguments):

        user = bot.database.user.get(message.author.id).points

        #!? give all points
        if arguments[1] == "all":
            arguments[1] == user

        try:
            amount = int(arguments[1])
        except ValueError:
            await bot.say(message.channel, "Invalid amount")
            return

        if user < amount:
            await bot.say(message.channel, "You don't have enough memes!")
            return

        # less than 10
        if amount < 10:
            await bot.say(message.channel, "transfer at least 10 memes!")
            return

        # Transferring to user instance
        user_getting = await bot.utils.get_user_instance(
            message.server, arguments[0])
        if user_getting is None:
            await bot.say(message.channel, "can't find user")
            return

        # checking if sending money toself
        if user_getting == message.author:
            await bot.say(message.channel, "Can't send money to yourself!")
            return

        letter = ":no_entry:** Olet siirtämässä __{}__ meemiä käyttäjälle {}!**\n\nTAX: **{}:money_with_wings: - 20% => {}:money_with_wings:**\nSinun meemisi: **{}:money_with_wings: -> {}:money_with_wings:**\n\n **Hyväksy** seuraavan 20 sekunnin aikana **kirjoittamalla: __PENIS__**".format(
            amount, user_getting.name, amount, mfloor(int(amount) * 80 / 100),
            user, str(int(user) - int(amount)))
        keepo = await bot.say(message.channel, letter)

        # Waiting for right response from user
        guess = await bot.wait_for_message(timeout=20.0,
                                           author=message.author,
                                           check=self.guess_check)

        # After time passes
        if guess is None:
            letter = ":no_entry_sign: **| Transaction cancelled!**"
            await bot.edit_message(keepo, letter)

        # After confirmed
        elif guess.content == "PENIS":
            # adding and removing points SOME NASTY MATH
            bot.database.user.points_alter(message.author.id, -amount)
            bot.database.user.points_alter(user_getting.id, amount)
            bot.database.server.tax_pot_alter(
                message.server.id, int(mfloor(int(amount) * 20 / 100)))

            # Sending message
            await bot.delete_message(keepo)
            await bot.say(message.channel,
                          ":white_check_mark: **| Siirto onnistui!**")
            bot.database.pointhistory.add(message.author.id, message.server.id,
                                          7, "Transfer", False, amount, "",
                                          "-" + str(amount), "",
                                          user_getting.name, "", "", "", 0, 0,
                                          int(amount))
            bot.database.pointhistory.add(user_getting.id, message.server.id,
                                          7, "Transfer", False, "", "",
                                          "+" + str(amount), "",
                                          message.author.name, "", "", "", 0,
                                          int(amount), 0)