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
ac4bf4bb
authored
Feb 03, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
9a581ef4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
0 deletions
p.py
p.py
0 → 100644
View file @
ac4bf4bb
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
,
defense
):
self
.
level
=
1
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
self
.
defense
=
defense
# self.speed = speed
# self.SA = SA
# self.SD = SD
# ,speed,SA,SD,skill
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
if
enemy
.
hp
>
0
:
info3
=
enemy
.
name
+
'剩余'
+
str
(
enemy
.
hp
)
+
'血量!'
info
=
info1
+
info2
+
info3
print
(
info
)
else
:
info3
=
enemy
.
name
+
'的hp不足,进入濒死状态'
+
self
.
name
+
'胜利'
a
=
Hero
(
'亚瑟'
,
300
,
25
,
30
)
b
=
Hero
(
'后羿'
,
250
,
30
,
25
)
a
.
combat
(
b
)
# a = Pokemon('妙蛙种子',45,49,49,45,65,65,'寄生种子')
# b = Pokemon('小火龙',39,52,43,65,60,50,'火花')
# c = Pokemon('杰尼龟',44,48,65,50,64,43,'水沫')
# a.upgrade()
# b.upgrade()
# c.upgrade()
# def upgrade(self):
# self.level = self.level+1
# self.hp = self.hp+self.hp*0.3
# self.attack = self.attack+self.attack*0.2
# self.defense = self.defense+self.defense*0.2
# self.speed = self.speed+self.speed*0.2
# self.SA = self.SA+self.SA*0.3
# self.SD = self.SD+self.SD*0.3
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