简体   繁体   English

在线游戏的 Python 编码 - 比萨店选择了故事游戏。

[英]Python coding for online Game - Pizzeria chose story Game.

I am stayed in getting the right coding.我一直在获得正确的编码。 If you happen to run this code, please correct what you see fit.如果您碰巧运行此代码,请更正您认为合适的内容。 I have searched and there continues to be bugs here and there.我已经搜索过,这里和那里仍然存在错误。 Here is the game coding.这是游戏编码。 There may be some issues in the definition terms and I'm still learning the Python vocabulary to defined new items and am not finding right answers.定义术语可能存在一些问题,我仍在学习 Python 词汇来定义新项目,但没有找到正确的答案。 Here is the code that you can run and try.这是您可以运行并尝试的代码。 Thank you:谢谢:

import random
import time

def displayIntro():
    print("You are in a city. In front of you,")
    print("you see two restraunts. In one pizzeria, the service is friendly")
    print("and will share thier free pizza with you. The other pizzeria")
    print("is very unpredictable and will hire you to wash the dishes in the back quick.!")
    print()

def choosePizzeria():
    pizzeria=""
    while((pizzeria != "1") and (pizzeria != "2")):
        print("Which pizzeria will you go into? (1 or 2) ")
        pizzeria = input()

    return pizzeria

def checkPizzeria(level,(pizzeria != "1") or (pizzeria != "2")):
    print("You approach the pizzeria and see people hustling in and out quickly...")
    time.sleep(2)
    print("It really crowded with people waiting in line, playing arcade games and just having a good time dancing...")
    time.sleep(2)
    print("A little manager with a suit steps in in front of you! He quickly slips his arm behind his back...")
    print()
    time.sleep(2)

    friendlypizzeria = random.randint(1, 3)
    overworkPizzeria = friendlypizzeria + 1
    if overworkPizzeria > 3:
      overworkPizzeria -= 3

    if chosenPizzeria == str(friendlyPizzeria):
        print("Hand you a slip of paper for two free pizzas!")
    elif chosenPizzeria == str(overworkPizzeria):
          print("He hands you a slip of paper telling you to watch the dishes in the back for a while since you stared at him too long!")
    else:
          level += 1
    if level < 3:
        print("You quickly hid behind some customes and head out to 3 more pizzerias")
    else:
        print("Congratulations you win two free pizzas and")
        print("you get to go to the manager's weekend party!!!! ")

    return level

playAgain = "yes"
while playAgain == "yes" or playAgain == "y":

    displayIntro()
    level = 0

    pizzeriaNumber = choosePizzeria()

    level = checkPizzeria(level,pizzeriaNumber)

    if level == 1:
        pizzeriaNumber = choosePizzeria()
        level = checkPizzeria(level,pizzeriaNumber)

    if level == 2:
        pizzeriaNumber = choosePizzeria()
        level = checkPizzeria(level,pizzeriaNumber)


    print('Do you want to play again? (yes or no)')
    playAgain = input()

Thank you.谢谢你。

Mostly Syntax errors, I would suggest reading some Python documentation.主要是语法错误,我建议阅读一些 Python 文档。 Especially in regards to Types, and Comparison Operators.特别是在类型和比较运算符方面。 But below will run;但下面会运行;

import random
import time

def displayIntro():
    print("You are in a city. In front of you,")
    print("you see two restraunts. In one pizzeria, the service is friendly")
    print("and will share thier free pizza with you. The other pizzeria")
    print("is very unpredictable and will hire you to wash the dishes in the back quick.!")
    print()

def choosePizzeria():
    pizzeria=""
    while((pizzeria != 1) and (pizzeria != 2)):
        print("Which pizzeria will you go into? (1 or 2) ")
        pizzeria = input()

    return pizzeria

def checkPizzeria(level, pizzariaNumber):
    print("You approach the pizzeria and see people hustling in and out quickly...")
    time.sleep(2)
    print("It really crowded with people waiting in line, playing arcade games and just having a good time dancing...")
    time.sleep(2)
    print("A little manager with a suit steps in in front of you! He quickly slips his arm behind his back...")
    print()
    time.sleep(2)

    chosenPizzeria = pizzariaNumber
    friendlypizzeria = random.randint(1, 3)
    overworkPizzeria = friendlypizzeria + 1
    if overworkPizzeria > 3:
      overworkPizzeria -= 3

    if chosenPizzeria == friendlypizzeria:
        print("Hand you a slip of paper for two free pizzas!")
    elif chosenPizzeria == overworkPizzeria:
          print("He hands you a slip of paper telling you to watch the dishes in the back for a while since you stared at him too long!")
    else:
          level += 1
    if level < 3:
        print("You quickly hid behind some customes and head out to 3 more pizzerias")
    else:
        print("Congratulations you win two free pizzas and")
        print("you get to go to the manager's weekend party!!!! ")

    return level



playAgain = "yes"
while playAgain == "yes" or playAgain == "y":

    displayIntro()
    level = 0

    pizzeriaNumber = choosePizzeria()

    level = checkPizzeria(level,pizzeriaNumber)

    if level == 1:
        pizzeriaNumber = choosePizzeria()
        level = checkPizzeria(level,pizzeriaNumber)

    if level == 2:
        pizzeriaNumber = choosePizzeria()
        level = checkPizzeria(level,pizzeriaNumber)


    print('Do you want to play again? (yes or no)')
    playAgain = raw_input()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM