Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson16_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
fd761198
authored
Jul 07, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
c8a03acb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
11 deletions
diy1.py
diy1.py
View file @
fd761198
import
random
lantiao
=
1
0
lantiao
=
0
hit
=
[
7000
,
8000
,
9000
,
10000
]
cint
=
random
.
choice
(
hit
)
class
Hero
(
object
):
...
...
@@ -11,17 +11,18 @@ class Hero(object):
self
.
max_hp
=
self
.
hp
def
cure
(
self
):
# 治疗
global
lantiao
self
.
hp
+=
cint
if
self
.
hp
>
self
.
max_hp
:
self
.
hp
=
self
.
max_hp
print
(
self
.
name
+
"服用了一枚治疗丹,血量增加:"
,
cint
,
",目前的血量为:"
,
self
.
hp
)
lantiao
+=
1
lantiao
=
lantiao
+
1
def
combat
(
self
,
enemy
):
# 普通攻击
global
lantiao
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"扔出一把飞刀,"
info2
=
"造成"
+
str
(
self
.
attack
)
+
"点伤害,"
enemy
.
hp
-=
self
.
attack
lantiao
+=
1
lantiao
=
lantiao
+
1
if
lantiao
>
10
:
lantiao
=
10
if
enemy
.
hp
>
0
:
...
...
@@ -39,13 +40,13 @@ class Hero(object):
exit
()
def
qiang
(
self
,
enemy
):
global
lantiao
if
lantiao
>=
8
:
lantiao
=
lantiao
-
8
self
.
huai
=
self
.
attack
+
5000
infu1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起攻击,"
infu2
=
"造成"
+
str
(
self
.
huai
)
+
"点伤害,"
enemy
.
hp
-=
self
.
huai
lantiao
+=
1
if
lantiao
>
10
:
lantiao
=
10
if
enemy
.
hp
>
0
:
infu3
=
enemy
.
name
+
"还剩下"
+
str
(
enemy
.
hp
)
+
"血量"
infu
=
infu1
+
infu2
+
infu3
...
...
@@ -59,6 +60,8 @@ class Hero(object):
if
self
.
hp
<=
0
:
print
(
"失败"
)
exit
()
if
lantiao
<
8
:
print
(
"蓝条不够,不能使用"
)
class
Player
(
Hero
):
def
__init__
(
self
,
hero_type
,
name
):
...
...
@@ -88,11 +91,7 @@ while True:
elif
int
(
a
)
==
2
:
houyi
.
cure
()
elif
int
(
a
)
==
3
:
if
lantiao
>=
8
:
lantiao
-=
8
houyi
.
qiang
(
yase
)
else
:
print
(
"蓝条不够,不可使用"
)
elif
a
==
"q"
:
print
(
'游戏结束'
)
break
...
...
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