Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_test1
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
f9362009
authored
Aug 14, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d7ff1317
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
4 deletions
diy.py
diy.py
View file @
f9362009
...
@@ -4,6 +4,7 @@ class Hero(object):
...
@@ -4,6 +4,7 @@ class Hero(object):
self
.
hp
=
3500
self
.
hp
=
3500
self
.
attack
=
388
self
.
attack
=
388
self
.
name
=
name
self
.
name
=
name
self
.
max_hp
=
self
.
hp
def
combat
(
self
,
enemy
):
# 攻击
def
combat
(
self
,
enemy
):
# 攻击
enemy
.
hp
-=
self
.
attack
enemy
.
hp
-=
self
.
attack
...
@@ -15,7 +16,23 @@ class Hero(object):
...
@@ -15,7 +16,23 @@ class Hero(object):
info3
=
enemy
.
name
+
'还剩下'
+
str
(
enemy
.
hp
)
+
'点生命值'
info3
=
enemy
.
name
+
'还剩下'
+
str
(
enemy
.
hp
)
+
'点生命值'
print
(
info1
+
info2
+
info3
)
print
(
info1
+
info2
+
info3
)
def
cure
(
self
):
self
.
hp
=
self
.
hp
+
500
if
self
.
hp
>
self
.
max_hp
:
self
.
hp
=
self
.
max_hp
print
(
self
.
name
+
"使用了治疗,血量为:"
,
self
.
hp
)
houyi
=
Hero
(
"后羿"
)
class
Player
(
Hero
):
yase
=
Hero
(
"垭瑟"
)
def
__init__
(
self
,
name
,
hero_type
):
houyi
.
combat
(
yase
)
super
()
.
__init__
(
name
)
\ No newline at end of file
self
.
hp
=
3500
self
.
attack
=
450
self
.
hero_type
=
hero_type
print
(
'角色'
+
self
.
name
+
'创建成功,类型为:'
+
hero_type
)
print
(
'等级,血量,攻击力:'
,
self
.
level
,
self
.
hp
,
self
.
attack
)
ailin
=
Player
(
'艾琳'
,
'射手'
)
#houyi = Hero("后羿")
#yase = Hero("垭瑟")
#houyi.combat(yase)
ailin
.
cure
()
\ 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