Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_1
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b1415d9e
authored
Oct 06, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
dffb9f8f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
12 deletions
diy.py
diy.py
View file @
b1415d9e
class
Hero
:
class
Hero
:
def
__init__
(
self
,
name
,
level
,
hp
,
attack
):
def
__init__
(
self
,
name
):
-
self
.
name
=
name
self
.
name
=
name
self
.
level
=
level
self
.
level
=
1
self
.
hp
=
hp
self
.
hp
=
300
self
.
attack
=
attack
self
.
attack
=
40
def
ungrade
(
self
):
#def ungrade(self):
self
.
level
+=
1
#self.level+=1
self
.
hp
+=
50
#self.hp+=50
self
.
attack
+=
40
#self.attack+=40
yase
=
Hero
(
'亚瑟'
,
1
,
300
,
240
)
def
combot
(
self
,
enemy
)
:
yase
.
ungrade
()
enemy
.
hp
-=
self
.
attack
print
(
yase
.
hp
)
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起进攻"
\ No newline at end of file
info2
=
"造成"
+
str
(
self
.
attack
)
+
"的伤害"
if
enemy
.
hp
>
0
:
info3
=
"剩下的血量为"
+
str
(
enemy
.
hp
)
info
=
info1
+
info2
+
info3
print
(
info
)
else
:
info3
=
self
.
name
+
"已经阵亡"
info
=
info1
+
info2
+
info3
print
(
info
)
exit
()
class
Player
(
Hero
):
def
__init__
(
self
,
name
,
hero_type
):
super
(
Player
,
self
)
.
__init__
(
name
)
self
.
hp
=
260
self
.
attack
=
50
self
.
hero_type
=
hero_type
print
(
"角色为"
+
self
.
name
+
"已成功"
)
print
(
"角色"
+
self
.
name
+
"的等级,血量,攻击力"
+
str
(
self
.
level
)
+
str
(
self
.
hp
)
+
str
(
self
.
attack
))
houyi
=
Player
(
"后羿"
,
"射手"
)
# yase.ungrade()
# print(yase.hp)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment