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
d79e649c
authored
Apr 18, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
ef8c9b34
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
4 deletions
diy1.py
diy1.py
View file @
d79e649c
class
Hero
:
class
Hero
:
def
__init__
(
self
,
hp
,
attack
,
name
):
def
__init__
(
self
,
hp
,
attack
,
name
,
howCure
):
self
.
HP
=
hp
self
.
HP
=
hp
self
.
Attack
=
attack
self
.
Attack
=
attack
self
.
level
=
1
self
.
level
=
1
self
.
Name
=
name
self
.
Name
=
name
self
.
howCure
=
howCure
self
.
MaxHp
=
hp
def
UpGrade
(
SB
):
def
UpGrade
(
SB
):
SB
.
level
+=
1
SB
.
level
+=
1
...
@@ -22,17 +24,24 @@ class Hero:
...
@@ -22,17 +24,24 @@ class Hero:
exit
()
exit
()
print
(
info1
+
info2
+
info3
)
print
(
info1
+
info2
+
info3
)
def
cure
(
self
):
self
.
HP
+=
60
if
self
.
HP
>
self
.
MaxHP
:
self
.
HP
=
MaxHP
class
Player
(
Hero
):
class
Player
(
Hero
):
def
__init__
(
self
,
hp
,
attack
,
name
,
type
):
def
__init__
(
self
,
hp
,
attack
,
name
,
type
,
howCure
):
super
()
.
__init__
(
hp
,
attack
,
name
)
super
()
.
__init__
(
hp
,
attack
,
name
)
self
.
type
=
type
self
.
type
=
type
self
.
howCure
=
howCure
print
(
"玩家创建成功 姓名:"
,
self
.
Name
)
print
(
"玩家创建成功 姓名:"
,
self
.
Name
)
print
(
"玩家创建成功 血量:"
,
self
.
HP
)
print
(
"玩家创建成功 血量:"
,
self
.
HP
)
print
(
"玩家创建成功 攻击力:"
,
self
.
Attack
)
print
(
"玩家创建成功 攻击力:"
,
self
.
Attack
)
print
(
"玩家创建成功 职业:"
,
self
.
type
)
print
(
"玩家创建成功 职业:"
,
self
.
type
)
print
(
"玩家创建成功 治疗量:"
,
self
.
howCure
)
player
=
Player
(
5000
,
250
,
"亚瑟"
,
"战士"
)
computer
=
Hero
(
3000
,
400
,
"后羿"
,
"射手"
)
player
=
Player
(
5000
,
250
,
"亚瑟"
,
"战士"
,
300
)
computer
=
Hero
(
3000
,
400
,
"后羿"
,
"射手"
,
200
)
player
.
ComBot
(
computer
)
player
.
ComBot
(
computer
)
\ 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