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
edbef57a
authored
Aug 07, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
65587578
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
diy1.py
diy1.py
View file @
edbef57a
...
@@ -3,20 +3,20 @@ class Hero(object):
...
@@ -3,20 +3,20 @@ class Hero(object):
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
level
=
1
self
.
hp
=
250
self
.
hp
=
250
self
.
attack
=
40
self
.
attack
=
999
self
.
name
=
name
self
.
name
=
name
def
combat
(
self
,
duifang
):
# 攻击
def
combat
(
self
,
duifang
):
# 攻击
duifang
.
hp
-=
self
.
attack
duifang
.
hp
-=
self
.
attack
info1
=
self
.
name
+
"对"
+
duifang
.
name
+
"发起攻击"
info1
=
self
.
name
+
"对"
+
duifang
.
name
+
"发起攻击"
info2
=
"造成"
+
str
(
self
.
attack
)
+
"点伤害"
info2
=
"造成"
+
str
(
self
.
attack
)
+
"点伤害"
if
duifang
.
hp
>
0
if
duifang
.
hp
>
0
:
info3
=
duifang
.
name
+
"
对
"
+
str
(
duifang
.
hp
)
+
"血量"
info3
=
duifang
.
name
+
"
还剩
"
+
str
(
duifang
.
hp
)
+
"血量"
print
(
info1
+
info2
+
info3
)
print
(
info1
+
info2
+
info3
)
else
:
else
:
info3
=
duifang
.
name
+
"已阵亡"
info3
=
duifang
.
name
+
"已阵亡"
print
(
info1
+
info2
+
info3
)
print
(
info1
+
info2
+
info3
)
exit
()
exit
()
yase
=
Hero
(
"
咸水鸭
"
)
yase
=
Hero
(
"
双汇王中王中王中王中王中王王中王中王中王中王中王王中王中王中王中王中王
"
)
houyi
=
Hero
(
"
北京烤鸭
"
)
houyi
=
Hero
(
"
台湾风味
"
)
yase
.
combat
(
houyi
)
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