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
d8200ee5
authored
Nov 14, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
333183d9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
34 additions
and
0 deletions
diy3.py
diy3.py
0 → 100644
View file @
d8200ee5
import
random
class
Hero
(
object
):
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
250
self
.
attack
=
40
self
.
name
=
name
def
combat
(
self
,
duifang
):
# 攻击
duifang
.
hp
-=
self
.
attack
if
duifang
.
hp
>
0
:
print
(
self
.
name
+
"对"
+
duifang
.
name
+
"发起攻击,"
+
duifang
.
name
+
"减少"
+
str
(
self
.
attack
)
+
"血量,"
+
duifang
.
name
+
"还剩"
+
str
(
duifang
.
hp
)
+
"血量"
)
else
:
print
(
duifang
.
name
+
"已阵亡,游戏结束"
)
print
(
"You Win"
)
exit
()
def
zhiliao
(
self
):
if
self
.
hp
<
250
:
self
.
hp
+=
40
else
:
print
(
"血量已满,加血无效!"
)
class
computer
(
Hero
):
def
__init__
(
name
):
super
()
.
__init__
(
name
):
self
.
hp
=
200
self
.
attack
=
60
while
True
:
a
=
input
(
"你要使用什么技能?(1回血/2攻击)"
)
yase
=
Hero
(
"垭瑟"
)
houyi
=
Hero
(
"后羿"
)
\ 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