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
aeb7c070
authored
Sep 02, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
beb166ed
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
15 deletions
diy1.py
tftf.py
diy1.py
View file @
aeb7c070
...
@@ -5,9 +5,9 @@ class Hero(object):
...
@@ -5,9 +5,9 @@ class Hero(object):
self
.
level
=
1
self
.
level
=
1
self
.
hp
=
250
self
.
hp
=
250
self
.
attack
=
40
self
.
attack
=
40
self
.
max_hp
=
self
.
hp
self
.
max_hp
=
self
.
hp
def
cure
(
self
):
# 治疗
def
cure
(
self
):
self
.
hp
+=
55
self
.
hp
+=
55
if
self
.
hp
>
self
.
max_hp
:
if
self
.
hp
>
self
.
max_hp
:
self
.
hp
=
self
.
max_hp
self
.
hp
=
self
.
max_hp
...
@@ -40,29 +40,30 @@ class Player(Hero):
...
@@ -40,29 +40,30 @@ class Player(Hero):
print
(
'-'
*
30
)
print
(
'-'
*
30
)
print
(
' 战斗开始'
)
print
(
' 战斗开始'
)
def
cure
(
self
):
def
cure
(
self
):
c
=
random
.
randint
(
35
,
50
)
blood
=
random
.
randint
(
30
,
50
)
self
.
hp
+=
c
self
.
hp
=
self
.
hp
+
blood
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
+
"使用了治疗,血量增加:"
,
str
(
c
),
",目前的血量为:"
,
self
.
hp
)
print
(
self
.
name
+
"使用了治疗,血量增加:"
,
blood
,
",目前的血量为:"
,
self
.
hp
)
houyi
=
Player
(
"射手"
,
"后羿"
)
houyi
=
Player
(
"射手"
,
"后羿"
)
yase
=
Hero
(
"垭瑟"
)
yase
=
Hero
(
"垭瑟"
)
print
(
'-'
*
30
)
print
(
' 战斗开始'
)
while
True
:
while
True
:
print
(
'-'
*
30
)
print
(
'-'
*
30
)
a
=
input
(
"请选择技能:1攻击/2治疗"
)
choice
=
input
(
"请选择技能:1攻击/2治疗"
)
if
int
(
a
)
==
1
:
if
choice
==
'q'
:
houyi
.
combat
(
yase
)
elif
int
(
a
)
==
2
:
houyi
.
cure
()
elif
a
==
"q"
:
print
(
'游戏结束'
)
print
(
'游戏结束'
)
break
break
elif
choice
==
'1'
:
houyi
.
combat
(
yase
)
elif
choice
==
'2'
:
houyi
.
cure
()
else
:
else
:
print
(
'
重输!
'
)
print
(
'
请重新输入(1或者2)
'
)
continue
continue
b
=
random
.
randint
(
1
,
3
)
num
=
random
.
randint
(
1
,
3
)
if
b
==
3
:
if
num
==
1
:
yase
.
cure
()
yase
.
cure
()
else
:
else
:
yase
.
combat
(
houyi
)
yase
.
combat
(
houyi
)
...
...
tftf.py
0 → 100644
View file @
aeb7c070
# a=int(input(5.2))
print
(
type
(
int
(
5.2
)))
# print(int(5.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