aboutsummaryrefslogtreecommitdiffstats
path: root/functest/utils/functest_vacation.py
blob: c2e40b07243f98162d97631168cdbea81811df95 (plain)
1
2
3
4
5
6
7
8

@media only all and (prefers-color-scheme: dark) {
.highlight .hll { background-color: #49483e }
.highlight .c { color: #75715e } /* Comment */
.highlight .err { color: #960050; background-color: #1e0010 } /* Error */
.highlight .k { color: #66d9ef } /* Keyword */
.highlight .l { color: #ae81ff } /* Literal */
.highlight .n { color: #f8f8f2 } /* Name */
.highlight .o { color: #f92672 } /* Operator */
.highlight .p { color: #f8f8f2 } /* Punctuation */
.highlight .ch { color: #75715e } /* Comment.Hashbang */
.highlight .cm { color: #75715e } /* Comment.Multiline */
.highlight .cp { color: #75715e } /* Comment.Preproc */
.highlight .cpf { color: #75715e } /* Comment.PreprocFile */
.highlight .c1 { color: #75715e } /* Comment.Single */
.highlight .cs { color: #75715e } /* Comment.Special */
.highlight .gd { color: #f92672 } /* Generic.Deleted */
.highlight .ge { font-style: italic } /* Generic.Emph */
.highlight .gi { color: #a6e22e } /* Generic.Inserted */
.highlight .gs { font-weight: bold } /* Generic.Strong */
.highlight .gu { color: #75715e } /* Generic.Subheading */
.highlight .kc { color: #66d9ef } /* Keyword.Constant */
.highlight .kd { color: #66d9ef } /* Keyword.Declaration */
.highlight .kn { color: #f92672 } /* Keyword.Namespace */
.highlight .kp { color: #66d9ef } /* Keyword.Pseudo */
.highlight .kr { color: #66d9ef } /* Keyword.Reserved */
.highlight .kt { color: #66d9ef } /* Keyw
from os import environ
from curses import initscr, curs_set, newwin, endwin
from curses import KEY_RIGHT, KEY_LEFT, KEY_DOWN, KEY_UP
from random import randrange


def main():
    environ["TERM"] = 'Eterm'
    initscr()
    curs_set(0)
    try:
        win = newwin(16, 60, 0, 0)
        win.keypad(True)
        win.nodelay(True)
        win.border('|', '|', '-', '-', '+', '+', '+', '+')
        win.addch(4, 44, '@')
        win.addstr(0, 5, ' Eat all the OPNFV bugs by FunTest! ')
        win.addstr(15, 7, ' Left,Right,Up,Down: move; other keys: quit ')
        snake = [[20, 7], [19, 7], [18, 7], [17, 7],
                 [16, 7], [15, 7], [14, 7], [13, 7]]
        key = KEY_RIGHT
        body = '~FUNTEST'
        ind = 0
        while key != 27:
            win.addstr(0, 44, ' Score: ' + str(len(snake) - len(body)) + ' ')
            win.timeout(140 - 2 * len(snake))
            getkey = win.getch()
            key = key if getkey == -1 else getkey
            snake.insert(
                0, [snake[0][0] + (key == KEY_RIGHT and 1 or
                                   key == KEY_LEFT and -1),
                    snake[0][1] + (key == KEY_DOWN and 1 or
                                   key == KEY_UP and -1)])
            win.addch(snake[len(snake) - 1][1], snake[len(snake) - 1][0], ' ')
            if win.inch(snake[0][1], snake[0][0]) & 255 == 32:
                snake.pop()
            elif win.inch(snake[0][1], snake[0][0]) & 255 == ord('@'):
                c = [n for n in [[randrange(1, 58, 1), randrange(1, 14, 1)]
                     for x in range(len(snake))] if n not in snake]
                win.addch(c == [] and 4 or c[0][1],
                          c == [] and 44 or c[0][0], '@')
            else:
                break
            ind += 1
            win.addch(snake[0][1], snake[0][0], body[ind % len(body)])
    finally:
        endwin()

    print '\nSnake.PY-26lines by Kris Cieslak (defaultset.blogspot.com).'
    print 'OPNFV adaptation by Functest dream team.'
    score = str(len(snake) - len(body) - 1)
    print ('Thanks for playing, your score: %s.' % score)
    print 'Find and fix more bugs in your real OPNFV setup!\n'