Ejemplo n.º 1
0
def game_CRAPS():
    os.system('cls')
    print('''CRAPS赌博游戏。
        玩家第一次摇骰子如果摇出了7点或11点,玩家胜;
        玩家第一次如果摇出2点、3点或12点,庄家胜;
        其他点数玩家继续摇骰子,如果玩家摇出了7点,庄家胜;
        如果玩家摇出了第一次摇的点数,玩家胜;
        其他点数,玩家继续要骰子,直到分出胜负''')
    shu = 0
    ying = 0

    while True:
        print("—————————————————")
        print("赌博有害,不要赌博")
        peo = input("是否开始/继续?:(Y/N)").upper()

        if peo == "Y":
            one = random.randint(1, 6)
            two = random.randint(1, 6)
            first = one + two
            print("玩家摇出了%d,%d点数,共%d点" % (one, two, one + two))

            if first == 7 or first == 1:
                print("您赢了")
                ying += 1
            elif first in [2, 3, 12]:
                print("您输了")
                shu += 1
            else:
                while True:
                    one = random.randint(1, 6)
                    two = random.randint(1, 6)
                    zong = one + two
                    print("玩家摇出了%d,%d点数,共%d点" % (one, two, zong))

                    if zong == 7:
                        print("您输了")
                        shu += 1
                        break
                    elif zong == first:
                        print("您赢了")
                        ying += 1
                        break
        elif peo == "N":
            print("您本次游玩共计游玩%d次,输了%d次,赢了%d次" % (shu + ying, shu, ying))
            print("希望您玩得愉快,以后远离赌博😊")
            break
    input("按任意键并回车返回游戏菜单")
    view.game()
    print("————————————————————————————")
Ejemplo n.º 2
0
    def inner():

        global login_id
        while True:
            try:
                with open("{}.txt".format(login_id), "r") as filename:
                    count1 = filename.read()
                    filename.close()
            except FileNotFoundError:
                count1 = "100"
            finally:
                count = int(count1)
            print("---------")
            print("您的积分:{}".format(count))
            print("---------")
            fn()
            with open("{}.txt".format(login_id), "w") as filename:
                if win == 1:
                    count = count + 2
                    filename.write(str(count))
                elif win == 0:
                    count = count - 1
                    filename.write(str(count))
                else:
                    filename.write(str(count))
                filename.close()
            choice = input("继续/返回(Y/N):").upper()
            if choice == "Y":
                continue
            elif choice == "N":
                break
        return view.game()
Ejemplo n.º 3
0
def game_guess():
    os.system('cls')
    print("————————————————————————————")
    print("赵氏GAME欢迎您")
    print()
    shuzi = random.randint(1, 100)
    cishu = 0

    while True:
        cishu = cishu + 1
        nu = input("请输入100以内整数(Q退出):").upper()

        if nu.isdigit():
            guess_num = int(nu)

            if 1 <= guess_num <= 100:
                if guess_num > shuzi:
                    print("大了")
                elif guess_num < shuzi:
                    print("小了")
                elif guess_num == shuzi:
                    print("猜对了")
                    print("你一共猜了:" + str(cishu) + "次")
                    guess_choice = input("是否继续(Y/N)").upper()

                    if guess_choice == "y":
                        game_guess()
                    elif guess_choice == "N":
                        view.game()
            else:
                print("输入错误")
                continue
        elif nu == "Q":
            view.game()
        else:
            input("输入错误,按任意键重新输入")
Ejemplo n.º 4
0
def game():
    os.system('cls')
    print("————————————————————————————")
    print("赵氏GAME欢迎您")
    print()
    print("1.猜数字")
    print("2.CRAPS赌博游戏")
    print("3.石头剪刀布")
    print("*.敬请期待")
    print("0.返回首页")
    print("————————————————————————————")
    game_choice = input("请选择功能:")

    if game_choice == "1":
        return func.game_guess()
    elif game_choice == "2":
        return func.game_CRAPS()
    elif game_choice == "3":
        return func.game_stj()
    elif game_choice == "0":
        pass
    else:
        input("系统升级中,按任意键并回车重新输入")
    return view.game()
Ejemplo n.º 5
0
from car import HorizontalCar, VerticalCar
from coordinate import Coordinate
from grid import Grid
import view
'''
Project description here.
'''
# Game window size.
size = (700, 700)
# Set up game.
grid = Grid(10, 10)
car1 = HorizontalCar(grid, Coordinate(0, 0), 2, view.BLUE)
car2 = HorizontalCar(grid, Coordinate(3, 0), 3, view.GREEN)
car3 = VerticalCar(grid, Coordinate(5, 5), 2, view.RED)
grid.add_car(car1)
grid.add_car(car2)
grid.add_car(car3)
grid.add_exit(Coordinate(5, -1))

view.game(size, grid)
Ejemplo n.º 6
0
import view
from grid import Grid
'''
Game editor allows users to make their own traffic jam games,
test them out, make random boards, or save and load grids.
'''
# Game window size.
size = (700, 700)
# Set up game.
grid = Grid(5, 5)

view.game(size, grid, show_buttons=True)