Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_4
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
6e8d76f7
authored
Nov 11, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
7bd75261
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
13 deletions
diy.py
diy.py
View file @
6e8d76f7
...
@@ -5,16 +5,21 @@ class hero:
...
@@ -5,16 +5,21 @@ class hero:
self
.
hp
=
hp
self
.
hp
=
hp
self
.
attack
=
attack
self
.
attack
=
attack
def
upgrade
(
self
):
# def upgrade(self):
self
.
level
=
self
.
level
+
1
# self.level=self.level+1
self
.
hp
=
self
.
hp
+
9999
# self.hp=self.hp+9999
self
.
attack
=
self
.
attack
+
9999
# self.attack=self.attack+9999
def
combat
(
self
,
enemy
):
enemy
.
hp
-=
self
.
attack
ifor1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发动了攻击,"
houyi
=
hero
(
"后羿"
,
240
,
23
)
ifor2
=
"造成了"
+
str
(
self
.
attack
)
+
"点伤害,"
houyi
.
upgrade
()
if
enemy
.
hp
>
0
:
print
(
houyi
.
level
)
ifor3
=
enemy
.
name
+
"还剩下"
+
str
(
enemy
.
hp
)
+
"点血"
print
(
houyi
.
hp
)
print
(
ifor1
+
ifor2
+
ifor3
)
print
(
houyi
.
attack
)
else
:
ifor3
=
enemy
.
name
+
"已阵亡,游戏结束"
print
(
ifor1
+
ifor2
+
ifor3
)
exit
()
yase
=
hero
(
"垭瑟"
,
250
,
40
)
houyi
=
hero
(
"后羿"
,
240
,
45
)
hero
.
combat
(
yase
,
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