Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_2_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
a1a1a342
authored
Oct 23, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
ad5dee88
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
11 deletions
diy2.py
diy2.py
View file @
a1a1a342
import
random
class
Hero
:
class
Hero
:
def
__init__
(
self
,
name
,
herotype
):
def
__init__
(
self
,
name
,
herotype
):
self
.
name
=
name
self
.
name
=
name
...
@@ -28,20 +30,32 @@ class Hero:
...
@@ -28,20 +30,32 @@ class Hero:
print
(
info
)
print
(
info
)
exit
()
exit
()
class
Player
(
Hero
):
class
Player
(
Hero
):
def
__init__
()
def
__init__
(
self
,
name
,
herotype
):
super
()
.
__init__
(
name
,
herotype
)
self
.
hp
=
200
self
.
attack
=
80
self
.
max_hp
=
self
.
hp
print
(
"英雄:"
+
self
.
name
+
"创建成功,"
+
"
\n
英雄类型:"
+
self
.
herotype
+
"
\n
攻击力:"
+
str
(
self
.
attack
))
yase
=
Hero
(
"亚瑟"
,
"坦克"
)
yase
=
Hero
(
"亚瑟"
,
"坦克"
)
houyi
=
Hero
(
"后羿"
,
"射手"
)
houyi
=
Player
(
"后羿"
,
"射手"
)
print
(
"-"
*
30
)
print
(
"-"
*
30
)
print
(
" 战斗开始"
)
print
(
" 战斗开始"
)
print
(
"-"
*
30
)
print
(
"-"
*
30
)
while
True
:
while
True
:
satute
=
int
(
input
(
"请选择英雄技能(1攻击/2治疗):"
))
satute
=
input
(
"请选择英雄技能(1攻击/2治疗):"
)
if
satute
==
1
:
if
satute
==
"q"
:
print
(
"用户选择退出"
)
if
satute
==
2
:
break
elif
satute
==
"1"
:
houyi
.
combat
(
yase
)
elif
satute
==
"2"
:
houyi
.
cure
()
else
:
print
(
"请输入正确指令"
)
continue
computer
=
random
.
randint
(
1
,
3
)
if
computer
==
1
or
2
:
yase
.
combat
(
houyi
)
elif
computer
==
3
:
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