Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson16_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
f7f27aaa
authored
Feb 17, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
333e05c0
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
23 deletions
diy1.py
diy1.py
View file @
f7f27aaa
import
random
class
Hero
(
object
):
def
__init__
(
self
,
name
):
self
.
name
=
name
...
...
@@ -14,10 +13,8 @@ class Hero(object):
print
(
self
.
name
+
"使用了治疗,血量增加:"
,
60
,
",目前的血量为:"
,
self
.
hp
)
def
combat
(
self
,
enemy
):
# 普通攻击
info1
=
self
.
name
+
"+++++666666666+
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*--+++++++++++++++++/--------------------------------------------------------------------------------------------------------------------------------------------------------------------------对"
+
enemy
.
name
+
"发起进攻,"
info2
=
"造成"
+
str
(
+++++
666666666
+
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*--+++++++++++++++++/--------------------------------------------------------------------------------------------------------------------------------------------------------------------------
self
.
attack
)
+
"点伤害,"
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起进攻,"
info2
=
"造成"
+
str
(
self
.
attack
)
+
"点伤害,"
enemy
.
hp
-=
self
.
attack
if
enemy
.
hp
>
0
:
info3
=
enemy
.
name
+
"还剩下"
+
str
(
enemy
.
hp
)
+
"血量"
...
...
@@ -56,24 +53,7 @@ print(" 开始游戏")
print
(
"-"
*
50
)
while
True
:
a
=
input
(
"请使用攻击技能1,回复技能2"
)
if
a
==
"1"
:
houyi
.
combat
(
yase
)
print
(
"发动攻击"
)
elif
a
==
"2"
:
houyi
.
cure
()
print
(
"使用回复"
)
elif
a
==
"q"
:
exit
()
else
:
print
(
"输入有误再来一遍"
)
continue
com
=
random
.
randint
(
1
,
3
)
if
com
==
1
:
yase
.
combat
(
houyi
)
print
(
""
)
else
:
yase
.
cure
()
input
(
"请使用攻击技能1,回复技能2"
)
...
...
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