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
6a99e7e7
authored
Jul 17, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
42e09de6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
2 deletions
diy2.py
diy2.py
View file @
6a99e7e7
...
...
@@ -7,6 +7,10 @@ class Hero: # 英雄类
self
.
max_hp
=
self
.
hp
def
cure
(
self
):
self
.
hp
+=
50
if
self
.
hp
>
self
.
max_hp
:
self
.
hp
=
self
.
max_hp
print
(
self
.
name
+
"使用治疗,血量增加:"
,
60
,
"目前的血量为:"
,
self
.
hp
)
def
combat
(
self
,
enemy
):
# 攻击功能
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起进攻,"
...
...
@@ -29,4 +33,9 @@ class Player(Hero): # 玩家英雄
print
(
"英雄"
+
str
(
name
)
+
"创建成功"
)
print
(
"等级:"
+
str
(
self
.
level
),
"血量:"
+
str
(
self
.
hp
),
"攻击力:"
+
str
(
self
.
attack
))
player
=
Player
(
"后羿"
)
\ No newline at end of file
player
=
Player
(
"后羿"
)
yase
=
Hero
(
"亚瑟"
)
print
(
"_"
*
30
)
print
(
" 游戏开始"
)
while
True
:
player_choice
=
input
(
"1,攻击、2,治疗"
)
\ 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