- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
所以,我正在制作一个角色扮演游戏,并且正在制作一个 map 功能。错误出现在脚本顶部名为 map1 的 def 中。请停止!另外,无论您有什么解决方案,请您解释一下它的作用,我是个新人。
weap = 0
fate = 0
gold = 100
#---------------------------------------------------------------------------------
def map1(dellon, forrest, fate):
print(dellon)
print("MAP")
print("---------------------------------------------------------------------------------")
print("type one of the following numbers, then press enter.")
if dellon == 1:
print("\n(1) Dellon")
if forrest == 1:
print("(2) Darkwood Forrest")
if fate == 1:
print("(3) Fate")
choice = float(input())
if choice == 1:
dellon(0)
elif choice == 2:
forrest()
elif choice == 3:
fate()
#---------------------------------------------------------------------------------
def forrest():
print("What do you chose to do:")
print("(1) Go North\n(2) Go South\n(3) Go East\n(4) Go West\n(5) Go hunting")
choice = input()
if choice == 1:
print("You find Donna picking berries, do you wish to talk to her?")
print("(1) Yes\n(2) No")
talk = input()
if talk == 1:
pass
elif talk == 2:
forrest()
elif choice == 2:
Fate()
fate = 1
elif choice == 5:
from random import randint
hunt = randint(1,3)
if hunt == 1:
animal = randint(1,5)
if animal == 1:
print("You where ambushed by a wild bear.")
input()
elif animal == 2:
print("You have been ambushed by a wild wolf.")
input()
elif animal == 3:
print("You have been ambushed by a wild bobcat.")
input()
elif animal == 4:
print("You have been ambushed by a wild cyote.")
elif animal == 5:
pass
input()
#---------------------------------------------------------------------------------
def kingsquestdone(gold, dellon, forrest, fate):
print("KING: I see you have the potions, good work!")
print("Give them to me, and I will have")
print("before you leave, here is your pay. I'll give")
print("my servant deliver them to the hospital. And I will give")
print("you 300 gold for your troubles.")
gold = gold + 300
print("Your current gold is "+ str(gold) +".")
choice = float(input("(1) Go into Dellon\n(2) Map: "))
if choice == 2:
map1(dellon, forrest, fate)
elif choice == 1:
indellon(1)
#---------------------------------------------------------------------------------
def lockfail():
print("You have failed to pick the lock.")
game0()
#---------------------------------------------------------------------------------
def king(name):
print("KING: Hello "+ name +", I requested your presence because")
print("we, the people of Dellon, need your help.")
print("We need you to seek out a berry called")
print("a jutish berry. It is for the public hospital, they need")
print("it to make healing remidies for the sick, and injured.")
print("--------------------------------------------------------------")
print("What do you want to say:")
print("1: Ok, I'll help.\n2: Maybe later.")
choice = float(input())
if choice == 1:
print("KING: Good, the berry is found Darkwood Forrest. A woman named Donna.")
print("She has much exxperience in picking these berries, talk to")
print("her to learn how, and where to pick them. After you pick")
print("three bushes, return to me, and I will give you your pay.")
input("Press enter to continue into Darkwood Forrest.")
dforrestent()
#---------------------------------------------------------------------------------
def allberriespicked():
print("-----------------------------------------------------------------")
print("\nDONNA: Good, you have collected all of the needed berries.")
print("I'll take those, and make them into the potions that you need.")
print("You can return here any time you want to pick some berries")
print("for me to earn some extra coin. Return to the King, and deliver")
print("those berries to him.")
input("\nPress enter to travel to the king.")
kingsquestdone(gold)
#---------------------------------------------------------------------------------
def dforrestent():
def jutish4():
from random import randint
berry = randint(1, 2)
if berry == 1:
print("---------------------------------------------------------------------")
print("\nYou have picked one jutish berry bush.")
input("Press enter to return to Donna.")
allberriespicked()
elif berry == 2:
print("---------------------------------------------------------------------")
print("\nYou didn'd find the correct bush this time, try again.")
input("Press enter to continue looking.")
jutish4()
def jutish3():
from random import randint
berry = randint(1,2)
if berry == 1:
print("---------------------------------------------------------------------")
print("\nYou have picked one jutish berry bush.")
input("Press enter to continue picking the berries.")
jutish4()
elif berry == 2:
print("\nYou didn'd find the correct bush this time, try again.")
input("Press enter to continue looking.")
jutish3()
def jutish2():
from random import randint
berry = randint(1, 2)
if berry == 1:
print("---------------------------------------------------------------------")
print("\nYou have picked one jutish berry bush.")
input("Press enter to continue picking the berries.")
jutish3()
elif berry == 2:
print("\nYou didn'd find the correct bush this time, try again.")
input("Press enter to continue looking.")
jutish2()
def jutish1():
print("You enter a field type area with many different types of bushes.")
input("\nPress enter to look for more jutish berry bushes.")
from random import randint
berry = randint(1, 2)
if berry == 1:
print("\nYou have picked one jutish berry bush.")
input("Press enter to continue picking the berries.")
jutish2()
elif berry == 2:
print("\nYou didn'd find the correct bush this time, try again.")
input("Press enter to look again.")
jutish1()
forrest = 1
print("you have entered the forrest. You must search")
print("for Donna as the King has mentioned.")
print("")
print("1: Go West\n2: Go North\n3: Go East\n4: Go South")
choice = float(input("Enter a number to travel in that direction: "))
if choice == 1:
print("You end up walking for hours, and never find Donna.")
print("You end up back at the enterance to Darkwood Forrest.")
elif choice == 2:
print("You find Donna, and speak to her.")
print("\nDONNA: Hello traveler, you must be the one")
print("delivering the jutish berries for the Dellon hospital.")
print("To find these berries, you must go to the enterance of the")
print("forrest, and then travel East, then you will find a")
print("short, and prickly bush with bright red berries, those are")
print("the jutish berries you are looking for. Pick berries from")
print("four of the bushes, then return to me.")
input("\nPress enter to continue.")
jutish1()
#---------------------------------------------------------------------------------
def indellon(first):
if first == 0:
print("a man approaches you with a letter.")
print("MAN: Hello sir, what is your name?")
name = input("Name: ")
print("MAN: Ah, good to meet you, "+ name +", I have a")
print("message for from the King himself. He says that")
print("he wishes to discuss something that will relieve")
print("your bounty. I suggest you talk to him imidiatly.")
print("\nPress enter to conitinue.")
first = 1
input()
king(name)
elif first == 1:
print("What do you want to do?")
print("(1) Leave Dellon")
print("(2) Go to shops")
print("(3) Go to residential homes")
print("(4) Go to the King's castle")
print("(5) Map")
choice = input()
if choice == 1:
dellonsign()
elif choice == 2:
dellonshops()
elif choice == 3:
dellonhomes()
elif choice == 4:
kingscastle()
elif choice == 5:
map1(dellon, forrest, fate)
#---------------------------------------------------------------------------------
def fight1(dellon):
print("you decide to confront the gaurd.")
en_hp = 10
pl_hp = 10
print("press (1) to attack")
choice = float(input())
if choice == 1:
while True:
if weap == 1:
from random import randint
en_damage = randint (1,8)
pl_damage = randint (5,15)
elif weap == 0:
from random import randint
en_damage = randint (1,8)
pl_damage = randint (1,10)
en_hp = en_hp - pl_damage
pl_hp = pl_hp - en_damage
print("enemy hp is now:")
print(en_hp)
print("your hp is now:")
print(pl_hp)
print("press enter to attack again.")
input()
if en_hp < 1:
print("You win this battle, and continue onwards.")
input("press enter to continue")
dellon = 1
dellon(0)
break
if pl_hp < 1:
print("You died.")
input("press enter to continue")
fight1()
break
#---------------------------------------------------------------------------------
def dellon(dellong):
if dellong == 1:
print("as you approach Dellon's city gates, you see")
print("a gaurd, do you want to try to sneak past him")
print("or confront him?")
print("(1) sneak past")
print("(2) confront")
choice = float(input())
if choice == 1:
from random import randint
n = randint(1,2)
if n == 1:
print("you failed to sneak past the gaurd, and must")
print("commenc battle.")
fight1(0)
elif n == 2:
print("you have succesfully snuck past that gaurd and enter")
print("the city.")
dellon = 1
input()
elif choice == 2:
fight1(dellon)
elif dellong == 0:
print("(1) enter Dellon")
print("(2) map")
choice1 = float(input())
if choice1 == 1:
indellon(0)
elif choice1 == 2:
map1(dellon, forrest, fate)
#---------------------------------------------------------------------------------
def freedome():
print("as you step outside, you see two signs, one says")
print("capitol city of Dellon, and the other says Red Bird Forrest.")
print("which path do you wish to choose?")
print("(1) Dellon")
print("(2) Forrest")
choice = float(input())
if choice == 2:
forrest()
if choice == 1:
dellong = 1
dellon(1)
#---------------------------------------------------------------------------------
def fightwin():
print("do you wish to search this body? If you do, you may")
print("run into more gaurds, if not, you won't get a better weapon.")
print("(1) yes")
print("(2) no")
choice = float(input())
if choice == 1:
print("you find a long sword, and continue out the jail")
print("doors and into freedome once more.")
weap = 1
freedome()
elif choice == 2:
print("you decide to ignore the body, and continue out the jail")
print("doors and into freedome once more.")
weap = 0
freedome()
#---------------------------------------------------------------------------------
def fight():
print("You have succesfully busted through the wall, and escaped your cell, but there's a gaurd on the other side! What do you want to do?")
en_hp = 10
pl_hp = 10
print("(1) attack")
choice = float(input())
if choice == 1:
while True:
from random import randint
en_damage = randint(1,8)
pl_damage = randint(1,10)
en_hp = en_hp - en_damage
pl_hp = pl_hp - pl_damage
print("enemy hp is now:")
print(en_hp)
print("your hp is now:")
print(pl_hp)
print("press enter to attack again.")
input()
if en_hp < 1:
print("You win this battle.")
input("press enter to continue")
fightwin()
break
if pl_hp < 1:
print("You died.")
input("press enter to continue")
game0()
break
#--------------------------------------------------------------------------------------
def lockgen():
from random import randint
number = randint(1,2)
if number == 1:
lfight()
if number == 2:
lockfail()
#--------------------------------------------------------------------------------------
def game0():
print("You wake up very fatigued in a prison cell.")
print("Your location is unkown, and you must break out.")
print("Your only choice is to attempt to escape by digging your way")
print("through the wall with a stone you have found.")
print("-----------------------------------------------------")
print("1: Dig through wall")
prisonchoice = float(input())
if prisonchoice == 1:
fight()
else:
game0()
def gameover():
input("Game Over. Press enter to exit.")
print("")
print("welcome to THE role playing game.")
print("(1) Start game")
print("(2) Type in checkpoint key")
startchoice = float(input())
if startchoice == 2:
print("Enter in the code.")
code = float(input())
if code == 123:
dellon = 1
forrest = 1
fate = 0
kingsquestdone(gold, dellon, forrest, fate)
elif startchoice == 1:
game0()
最佳答案
在你的函数中,你有这样的语句:
if dellon == 1:
print("\n(1) Dellon")
这是检查是否 dellon
等于 1,因此我假设想看看 dellon
是否是一个整数(正如@Blender所说,使用完整的回溯会更容易)。然后你就这样做
if choice == 1:
dellon(0)
假设dellon
实际上是一个整数,您现在将它视为一个函数并使用 0
调用它作为一个论点。你实际上有一个dellon
可以使用参数调用的函数,因此您可能需要查看您要使用 if dellon == 1:
执行的操作。快速浏览一下程序的其余部分,您正在传递 dellon
看起来像是函数形式,您不需要这样做,因为它不返回任何内容并且已经可供其他函数使用。
关于python - 我收到类型错误 : int object not callable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13150129/
我遵循了一本名为“Sitepoint Full Stack Javascript with MEAN”的书中的教程,我刚刚完成了第 6 章,应该已经创建了一个带有“数据库”的“服务器”。数据库只不过是
在 Jquery 中,我创建两个数组,一个嵌入另一个数组,就像这样...... arrayOne = [{name:'a',value:1}, {name:'b',value:2}] var arra
这个问题在这里已经有了答案: What is the explanation for these bizarre JavaScript behaviours mentioned in the 'Wa
我被放在别人的代码上,有一个类用作其他组件的基础。当我尝试 ng serve --aot(或 build --prod)时,我得到以下信息。 @Component({ ...,
我正在测试一些代码,并使用数据创建了一个 json 文件。 问题是我在警报中收到“[object Object],[object Object]”。没有数据。 我做错了什么? 这是代码:
我想打印 [object Object],[object Object] 以明智地 "[[{ 'x': '1', 'y': '0' }, { 'x': '2', 'y': '1' }]]"; 在 ja
我有一个功能 View ,我正在尝试以特殊格式的方式输出。但我无法让列表功能正常工作。 我得到的唯一返回是[object Object][object Object] [object Object]
在使用优秀的 Sim.js 和 Three.js 库处理 WebGL 项目时,我偶然发现了下一个问题: 一路走来,它使用了 THREE.Ray 的下一个构造函数: var ray = new THRE
我正在使用 Material UI 进行多重选择。这是我的代码。 {listStates.map(col => (
我的代码使用ajax: $("#keyword").keyup(function() { var keyword = $("#keyword").val(); if (keyword.
我遇到了下一个错误,无法理解如何解决它。 Can't resolve all parameters for AuthenticationService: ([object Object], ?, [o
我正在尝试创建一个显示动态复选框的表单,至少应选中其中一个才能继续。我还需要获取一组选中的复选框。 这是组件的代码: import { Component, OnInit } from '@angul
我正在开发 NodeJs 应用程序,它是博客应用程序。我使用了快速验证器,我尝试在 UI 端使用快速闪存消息将帖子保存在数据库中之前使用闪存消息验证数据,我成功地将数据保存在数据库中,但在提交表单后消
我知道有些人问了同样的问题并得到了解答。我已经查看了所有这些,但仍然无法解决我的问题。我有一个 jquery snipet,它将值发送到处理程序,处理程序处理来自 JS 的值并将数据作为 JSON 数
我继承了一个非常草率的项目,我的任务是解释为什么它不好。我注意到他们在整个代码中都进行了这样的比较 (IQueryable).FirstOrDefault(x => x.Facility == fac
我只是在删除数组中的对象时偶然发现了这一点。 代码如下: friends = []; friends.push( { a: 'Nexus', b: 'Muffi
这两个代码片段有什么区别: object = nil; [object release] 对比 [object release]; object = nil; 哪个是最佳实践? 最佳答案 object
我应该为其他人将从中继承的第一个父对象传递哪个参数,哪个参数更有效 Object.create(Object.prototype) Object.create(Object) Object.creat
我在不同的对象上安排不同的选择器 [self performSelector:@selector(doSmth) withObject:objectA afterDelay:1]; [self per
NSLog(@"%p", &object); 和 NSLog(@"%p", object); 有什么区别? 两者似乎都打印出一个内存地址,但我不确定哪个是对象的实际内存地址。 最佳答案 这就是我喜欢的
我是一名优秀的程序员,十分优秀!