Exemplo n.º 1
0
#!/usr/bin/env python
from tronner import App, command
from tronner.color import *

app = App()


@app.event("NEW_ROUND")
def new_round():
    colors = []
    colors.append(colorize("Blue", BLUE))
    colors.append(colorize("Red", RED))
    colors.append(colorize("Green", GREEN))
    colors.append(colorize("Yellow", YELLOW))
    colors.append(colorize("Cyan", CYAN))
    colors.append(colorize("White", WHITE))
    colors.append(colorize("Reset", RESET))
    colors.append(colorize("Pink", PINK))
    colors.append(colorize("Gray", GRAY))
    colors.append(colorize("Lime", LIME))

    command.say(", ".join(colors))
    command.say(gradient("This goes from cyan to green.", CYAN, GREEN))
    command.say(gradient("This from white to blue.", WHITE, BLUE))
    command.say(gradient("And this to red from yellow.", YELLOW, RED))

    command.say(random_color_text("This should be colored quite randomly.", False))


if __name__ == "__main__":
    app.run()
Exemplo n.º 2
0
from tronner import App, Players, Player

app = App()
app.players = Players()

@app.event('PLAYER_ENTERED <name> <ip> <screen_name>')
def player_entered(name, ip, screen_name):
    p = Player(name, ip, screen_name)
    app.players.append(p)

@app.event('PLAYER_RENAMED <old_name> <new_name>')
def player_renamed(old_name, new_name):
    p = app.players.get(old_name)
    if p: p.name = new_name

@app.event('PLAYER_LEFT <name>')
def player_left(name):
    app.players.safe_remove(name)

if __name__ == '__main__':
    app.run()
Exemplo n.º 3
0
#!/usr/bin/env python
from tronner import App
from tronner import command

app = App()

command.command('INTERCEPT_COMMANDS /stats')

@app.event('COMMAND <cmd> <name> <args>')
def command(cmd, name, args):
    if cmd == '/stats':
        command.say("%s used command: %s %s" % (name, cmd, args))


if __name__ == '__main__':
    app.run(debug=True)
Exemplo n.º 4
0
#!/usr/bin/env python
from tronner import App, command, color
from tronner import Players, Player

app = App()
app.players = Players()

@app.event('PLAYER_ENTERED <name> <ip> <screen_name>')
def player_entered(name, ip, screen_name):
    p = Player(name, ip, screen_name)
    app.players.append(p)

@app.event('PLAYER_RENAMED <old_name> <new_name> <ip> <screen_name>')
def player_renamed(old_name, new_name, ip, screen_name):
    p = app.players.get(old_name)
    if p:
        p.name = new_name
        p.screen_name = screen_name

@app.event('PLAYER_LEFT <name> <ip>')
def player_left(name, ip):
    app.players.safe_remove(name)

@app.event('DEATH_FRAG <killed> <killer>')
def death_frag(killed, killer):
    app.players.get(killed).stats.deaths += 1
    app.players.get(killer).stats.kills += 1

@app.event('DEATH_SUICIDE <name>')
def death_suicide(name):
    app.players.get(name).stats.suicides += 1