Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_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
72002e78
authored
May 29, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
bf0c6f97
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
2 deletions
diy2.py
diy2.py
View file @
72002e78
import
random
class
Hero
:
class
Hero
:
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
level
=
1
...
@@ -26,12 +27,13 @@ class Hero:
...
@@ -26,12 +27,13 @@ class Hero:
class
Player
(
Hero
):
class
Player
(
Hero
):
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
,
hero_type
):
super
()
.
__init__
(
name
)
super
()
.
__init__
(
name
)
self
.
hp
=
190
self
.
hp
=
190
self
.
attack
=
70
self
.
attack
=
70
self
.
maxhp
=
self
.
hp
self
.
maxhp
=
self
.
hp
print
(
'角色'
+
self
.
name
+
'创建成功,英雄类型为:'
,
self
.
hero_tape
)
self
.
hero_type
=
hero_type
print
(
'角色'
+
self
.
name
+
'创建成功,英雄类型为:'
,
self
.
hero_type
)
print
(
'当前等级,血量,攻击力为:'
,
self
.
level
,
self
.
hp
,
self
.
att
)
print
(
'当前等级,血量,攻击力为:'
,
self
.
level
,
self
.
hp
,
self
.
att
)
player
=
Player
(
'后羿'
)
player
=
Player
(
'后羿'
)
...
@@ -42,3 +44,21 @@ player=Player('后羿')
...
@@ -42,3 +44,21 @@ player=Player('后羿')
yase
=
Hero
(
'亚瑟'
)
yase
=
Hero
(
'亚瑟'
)
houyi
=
Hero
(
'后羿'
)
houyi
=
Hero
(
'后羿'
)
while
True
:
print
(
30
*
'-'
)
choice
=
input
(
'1攻击,2治疗,q退出'
)
if
choice
==
'q'
:
print
(
'游戏结束'
)
break
elif
choice
==
'1'
:
houyi
.
combat
(
yase
)
elif
choice
==
'2'
:
houyi
.
cure
()
else
:
print
(
'输入1、2、q'
)
continue
num
=
random
.
randint
(
1
,
3
)
if
num
==
1
:
yase
.
cure
()
else
:
yas
.
combat
(
houyi
)
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