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
de247ed1
authored
Jul 28, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
28c8e6ab
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
3 deletions
diy1.py
diy1.py
View file @
de247ed1
import
random
class
Hero
(
object
):
class
Hero
(
object
):
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
name
=
name
self
.
name
=
name
...
@@ -9,7 +10,8 @@ class Hero(object):
...
@@ -9,7 +10,8 @@ class Hero(object):
def
cure
(
self
):
# 治疗
def
cure
(
self
):
# 治疗
self
.
hp
+=
60
self
.
hp
+=
60
if
self
.
hp
>
self
.
max_hp
:
if
self
.
hp
>
self
.
max_hp
:
self
.
hp
=
self
.
max_hp
self
.
hp
=
self
.
max_hp
print
(
self
.
name
,
'用了治疗,'
,
self
.
name
,
"还有"
,
self
.
hp
,
"滴血"
)
def
combat
(
self
,
enemy
):
# 普通攻击
def
combat
(
self
,
enemy
):
# 普通攻击
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起进攻,"
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起进攻,"
info2
=
"造成"
+
str
(
self
.
attack
)
+
"点伤害,"
info2
=
"造成"
+
str
(
self
.
attack
)
+
"点伤害,"
...
@@ -40,4 +42,24 @@ print('-'*30)
...
@@ -40,4 +42,24 @@ print('-'*30)
print
(
" 游戏开始"
)
print
(
" 游戏开始"
)
while
True
:
while
True
:
print
(
'-'
*
30
)
print
(
'-'
*
30
)
input
(
"请选择释放技能(1攻击,2治疗):"
)
ada
=
input
(
"请选择释放技能(1攻击/2治疗):"
)
\ No newline at end of file
if
ada
==
'q'
:
print
(
'game over.'
)
break
elif
ada
==
'1'
:
houyi
.
combat
(
yase
)
elif
ada
==
'2'
:
houyi
.
cure
()
else
:
print
(
'重输'
)
continue
a
=
random
.
randint
(
1
,
3
)
if
a
==
1
or
a
==
2
:
yase
.
combat
(
houyi
)
else
:
yase
.
cure
()
\ 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