我一直在尝试使用 python 编码在 renpy 上制作类似 pesudo RPG 的游戏。我主要将其用作基本测试场,并将我的代码组织到不同的 rpy 文件中。但是现在,我很难将这些技能从子类绑定到主类。这是字符类
#侦探属性
class Detective:
def __init__(self, name, intelligence, psyche, strength, dexterity):
self.name = name
self.intelligence = intelligence
self.psyche = psyche
self.strength = strength
self.dexterity = dexterity
#智力技能
class IntSkill(Detective):
def __init__(self, logic, history, persuasion, deception):
super().__init__(self, name, intelligence, psyche, strength, dexterity)
self.logic = logic
self.history = history
self.persuasion = persuasion
self.deception = deception
默认侦探 = Detective("无名", 5, 5, 5, 5)
我觉得我应该只发布完整的脚本,这样人们就会知道我在寻找什么。尝试应用类似 psudo RPG 的效果,其中侦探类的属性也将带入应该被定义为类的孩子的技能。
label start:
unknown "Can you feel it?"
"..."
unknown "Can you see it?"
"..."
unknown "The spark of life flowing back in your mortal coil."
unknown "It may feel empty, cold and dark at first. That's always the case like this."
unknown "Now, your last moments, do you remember them, child of man?"
unknown "'Sorry detective, but the game was rigged from the start.'"
"First silence,"
"then there was gunfire."
"Three shots were fired."
"The last two were in rapid succession, as though fired at the same time."
unknown "Yes, yes it is exactly as you remember it."
unknown "But do you remember anything after? Anything before?"
"No... I don't think I do."
unknown "Nobody really remembers their experiences after death."
unknown "But most would remember their time before their death. Do you not know?"
" I don't know if I know myself. Who am I?"
unknown "Ahh, scrambled and fried like eggs over an open flame."
"Something happened?"
unknown "Yeah child of man... you died."
"I knew that from what you were saying."
unknown "And do you remember nothing before then?"
"Some double fucking mother fucker with poor fashion sense."
"And a... bird folk?"
unknown "Ah so some memories have survived."
"Why is this happening?"
unknown "Because sometimes the universe has a cosmological joke to play on all of us,"
unknown "even me."
"So what happens now?"
unknown "First I will ask you a couple questions."
menu:
unknown "What is your most definitive attributes?"
"My vast intellect to unraveling the Material world":
$ nameless.intelligence += 2
jump after_attribute_1
"My intimate relationship with the Immaterial.":
$ nameless.psyche += 2
jump after_attribute_1
"My martial prowess":
$ nameless.strength += 2
jump after_attribute_1
"My flexability and nimbleness.":
$ nameless.dexterity += 2
jump after_attribute_1
label after_attribute_1:
menu:
unknown "Good... now, what is your weakest trait?"
"I struggle to grasp the basics of Material science" if nameless.intelligence == 5:
$ nameless.intelligence -= 2
jump after_attribute_2
"I am deaf to the Immaterial." if nameless.psyche == 5:
$ nameless.psyche -= 2
jump after_attribute_2
"I am physically weak." if nameless.strength == 5:
$ nameless.strength -= 2
jump after_attribute_2
"I trip over my own feet."if nameless.dexterity == 5:
$ nameless.dexterity -= 2
jump after_attribute_2
label after_attribute_2:
unknown "Now let us see how you handle critical thinking."
unknown "What do you think happened?"
if nameless.intelligence.logic >= 7:
"\[Passive Logic Successful] I think I got shot in the head."
if nameless.intelligence.logic < 7:
"Balls if I know"
return
这就是我不断得到的。
[code]
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 126, in script
if int.logic >= 7:
File "game/script.rpy", line 126, in <module>
if int.logic >= 7:
AttributeError: type object 'int' has no attribute 'logic'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "game/script.rpy", line 126, in script
if int.logic >= 7:
File "renpy/ast.py", line 1892, in execute
if renpy.python.py_eval(condition):
File "renpy/python.py", line 2249, in py_eval
return py_eval_bytecode(code, globals, locals)
File "renpy/python.py", line 2242, in py_eval_bytecode
return eval(bytecode, globals, locals)
File "game/script.rpy", line 126, in <module>
if int.logic >= 7:
AttributeError: type object 'int' has no attribute 'logic'
Windows-10-10.0.19041
Ren'Py 7.4.6.1693
Tales of Tellus Mindthrob 0.1
Thu Jun 24 22:48:31 2021
[/code]
我一直在尝试使用类继承器之类的东西,但我只是不知道我做错了什么。