コード例 #1
0
def acUpdate(delta_t):
    global last_calculated, last_posted
    global spinner_calculation_interval, spinner_posting_interval
    global label_names, label_track_progress, label_penalties, label_last_message
    global turn_gen, penalties

    CALCULATION_INTERVAL = ac.getValue(spinner_calculation_interval) / 1000
    POSTING_INTERVAL = ac.getValue(spinner_posting_interval) / 1000

    if (time.clock() - last_calculated) > CALCULATION_INTERVAL:
        last_calculated = time.clock()

        progresses = get_progresses()
        penalties = calculate_penalties(progresses)

        ac.setText(
            label_track_progress, "Track progresses: {}".format(
                [round(float(i), 2) for i in progresses]))
        ac.setText(
            label_penalties, "Penalty percentages: {}".format(
                [round(float(i), 2) for i in penalties]))

    if (time.clock() - last_posted) > POSTING_INTERVAL:
        p_type, target = next(turn_gen)

        if ac.isConnected(target):
            last_posted = time.clock()
            msg = create_msg(p_type, target, penalties)

            ac.sendChatMessage(msg)
            ac.setText(label_last_message,
                       "Last message posted: {}".format(msg))
コード例 #2
0
ファイル: InRaceChat.py プロジェクト: nosnickid/inracechat
 def onValidateInput(self, string):
     text = ac.getText(self.textInput)
     ac.setText(self.textInput, "")
     ac.setFocus(self.textInput, 1)
     if len(text) > 0:
         if ac.sendChatMessage(text) == -1:
             self.delayedChat = text
コード例 #3
0
def acMain(ac_version):
    global appWindow, last_calculated, last_posted, turn_gen

    appWindow = ac.newApp(appName)
    ac.setTitle(appWindow, appName)
    ac.setSize(appWindow, WIDTH, HEIGHT)

    last_calculated = time.clock()
    last_posted = time.clock()

    create_ui_components()

    ac.sendChatMessage("/admin {}".format(ADMIN_PW))

    turn_gen = msg_turn_generator(NCARS)

    return appName
コード例 #4
0
ファイル: nCountdown.py プロジェクト: nuggs/nCountdown
def updateCountdown(count):
    global countdown

    if count == 5:
        countdown = 4
        ac.sendChatMessage('Get ready...')
    elif count == 4:
        countdown = 3
        ac.sendChatMessage('3')
    elif count == 3:
        countdown = 2
        ac.sendChatMessage('2')
    elif count == 2:
        countdown = 1
        ac.sendChatMessage('1')
    elif count == 1:
        countdown = 0
        ac.sendChatMessage('GO!')
    else:
        countdown = 0
コード例 #5
0
def send_chat_message(drv, lap):
    """Sends message to chat to indicate that driver completed joker, also log to py_log"""
    ac.sendChatMessage(" | " + drv + " completed joker on lap " + str(lap + 1))
    ac.log("[JOKER CHECK] " + drv + " completed joker on lap " + str(lap + 1))
コード例 #6
0
ファイル: nChat.py プロジェクト: nuggs/nChat
def onValidateListener(string):
    global textInput
    text = ac.getText(textInput)
    ac.setText(textInput, '')
    ac.setFocus(textInput, 1)
    ac.sendChatMessage(text)