Example #1
0
def library():
    print(term_io.delete.whole_screen)
    os.system('sed -n 1,26p BookSkin')
    term_io.press_any_key_to_continue()
    os.system('sed -n 27,52p BookSkin')
    print("\n")
    term_io.press_any_key_to_continue()
Example #2
0
def minigame(user):
    while True:
        print(term_io.delete.whole_screen + term_io.fgcolor.black + term_io.bgcolor.yellow +
              "  Mini Game Room  " + term_io.fgcolor.reset)
        print("Winning a minigame will earn you points. But sometimes, losing it will also takes a few points from you.\n")
        action = term_io.select_menu([
            "  Guess a Number  ",
            "   Connect Five   ",
            "  Exit the Room   "])
        points_gain = 0
        if action == 2:
            return user
        elif action == 0:
            print(
                "\n\n\nYou will gain 50 points if winning the game, but lose 5 points if failed.")
            if guess_a_number():
                print(term_io.fgcolor.green +
                      "You gained 50 points." + term_io.fgcolor.reset)
                user.points += 50
            else:
                print(term_io.fgcolor.red +
                      "You lost 5 points." + term_io.fgcolor.reset)
                user.points -= 5
                if user.points < 0:
                    user.points = 0
            user.save()
            term_io.press_any_key_to_continue()
        elif action == 1:
            points_gain = run_connect_five()
            if points_gain > 0:
                print(term_io.fgcolor.green + "You got %d points!" %
                      points_gain + term_io.fgcolor.reset)
                user.points += points_gain
                user.save()
                term_io.press_any_key_to_continue()
Example #3
0
def show_room():
    user_account = account("init", "get rid of error msg.")
    emoji = ["-", "^_^", "T-T", "@_@", "@.@", "*-*", ":P"]
    print("You entered the show room. There is a list of users on the wall.")
    a = os.popen(
        'find vending_accounts/ -name "*.p" |  grep -oP "(?<=vending_accounts/)\w+"'
    ).read().split("\n")[:-1]
    for user in a:
        user_account = load_account(user)
        print_inventory(emoji,
                        user_account.emoji_you_have,
                        title=user + "'s emoji")
    term_io.press_any_key_to_continue()
Example #4
0
def status_update(player, HP, message, status, display, player_name=""):
    if player == 1:
        display.update_t1_HP(HP)
        display.update_t1_hit(message, status)
    elif player == 2:
        display.update_t2_HP(HP)
        display.update_t2_hit(message, status)
    if HP <= 0:
        if player == 1:
            display.update_t1_hit(print_lose(player_name), 3)
        if player == 2:
            display.update_t2_hit(print_lose(player_name), 3)
        ti.press_any_key_to_continue()
        display.close()
Example #5
0
def run_connect_five():
    print("It's a game to get five pieces connected into a line first, either horizontally, vertically or diagonally.")
    print("Your pieces are 'O'. Type coordinate with row + colume. For example H row and K col, key in hk.")
    print("Choose a difficulty level. The higher level you chose, the longer time computer would use.")
    reward = [150, 250, 450]
    action = term_io.select_menu([
        "  Easy  ",
        "  Hard  ",
        "  Guru  ",
        "  Exit  "])
    if action == 3:
        return 0
    else:
        if connect_five.gamemain(action + 1) == 0:
            print("No reward for losing a game.")
            term_io.press_any_key_to_continue()
            return 0
        else:
            return reward[action]
Example #6
0
def my_inventory(user, emoji):
    print("\nYou have %d points." % user.points)
    print_inventory(emoji, user.emoji_you_have)
    term_io.press_any_key_to_continue()
Example #7
0
def training_room(user):
    print(term_io.delete.whole_screen + term_io.bgcolor.yellow +
          term_io.fgcolor.black +
          "               The Ancient Tower               " +
          term_io.fgcolor.reset)
    print(
        "You entered an ancient tower. You will meet spirit fighters with their emojis in the tower. You need beat them to move the every next level. You will receive a blessing at each five levels you clear. But be careful that if you lose a battle, you will lose your emojis in the team. So choose the team wisely."
    )
    level = 1
    while True:
        if level != 1:
            if (level - 1) % 5 == 0:
                print(
                    term_io.fgcolor.green +
                    "You come to a blessing spring. After you drink some water in the spring, you feel refreshed."
                )
                print("(Technically, you received %d points.)" %
                      (300 * int(level / 5)) + term_io.fgcolor.reset)
                user.points += 300 * int(level / 5)
            else:
                print(term_io.fgcolor.green + "You gained 10 points." +
                      term_io.fgcolor.reset)
                user.points += 10
            user.save()
        trainer_name = name_gen()
        trainer_team = [randint(1, 6), randint(1, 6), randint(1, 6)]
        while True:
            print(term_io.bgcolor.blue +
                  "\nYou come to the level %d of the tower." % level +
                  term_io.bgcolor.reset)
            print(
                "The tower was built before history. It grows tall into the clouds. No one knows where it leads to."
            )
            print("The trainer in this level is %s." % trainer_name)
            team.print_team(trainer_team)
            print("\nNow pick your team to fight against %s." % trainer_name)
            player_team = team.pick_team(user)
            if len(player_team) == 3:
                print("%s's team:" % trainer_name)
                team.print_team(trainer_team)
                print("Your team:")
                team.print_team(player_team)
                print(
                    "Start to fight? (Remember, if you press F key during the battle, it's some chance to run away from it."
                )
                if term_io.y_or_n():
                    winner = fight_start(user.username, trainer_name,
                                         team.cal_att(player_team),
                                         team.cal_att(trainer_team))
                    if winner == 2:
                        print(
                            "You can't move to the next level, and have been sent back the to entance."
                        )
                        for team_member in player_team:
                            user.emoji_you_have[team_member] -= 1
                            user.save()
                        term_io.press_any_key_to_continue()
                        return user
                    elif winner == 0:
                        print(
                            "You got out of the tower and looked back. There is no one running after you."
                        )
                        term_io.press_any_key_to_continue()
                        return user
                    else:
                        level += 1
                        break
            else:
                print("Do you want to leave the tower?")
                if term_io.y_or_n():
                    return user
Example #8
0
import curses
import term_io
import time

stdscr = curses.initscr()
stdscr.addstr(0, 0, "RED ALERT!")
stdscr.refresh()

term_io.press_any_key_to_continue()

begin_x = 20
begin_y = 7
height = 20
width = 40
win = curses.newwin(height, width, begin_y, begin_x)
win.scrollok(True)
win.addstr("test")
win.addstr("2222222222222222222")
win.refresh()
for _ in range(100):
    win.addstr("sdlfkajsda;laskdfj;alskdjfa;sldkjfa;sldkfj" + "\n")
    win.refresh()
    time.sleep(0.3)

term_io.press_any_key_to_continue()

curses.endwin()