Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何修复python上的分支/故事制作? sceneDict={} 布告[乞讨]={ “分支”:错误 “SceneText”:“走向那棵被挖空的树的入口,你会发现\ 注意泥土通道两侧的一些大头骨以及其他\ 大骨头,看起来不像你以前见过的任何东西。”, “NextScene”:“进入” } 情景指令[“进入”={ “分支”:没错, “SceneText”:“你来到洞穴入口,在检查它时,你注意到一些\ 从入口顶部滴下的液体,你手里抓着一小部分,这是\ 红色,有着血的一致性。突然一声雷鸣般的吼声在你身后响起,一声巨响\ 巨魔出现了!“, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“跑进洞穴躲避巨魔”, “NextScene”:“Cave”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“尝试在巨魔腿之间逃跑”, “NextScene”:“Chase”}, {“ChoiceNumber”:“3.”, “选择文字”:“拔出你的剑,试图与巨魔作战” “NextScene”:“战斗”} ] } 场景指令[“战斗”]={ “分支”:假, “SceneText”:“当你伸手从背后夺剑时,巨魔将手臂伸向目标\ 在一次横扫运动中,你撞到了一棵树上,不幸地结束了你的生命。”, “来世”:“来世” } 场景法令[“来世”]={ “分支”:没错, “SceneText”:“你感觉到阳光照在脸上,当你睁开眼睛时,前方有两条路\ 此外,在两个箭头标志上方都有一个标志“这很奇怪,我可能已经死了”\ 有一个牌子上写着“你搞砸了,它发生了,但再试一次”这两条路都通向另外两个选择\ 在你做出这三个选择中最糟糕的一个之前, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“跑进洞穴躲避巨魔”, “NextScene”:“Cave”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“尝试在巨魔腿之间逃跑”, “NextScene”:“Chase”} ] } 场景指令[“追逐”]={ “分支”:假, “SceneText”:“你跪在巨魔双腿之间滑翔,巨大的拳头从后面砸下来\ 你,你站起来,开始跑下山向你的村庄跑去,听到它雷鸣般的脚步声\ 在后面。你们镇上的人听到了喧闹声,朝大门走去,看到你们被追赶,他们都走了\ 开始为你加油,让你继续前进!”, “NextScene”:“决定” } 情景指令[“决定”]={ “分支”:没错, “SceneText”:“你离你的村庄大约100米远,但你记得有一条河通向村庄\ 在大门的右边,你很可能会把巨魔带到那边,让它撞过桥\ 跳进水里,或者你可以试试警卫关上大门的速度来阻挡巨魔。”, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“继续前往村庄”, “NextScene”:“村庄”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“奔向水面”, “NextScene”:“Bridge”} ] } 场景法令[“村庄”]={ “分支”:假, “SceneText”:“你尽可能快地向村庄跑去,巨魔克利林正在逼近你。”\ 当你跑的时候,你叫警卫开始关上大门,当你跑的时候,大门开始关上\ 靠近它,你迅速滑过最后一个剩余的开口,门砰地关上,接着是一声巨响\ “砰!”巨魔把头撞进大门。当你活着回来时,全村人都欢呼起来, } 情景指令[“桥”]={ “分支”:假, “SceneText”:“当村民们欢呼时,他们开始质疑你在干什么?!你改变了你的道路\ 然后向桥走去。几秒钟后,你开始在正在小溪边的木桥上奔跑\ 真的在发抖。突然你听到一声咔嗒的响声,因为底部发出声音,你抓住了桥的一侧\ 当你听到巨大的水花飞溅时,桥会在你脚边脱落,只留下两边可以抓住\ 巨魔飘向远方。”, } 场景指令[“洞穴”]={ “分支”:没错, “SceneText”:“你向前跑进洞穴,把一些血滑入洞穴深处。在你身后\ 巨魔就要来了,但是你听到了水花飞溅进洞穴的声音。”, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“向喷溅处深入洞穴”, “NextScene”:“Jump”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“站在巨魔面前”, “NextScene”:“学习”} ] } 情景指令[“跳跃”]={ “分支”:假, “SceneText”:“你朝悬崖的尽头跑去,悬崖边上有一个小瀑布\ 你听到巨魔逼近你,但是下降是可以控制的,你后退一步,为荣耀而跳跃!你\ 随着水花落地,巨魔坐在顶端,怒吼着你逃走了,你成功了。现在去找他\ 回家的路……“, } 情景指令[“学习”]={ “分支”:假, “SceneText”:“你向后伸手从背后夺剑,但巨魔一个快速动作就将你击碎\ 把你变成肉糜,很不幸你听到一个闪闪发光的声音,你就回来了\ 再次踏上通往山洞的道路,仿佛上帝给了你第二次机会或其他什么。”, “NextScene”:“进入” } currentScene=“Begging” 而当前场景!=“”: 场景数据=场景指令[当前场景] 打印(sceneData[“SceneText”]) 打印() 如果场景数据[“分支”]: 对于sceneData[“选项”]中的选项: 打印(选项[“ChoiceNumber”]+选项[“ChoiceText”]) 打印() 回答=输入(“>”) 打印() 答案=int(答案)-1 如果while循环中的答案_Python_Input - Fatal编程技术网

如何修复python上的分支/故事制作? sceneDict={} 布告[乞讨]={ “分支”:错误 “SceneText”:“走向那棵被挖空的树的入口,你会发现\ 注意泥土通道两侧的一些大头骨以及其他\ 大骨头,看起来不像你以前见过的任何东西。”, “NextScene”:“进入” } 情景指令[“进入”={ “分支”:没错, “SceneText”:“你来到洞穴入口,在检查它时,你注意到一些\ 从入口顶部滴下的液体,你手里抓着一小部分,这是\ 红色,有着血的一致性。突然一声雷鸣般的吼声在你身后响起,一声巨响\ 巨魔出现了!“, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“跑进洞穴躲避巨魔”, “NextScene”:“Cave”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“尝试在巨魔腿之间逃跑”, “NextScene”:“Chase”}, {“ChoiceNumber”:“3.”, “选择文字”:“拔出你的剑,试图与巨魔作战” “NextScene”:“战斗”} ] } 场景指令[“战斗”]={ “分支”:假, “SceneText”:“当你伸手从背后夺剑时,巨魔将手臂伸向目标\ 在一次横扫运动中,你撞到了一棵树上,不幸地结束了你的生命。”, “来世”:“来世” } 场景法令[“来世”]={ “分支”:没错, “SceneText”:“你感觉到阳光照在脸上,当你睁开眼睛时,前方有两条路\ 此外,在两个箭头标志上方都有一个标志“这很奇怪,我可能已经死了”\ 有一个牌子上写着“你搞砸了,它发生了,但再试一次”这两条路都通向另外两个选择\ 在你做出这三个选择中最糟糕的一个之前, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“跑进洞穴躲避巨魔”, “NextScene”:“Cave”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“尝试在巨魔腿之间逃跑”, “NextScene”:“Chase”} ] } 场景指令[“追逐”]={ “分支”:假, “SceneText”:“你跪在巨魔双腿之间滑翔,巨大的拳头从后面砸下来\ 你,你站起来,开始跑下山向你的村庄跑去,听到它雷鸣般的脚步声\ 在后面。你们镇上的人听到了喧闹声,朝大门走去,看到你们被追赶,他们都走了\ 开始为你加油,让你继续前进!”, “NextScene”:“决定” } 情景指令[“决定”]={ “分支”:没错, “SceneText”:“你离你的村庄大约100米远,但你记得有一条河通向村庄\ 在大门的右边,你很可能会把巨魔带到那边,让它撞过桥\ 跳进水里,或者你可以试试警卫关上大门的速度来阻挡巨魔。”, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“继续前往村庄”, “NextScene”:“村庄”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“奔向水面”, “NextScene”:“Bridge”} ] } 场景法令[“村庄”]={ “分支”:假, “SceneText”:“你尽可能快地向村庄跑去,巨魔克利林正在逼近你。”\ 当你跑的时候,你叫警卫开始关上大门,当你跑的时候,大门开始关上\ 靠近它,你迅速滑过最后一个剩余的开口,门砰地关上,接着是一声巨响\ “砰!”巨魔把头撞进大门。当你活着回来时,全村人都欢呼起来, } 情景指令[“桥”]={ “分支”:假, “SceneText”:“当村民们欢呼时,他们开始质疑你在干什么?!你改变了你的道路\ 然后向桥走去。几秒钟后,你开始在正在小溪边的木桥上奔跑\ 真的在发抖。突然你听到一声咔嗒的响声,因为底部发出声音,你抓住了桥的一侧\ 当你听到巨大的水花飞溅时,桥会在你脚边脱落,只留下两边可以抓住\ 巨魔飘向远方。”, } 场景指令[“洞穴”]={ “分支”:没错, “SceneText”:“你向前跑进洞穴,把一些血滑入洞穴深处。在你身后\ 巨魔就要来了,但是你听到了水花飞溅进洞穴的声音。”, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“向喷溅处深入洞穴”, “NextScene”:“Jump”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“站在巨魔面前”, “NextScene”:“学习”} ] } 情景指令[“跳跃”]={ “分支”:假, “SceneText”:“你朝悬崖的尽头跑去,悬崖边上有一个小瀑布\ 你听到巨魔逼近你,但是下降是可以控制的,你后退一步,为荣耀而跳跃!你\ 随着水花落地,巨魔坐在顶端,怒吼着你逃走了,你成功了。现在去找他\ 回家的路……“, } 情景指令[“学习”]={ “分支”:假, “SceneText”:“你向后伸手从背后夺剑,但巨魔一个快速动作就将你击碎\ 把你变成肉糜,很不幸你听到一个闪闪发光的声音,你就回来了\ 再次踏上通往山洞的道路,仿佛上帝给了你第二次机会或其他什么。”, “NextScene”:“进入” } currentScene=“Begging” 而当前场景!=“”: 场景数据=场景指令[当前场景] 打印(sceneData[“SceneText”]) 打印() 如果场景数据[“分支”]: 对于sceneData[“选项”]中的选项: 打印(选项[“ChoiceNumber”]+选项[“ChoiceText”]) 打印() 回答=输入(“>”) 打印() 答案=int(答案)-1 如果while循环中的答案

如何修复python上的分支/故事制作? sceneDict={} 布告[乞讨]={ “分支”:错误 “SceneText”:“走向那棵被挖空的树的入口,你会发现\ 注意泥土通道两侧的一些大头骨以及其他\ 大骨头,看起来不像你以前见过的任何东西。”, “NextScene”:“进入” } 情景指令[“进入”={ “分支”:没错, “SceneText”:“你来到洞穴入口,在检查它时,你注意到一些\ 从入口顶部滴下的液体,你手里抓着一小部分,这是\ 红色,有着血的一致性。突然一声雷鸣般的吼声在你身后响起,一声巨响\ 巨魔出现了!“, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“跑进洞穴躲避巨魔”, “NextScene”:“Cave”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“尝试在巨魔腿之间逃跑”, “NextScene”:“Chase”}, {“ChoiceNumber”:“3.”, “选择文字”:“拔出你的剑,试图与巨魔作战” “NextScene”:“战斗”} ] } 场景指令[“战斗”]={ “分支”:假, “SceneText”:“当你伸手从背后夺剑时,巨魔将手臂伸向目标\ 在一次横扫运动中,你撞到了一棵树上,不幸地结束了你的生命。”, “来世”:“来世” } 场景法令[“来世”]={ “分支”:没错, “SceneText”:“你感觉到阳光照在脸上,当你睁开眼睛时,前方有两条路\ 此外,在两个箭头标志上方都有一个标志“这很奇怪,我可能已经死了”\ 有一个牌子上写着“你搞砸了,它发生了,但再试一次”这两条路都通向另外两个选择\ 在你做出这三个选择中最糟糕的一个之前, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“跑进洞穴躲避巨魔”, “NextScene”:“Cave”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“尝试在巨魔腿之间逃跑”, “NextScene”:“Chase”} ] } 场景指令[“追逐”]={ “分支”:假, “SceneText”:“你跪在巨魔双腿之间滑翔,巨大的拳头从后面砸下来\ 你,你站起来,开始跑下山向你的村庄跑去,听到它雷鸣般的脚步声\ 在后面。你们镇上的人听到了喧闹声,朝大门走去,看到你们被追赶,他们都走了\ 开始为你加油,让你继续前进!”, “NextScene”:“决定” } 情景指令[“决定”]={ “分支”:没错, “SceneText”:“你离你的村庄大约100米远,但你记得有一条河通向村庄\ 在大门的右边,你很可能会把巨魔带到那边,让它撞过桥\ 跳进水里,或者你可以试试警卫关上大门的速度来阻挡巨魔。”, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“继续前往村庄”, “NextScene”:“村庄”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“奔向水面”, “NextScene”:“Bridge”} ] } 场景法令[“村庄”]={ “分支”:假, “SceneText”:“你尽可能快地向村庄跑去,巨魔克利林正在逼近你。”\ 当你跑的时候,你叫警卫开始关上大门,当你跑的时候,大门开始关上\ 靠近它,你迅速滑过最后一个剩余的开口,门砰地关上,接着是一声巨响\ “砰!”巨魔把头撞进大门。当你活着回来时,全村人都欢呼起来, } 情景指令[“桥”]={ “分支”:假, “SceneText”:“当村民们欢呼时,他们开始质疑你在干什么?!你改变了你的道路\ 然后向桥走去。几秒钟后,你开始在正在小溪边的木桥上奔跑\ 真的在发抖。突然你听到一声咔嗒的响声,因为底部发出声音,你抓住了桥的一侧\ 当你听到巨大的水花飞溅时,桥会在你脚边脱落,只留下两边可以抓住\ 巨魔飘向远方。”, } 场景指令[“洞穴”]={ “分支”:没错, “SceneText”:“你向前跑进洞穴,把一些血滑入洞穴深处。在你身后\ 巨魔就要来了,但是你听到了水花飞溅进洞穴的声音。”, “选择”:[ {“ChoiceNumber”:“1.”, “ChoiceText”:“向喷溅处深入洞穴”, “NextScene”:“Jump”}, {“ChoiceNumber”:“2.”, “ChoiceText”:“站在巨魔面前”, “NextScene”:“学习”} ] } 情景指令[“跳跃”]={ “分支”:假, “SceneText”:“你朝悬崖的尽头跑去,悬崖边上有一个小瀑布\ 你听到巨魔逼近你,但是下降是可以控制的,你后退一步,为荣耀而跳跃!你\ 随着水花落地,巨魔坐在顶端,怒吼着你逃走了,你成功了。现在去找他\ 回家的路……“, } 情景指令[“学习”]={ “分支”:假, “SceneText”:“你向后伸手从背后夺剑,但巨魔一个快速动作就将你击碎\ 把你变成肉糜,很不幸你听到一个闪闪发光的声音,你就回来了\ 再次踏上通往山洞的道路,仿佛上帝给了你第二次机会或其他什么。”, “NextScene”:“进入” } currentScene=“Begging” 而当前场景!=“”: 场景数据=场景指令[当前场景] 打印(sceneData[“SceneText”]) 打印() 如果场景数据[“分支”]: 对于sceneData[“选项”]中的选项: 打印(选项[“ChoiceNumber”]+选项[“ChoiceText”]) 打印() 回答=输入(“>”) 打印() 答案=int(答案)-1 如果while循环中的答案,python,input,Python,Input,,则表示您在if中使用了错误的结束报价 sceneDict = {} sceneDict["Beggining"] = { "Branching" : False "SceneText" : "Walking towards the enterance to the hollowed out tree you \ notice some large skulls on the sides of the dirt path along with other \ large sized bones

,则表示您在if中使用了错误的结束报价
sceneDict = {}

sceneDict["Beggining"] = {
"Branching" : False
"SceneText" : "Walking towards the enterance to the hollowed out tree you \
notice some large skulls on the sides of the dirt path along with other \
large sized bones which don't look like anything you've ever seen before.",
"NextScene" : "Enterance"
}

sceneDict["Enterance" = {
"Branching": True,
"SceneText" : "You come up to the cave enterance and upon inspecting it you notice some \
liquid dripping from the roof of the enterance, you catch a small amount in your hand.. It's \
red and has the consistency of blood. All of a sudden a thundering roar is heard behind you and a massive \
troll has appeared!",
"Choices" : [
        {"ChoiceNumber" : "1. ",
         "ChoiceText" : "Run into the cave to escape the troll",
         "NextScene" : "Cave"},
        {"ChoiceNumber" : "2. ",
         "ChoiceText" : "Attempt to escape between the trolls legs",
         "NextScene" : "Chase"},
        {"ChoiceNumber" : "3. ",
         "ChoiceText" : "Pull out your sword in an attempt to combat the troll"
         "NextScene" : "Combat"}
    ]
}

sceneDict["Combat"] = {
"Branching": False,
"SceneText" : "As you reach back to grab your sword from your back the troll puts its arm out to the \
side and in one sweeping motion smashes you into a tree, unfortunately ending your life.",
"NextScene" : "Afterlife"
}

sceneDict["Afterlife"] = {
"Branching": True,
"SceneText" : "You feel sunlight on your face and as you open your eyes there is two pathways infront of you \
as well as a sign over top of both'that's strange, I should probably be dead' however, above the arrow signs \
there is a sign that reads 'You messed up, it happens but try again' the paths both lead to the two other choices\
you had before you took the worst of the three choices.",
"Choices" : [
        {"ChoiceNumber" : "1. ",
         "ChoiceText" : "Run into the cave to escape the troll",
         "NextScene" : "Cave"},
        {"ChoiceNumber" : "2. ",
         "ChoiceText" : "Attempt to escape between the trolls legs",
         "NextScene" : "Chase"}
    ]
}

sceneDict["Chase"] = {
"Branching": False,
"SceneText" : "You slide on your knees between the trolls legs as it's enormous fists come crashing down behind \
you, you get back up and start running down the hill towards your village hearing its thunderous steps close \
behind. The people of your town hear the ruckus and go towards the gate to see you being chased and they all \
start cheering you to keep going!",
"NextScene" : "Decisions"
}

sceneDict["Decisions"] = {
"Branching": True,
"SceneText" : "You are about 100 meters out from your village but you remember that there is a river to the \
right of the gate you could most likely lead the troll over there and have it crash through the bridge \
into the water, or you could chance the guards speed of closing the gate to block the troll.",
"Choices" : [
         {"ChoiceNumber" : "1. ",
         "ChoiceText" : "Continue towards the village",
         "NextScene" : "Village"},
        {"ChoiceNumber" : "2. ",
         "ChoiceText" : "Run towards the water",
         "NextScene" : "Bridge"}
     ]
}

sceneDict["Village"] = {
"Branching": False,
"SceneText" : "You run towards the village as fast as you possibly can the troll clearling gaining on you \
you call out for the guards to start closing the gate as you are running, the gate begins to close as you \
close in on it, you quickly slide through the last remaining opening as the gate slams shut followed by a loud \
'BANG!' as the troll smashes his head into the gate. The village cheers as you made it back alive!",
}
sceneDict["Bridge"] = {
"Branching": False,
"SceneText" : "As the villagers are cheering they start questioning what are you doing?! You change your path \
and go for the bridge. You start running over the wooden bridge as it is creeking and after a few seconds \
really shaking. Suddenly you hear a snap as the bottom gives out and you grab onto the side of the bridge. \
The bridge falls away at your feet only leaving the sides to hold onto as you hear a loud splash and see \
the troll floating away into the distance.",
}

sceneDict["Cave"] = {
"Branching": True,
"SceneText" : "You run forward into the cave, and slip on some of the blood into the depths of it. Behind you \
the troll is coming, however you hear the sound of splashing further into the cave.",
"Choices" : [
        {"ChoiceNumber" : "1. ",
         "ChoiceText" : "Run deeper into the cave towards the splashing",
         "NextScene" : "Jump"},
        {"ChoiceNumber" : "2. ",
         "ChoiceText" : "Stand your ground to the troll",
         "NextScene" : "Learn"}
    ]
}
sceneDict["Jump"] = {
"Branching": False,
"SceneText" : "You run towards the end of a cliff which has a small waterfall going over the edge of it \
you hear the troll gaining on you, but the drop is managable, you take a step back and leap for glory! You \
land with a splash and the troll sits at the top roaring in anger at your escape, you made it.. now to find \
your way home..",
}

sceneDict["Learn"] = {
"Branching": False,
"SceneText" : "You reach back to grab your sword from your back but in one swift movement the troll smashes you \
into the ground turning you into mince meat, very unfortunate.. You hear a shimmering sound and you appear back \
in on the path towards the cave again as if a God has given you a second chance or something.",
"NextScene" : "Enterance"
}

currentScene = "Beggining"

while currentScene != "":
    sceneData = sceneDict[currentScene]
    print(sceneData["SceneText"])
    print()

    if sceneData["Branching']:
        for choice in sceneData["Choices"]:
            print(choice["ChoiceNumber"] + choice["ChoiceText"])

        print()

        answer = input("> ")
        print()

        answer = int(answer) - 1
        if answer <= len(sceneData["Choices"])
            currentScene = sceneData["Choices"][answer]["NextScene"]

    else:
        currentScene = sceneData ["NextScene"]

window.exitonclick()
if sceneData["Branching']
if sceneData["Branching"]
if sceneData['Branching']
sceneDict["Beggining"] = {
    "Branching" : False
    "SceneText" : "Walking towards the enterance to the hollowed out tree you \n"
                  "notice some large skulls on the sides of the dirt path along with other \n"
                  "large sized bones which don't look like anything you've ever seen before.",
    "NextScene" : "Enterance"
}