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
08397dfb
authored
Nov 17, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
2d25f375
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
7 deletions
p.py
p.py
View file @
08397dfb
class
Hero
(
object
)
:
class
Hero
:
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
#只有名字要最后赋值,其他都是固定的
self
.
level
=
1
self
.
level
=
1
self
.
hp
=
3500
self
.
hp
=
3500
self
.
attack
=
388
self
.
attack
=
388
self
.
name
=
name
self
.
name
=
name
def
diren
(
self
,
emery
):
def
diren
(
self
,
emery
):
emery
.
hp
-=
self
.
attack
emery
.
hp
-=
self
.
attack
s1
=
self
+
"对"
+
emery
+
"发起攻击
"
s1
=
self
.
name
+
"对"
+
emery
.
name
+
"发起攻击,
"
s2
=
"对"
+
emery
+
"造成"
+
str
(
emery
.
hp
)
+
"的伤害
"
s2
=
"对"
+
emery
.
name
+
"造成"
+
str
(
emery
.
attack
)
+
"的伤害,
"
s3
=
emery
+
"的血量还有"
+
str
(
emery
.
hp
)
if
emery
.
hp
>
0
:
if
emery
.
hp
>
0
:
s3
=
emery
.
name
+
"的血量还有"
+
str
(
emery
.
hp
)
s
=
s1
+
s2
+
s3
print
(
s
)
else
:
s4
=
emery
.
name
+
"的血量为0"
ss
=
s1
+
s2
+
s4
print
(
ss
)
exit
()
yase
=
Hero
(
"亚瑟"
)
houyi
=
Hero
(
"猴一"
)
houyi
.
diren
(
yase
)
#调用一次,攻击一次
houyi
.
diren
(
yase
)
#再次攻击
\ 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