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
e6bddf22
authored
Oct 10, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
95469278
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
7 deletions
diy1.py
diy1.py
View file @
e6bddf22
# 英雄角色类
class
Hero
(
object
):
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
250
self
.
attack
=
40
self
.
name
=
name
def
combat
(
self
,
name
):
enemy
.
hp
-=
self
。
attack
def
combat
(
self
,
enemy
):
enemy
.
hp
-=
self
.
attack
into
=
str
(
self
.
name
)
+
"对"
+
str
(
enemy
.
name
)
+
"发起进攻"
into1
=
str
(
enemy
.
name
)
+
"受到"
+
str
(
self
.
attack
)
+
"伤害"
into2
=
str
(
enemy
.
name
)
+
"还剩下"
+
str
(
enemy
.
hp
)
if
enemy
.
hp
>
0
into
=
into
+
into1
+
into2
if
enemy
.
hp
>
0
:
into
3
=
into
+
into1
+
into2
print
(
into3
)
else
:
print
(
into
+
into1
+
str
(
enemy
.
name
)
+
"已阵亡"
)
yase
=
Hero
(
"垭瑟"
)
houyi
=
Hero
(
"后羿"
)
yase
.
combat
(
houyi
)
class
Play
)()
\ 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