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
8a0689fd
authored
Apr 18, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d79e649c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
7 deletions
diy1.py
diy1.py
View file @
8a0689fd
...
@@ -5,7 +5,7 @@ class Hero:
...
@@ -5,7 +5,7 @@ class Hero:
self
.
level
=
1
self
.
level
=
1
self
.
Name
=
name
self
.
Name
=
name
self
.
howCure
=
howCure
self
.
howCure
=
howCure
self
.
MaxH
p
=
hp
self
.
MaxH
P
=
hp
def
UpGrade
(
SB
):
def
UpGrade
(
SB
):
SB
.
level
+=
1
SB
.
level
+=
1
...
@@ -25,14 +25,14 @@ class Hero:
...
@@ -25,14 +25,14 @@ class Hero:
print
(
info1
+
info2
+
info3
)
print
(
info1
+
info2
+
info3
)
def
cure
(
self
):
def
cure
(
self
):
self
.
HP
+=
60
self
.
HP
+=
self
.
howCure
if
self
.
HP
>
self
.
MaxHP
:
if
self
.
HP
>
self
.
MaxHP
:
self
.
HP
=
MaxHP
self
.
HP
=
MaxHP
print
(
self
.
Name
,
"使用了治疗术,当前血量"
,
self
.
HP
)
class
Player
(
Hero
):
class
Player
(
Hero
):
def
__init__
(
self
,
hp
,
attack
,
name
,
type
,
howCure
):
def
__init__
(
self
,
hp
,
attack
,
name
,
type
,
howCure
):
super
()
.
__init__
(
hp
,
attack
,
name
)
super
()
.
__init__
(
hp
,
attack
,
name
,
howCure
)
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
)
...
@@ -42,6 +42,7 @@ class Player(Hero):
...
@@ -42,6 +42,7 @@ class Player(Hero):
player
=
Player
(
5000
,
250
,
"亚瑟"
,
"战士"
,
300
)
player
=
Player
(
5000
,
250
,
"亚瑟"
,
"战士"
,
300
)
computer
=
Hero
(
3000
,
400
,
"后羿"
,
"射手"
,
200
)
computer
=
Hero
(
3000
,
400
,
"后羿"
,
200
)
player
.
ComBot
(
computer
)
player
.
ComBot
(
computer
)
\ No newline at end of file
computer
.
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