Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_3
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
d17efe3f
authored
Oct 06, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
df53ee8b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
3 deletions
diy2.py
diy2.py
View file @
d17efe3f
...
@@ -9,6 +9,9 @@ class Hero:
...
@@ -9,6 +9,9 @@ class Hero:
def
gongji
(
self
,
e
):
def
gongji
(
self
,
e
):
e
.
hp
-=
self
.
att
e
.
hp
-=
self
.
att
if
self
.
hp
<=
0
:
print
(
e
.
name
+
"死了!"
)
exit
print
(
self
.
name
+
"攻击"
+
e
.
name
print
(
self
.
name
+
"攻击"
+
e
.
name
+
"造成"
+
str
(
self
.
att
)
+
"点伤害,"
+
"造成"
+
str
(
self
.
att
)
+
"点伤害,"
+
e
.
name
+
"剩"
+
str
(
e
.
hp
)
+
"点血。"
)
+
e
.
name
+
"剩"
+
str
(
e
.
hp
)
+
"点血。"
)
...
@@ -32,5 +35,17 @@ class Player(Hero):
...
@@ -32,5 +35,17 @@ class Player(Hero):
p1
=
Player
(
500
,
90
,
"张飞"
)
p1
=
Player
(
500
,
90
,
"张飞"
)
p2
=
Player
(
300
,
60
,
"岩石"
)
p2
=
Player
(
300
,
60
,
"岩石"
)
p1
.
gongji
(
p2
)
while
p1
.
hp
>
0
and
p2
.
hp
>
0
:
p2
.
cure
()
d
=
int
(
input
())
\ No newline at end of file
if
(
d
==
1
):
p1
.
gongji
(
p2
)
elif
(
2
==
d
):
p1
.
cure
()
print
(
"--------------------------------------"
)
d
=
int
(
input
())
if
(
d
==
1
):
p2
.
gongji
(
p1
)
elif
(
2
==
d
):
p2
.
cure
()
print
(
"--------------------------------------"
)
\ 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