Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_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
2d176c62
authored
Feb 03, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
ac4bf4bb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
p.py
p.py
View file @
2d176c62
...
...
@@ -13,8 +13,8 @@ class Hero:
def
combat
(
self
,
enemy
):
enemy
.
hp
-
self
.
attack
info1
=
self
.
name
+
'对'
+
enemy
.
name
+
'发动了抓击!'
info2
=
enemy
.
name
+
'收到了'
+
str
(
self
.
attack
-
enemy
.
defense
*
0.2
)
+
'点伤害!
'
enemy
.
hp
-=
self
.
attack
-
enemy
.
defense
*
0.2
info2
=
enemy
.
name
+
'收到了'
+
str
(
self
.
attack
)
+
'点伤害!'
+
'防御减免'
+
str
(
enemy
.
defense
*
0.2
)
+
'点伤害。
'
enemy
.
hp
=
enemy
.
hp
-
self
.
attack
+
enemy
.
defense
*
0.2
if
enemy
.
hp
>
0
:
info3
=
enemy
.
name
+
'剩余'
+
str
(
enemy
.
hp
)
+
'血量!'
info
=
info1
+
info2
+
info3
...
...
@@ -26,6 +26,16 @@ b = Hero('后羿',250,30,25)
a
.
combat
(
b
)
class
Player
(
Hero
):
def
__init__
(
self
,
name
,
hp
,
attack
,
defense
):
super
()
.
__init__
(
name
,
hp
,
attack
,
defense
)
self
.
hp
=
250
self
.
attack
=
30
self
.
defense
=
25
player
=
Player
(
'后羿'
,
250
,
30
,
25
)
print
(
'玩家的血量值为'
+
str
(
player
.
hp
))
print
(
'玩家的攻击力为'
+
str
(
player
.
attack
))
print
(
'玩家的防御值为'
+
str
(
player
.
defense
))
# a = Pokemon('妙蛙种子',45,49,49,45,65,65,'寄生种子')
# b = Pokemon('小火龙',39,52,43,65,60,50,'火花')
...
...
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