Beispiel #1
0
    def prep(self, duration, rest=5, read_delay=5):
        """Set the exercise durations.  Arguments:
        duration - time to exercise for in seconds
        rest - time afterwards to allow the athlete to rest
        read_delay - time before to read and understand the instructions

        Throws: Exception for invalid input
        """
        if duration < 0:
            raise exceptions.ParseError(
                "Not a time traveller: Can't exercise for {0} second(s)".
                format(repr(duration)))
        if rest < 0:
            raise exceptions.ParseError(
                "Not a time traveller: Can't rest for {0} second(s)".format(
                    repr(rest)))
        if read_delay < 0:
            raise exceptions.ParseError(
                "Not a time traveller: Can't let the user read for {0} second(s)"
                .format(repr(read_delay)))
        self.reading = countdown.Countdown(read_delay, self.session_start)
        self.countdown = countdown.Countdown(duration, self.finish, self.tick)
        self.duration = duration
        self.rest = rest
        self.read_delay = read_delay
Beispiel #2
0
    def __init__(self, inMap, inChars, team):
        super(Model, self).__init__()
        self.team = team
        self.map = inMap
        self.zoomVal = 1.0
        self.fimbulvetrPos = 0
        self.fimbulvetrTick = boundint.BoundInt(0, self.map.fimbulvetrSpeed, 0,
                                                True)
        self.fimbulvetrDelayTick = self.map.fimbulvetrDelay
        self.fimbulvetrSpreadSpeed = self.map.fimbulvetrSpreadSpeed

        self.characters = inChars
        self.charactersInTeams = [[], []]
        self.rezSparks = []
        self.lockCircles = []
        for c in self.characters:
            self.charactersInTeams[c.team].append(c)
        self.mapRect = None
        self.currHighlighted = None
        self.currSelected = None
        self.drawOrigMap()
        self.mousePos = pygame.mouse.get_pos()
        self.createRegions()
        self.placeChars()
        self.placeStructures()
        self.buildInterface()
        self.checkForStructureOwnership(True)

        self.pendingBattle = None
        self.pause = [False, False]
        self.keys = [False, False, False, False, False, False]
        self.currentFrameOrder = None
        self.countdown = countdown.Countdown(MAP_COUNTDOWN_LENGTH)

        if SHOW_TRIGGER_AREA:
            self.setTriggerAreas()

        self.encounterPause = -1
        self.encounterPauseTick = 0

        self.charBarSideRight = True

        self.setCountdown()

        self.initialCount = 5

        for c in self.characters:
            self.checkTerrain(c)
            self.checkTerritory(c)
Beispiel #3
0
def Waiting():
    for steamID in var.WaitingQueue:
        player = var.WaitingQueue[steamID]
        var.Players[steamID] = player

    var.WaitingQueue.clear()

    for steamID in var.Players:
        player = var.Players[steamID]
        var.Bank.GiveMoney(steamID, -player.Bet)

    Say(("Blackjack is starting in 30 seconds.\n" + \
    "Join with {0}blackjack [bet amount] or {0}bj [bet amount].\n" + \
    "Change your bet with 'bet [amount]'.")
    .format(SteamNerd.CommandChar))

    var.Countdown = countdown.Countdown(
        30, 3, lambda: SetState(BlackjackStates.Dealing), Say)
    var.Countdown.start()
Beispiel #4
0
# When in eternal lines to time jenn grow’st:
#    So long as men can breathe or eyes can see,
#    So long lives this, and this gives life to jenn.""")
@bot.command(name="daniel",help="gently persuade Daniel to return to us")
async def daniel(ctx):
    await ctx.send("""@panDANIELlo:rainbow: whence shall we hear your joyful voice again
as the flowers sweetly bloom in the meadow
and children frolic to and fro
lest we forget that gay summer's day
perched on a porcelain throne""")
@bot.command(name="mute",help="server mute yourself")
@commands.has_permissions(administrator=True)
async def mute(ctx):
    await ctx.author.edit(mute=True)
@bot.command(name="begone",help="Stop the bot")
@commands.has_permissions(administrator=True)
async def begone(ctx):
    for c in bot.cogs:
        cog=bot.get_cog(c)
        if isinstance(cog,jukebox.Jukebox):
            await cog.graceful_stop()
    await ctx.send("bye!")
    await bot.logout()
bot.add_cog(slots.Slots(bot))
bot.add_cog(economy.Economy(bot))
bot.add_cog(countdown.Countdown(bot))
bot.add_cog(hangman.Hangman(bot))
bot.add_cog(dib.Games(bot))
bot.add_cog(jukebox.Jukebox(bot))
bot.add_cog(shop.Shop(bot))
bot.run(token)
Beispiel #5
0
dataf = pickle.load(f)
print dataf
dataf = pickle.load(f)
print dataf

#从string中恢复
datas = pickle.loads(s)
print datas

import math
print pickle.dumps(math.cos)
print

import time
import countdown
c = countdown.Countdown(30)

time.sleep(6)
print
f = open('cstate.p', 'wb')
pickle.dump(c, f)
f.close()
print
f = open('cstate.p', 'rb')
pickle.load(f)
time.sleep(6)




s = pickle.dumps(data)
print(s)

# restore from a file
f = open('somefile', 'rb')
data = pickle.load(f)
# print(data)
# restore from a string
data = pickle.loads(s)

# pickle module

f = open('hello.txt', 'wb')
pickle.dump([1, 2, 3, 4], f)
pickle.dump('hello', f)
pickle.dump({'apple', 'pear', 'banana'}, f)
f.close()

# f = open('hello.txt', 'rb')
# print(pickle.load(f))
# print(pickle.load(f))
# print(pickle.load(f))

import countdown

c = countdown.Countdown(5)
print(c.run())
f = open('cstate.p', 'wb')
pickle.dumb(c, f)
f.close()
Beispiel #7
0
import PySimpleGUI as sg

import countdown as cd

# creating the gui
layout = [[sg.Text('Countdown in seconds:'), sg.Input(key='INPUT_SECONDS')],
          [sg.Button('Start'), sg.Button('Reset')],
          [sg.Text('', size=(20, 1), key='COUNTDOWN')]]

window = sg.Window('Simple Countdown', layout)

# init countdown object
timer = cd.Countdown()

while True:  # Event Loop
    #print timer
    event, values = window.Read(timeout=100) # the timeout=100 option makes sure that the countdown gets regulary updated
    countdown_string = "Seconds left: {:.2f}".format(timer.getTimeLeft()) # format the cryptic time left to pretty string
    window['COUNTDOWN'].Update(countdown_string) # put into gui!

    if event is None or event == 'Exit':
        break

    elif event == 'Reset':
        timer.reset()

    elif event == 'Start':
        # get the seconds from the input timer
        seconds = int(values['INPUT_SECONDS'])
        timer.start(seconds) # lets go counting
Beispiel #8
0
print(data)


# Discussion

f = open('somedata', 'wb')
pickle.dump([1,2,3], f)
pickle.dump('hello', f)
pickle.dump({'Apple', 'Pear', 'Banana'}, f)
f.close()
f = open('somedata', 'rb')
print(pickle.load(f))
print(pickle.load(f))
print(pickle.load(f))

import math
pickle.dumps(math.cos)


import countdown
c = countdown.Countdown(10)

f = open('cstate', 'wb')
import pickle
pickle.dump(c,f)
f.close()

f = open('cstate', 'rb')
pickle.load(f)