Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_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
c8163904
authored
Nov 20, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
49e7b569
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
diy1.py
diy1.py
View file @
c8163904
# 英雄角色类
class
Hero
(
object
):
def
__init__
(
self
,
name
):
self
.
level
=
-
1
self
.
hp
=
-
1
0
self
.
attack
=
-
99999999999999999999999999999999999999999999999999999999999999
9
self
.
level
=
1
self
.
hp
=
20
0
self
.
attack
=
9
self
.
name
=
name
def
combat
(
self
,
enemy
):
# 攻击
...
...
@@ -18,7 +18,16 @@ class Hero(object):
info3
=
enemy
.
name
+
"死了,game over"
info
=
info1
+
info2
+
info3
print
(
info
)
exit
()
class
player
(
Hero
):
def
__init__
(
self
,
name
,
Hero_type
):
super
()
.
__init__
(
name
)
self
.
hp
=
100
self
.
attack
=
10
self
.
Hero_type
=
Hero_type
print
(
"角色"
+
self
.
name
+
"创建成功,英雄类型为:"
,
self
.
Hero_type
)
print
(
"当前等级、血量、攻鸡力分别是:"
,
self
.
level
,
self
.
hp
,
self
.
attack
)
yase
=
Hero
(
"垭瑟"
)
houyi
=
Hero
(
"后羿
"
)
houyi
=
player
(
"后羿"
,
"坦克
"
)
yase
.
combat
(
houyi
)
\ 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