Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_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
7401c108
authored
May 18, 2024
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
8438c271
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
14 deletions
diy.py
diy.py
View file @
7401c108
class
hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
class
hero
(
object
)
:
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
name
self
.
attack
=
attack
self
.
hp
=
3500
self
.
attack
=
388
self
.
name
=
name
def
upgrade
():
yase
.
level
=
yase
.
level
+
1
yase
.
hp
=
yase
.
hp
+
50
yase
.
attack
=
yase
.
attack
+
4
def
combat
(
self
,
enemy
):
enemy
.
hp
-=
self
.
attack
info1
=
self
.
name
+
'对'
+
enemy
.
name
+
'发起伤害,'
info2
=
'造成'
+
str
(
self
.
attack
)
+
'真实伤害,'
if
enemy
.
hp
<
0
:
info3
=
enemy
.
name
+
'阵亡'
else
:
info3
=
enemy
.
name
+
'还剩下'
+
str
(
enemy
.
hp
)
+
'点生命值'
print
(
info1
+
info2
+
info3
)
yase
=
Hero
(
"垭瑟"
,
300
,
20
)
print
(
"垭瑟的初始血量值为:"
,
yase
.
hp
)
upgrade
()
upgrade
()
print
(
"升级2次后,垭瑟的血量值为:"
yase
.
hp
)
\ No newline at end of file
class
player
(
help
):
def_init_
(
self
,
Name
,
help_type
):
self
.
hp
=
200
self
.
attack
=
50
self
.
help_type
=
help_type
print
(
"角色"
+
self
.
name
+
"创建成功,英雄类型为:"
,
self
.
hero_type
)
print
(
"当前等级血量攻击力分别为"
,
self
.
level
,
self
.
hp
,
self
.
attack
)
yase
=
Hero
(
"垭瑟"
)
houyi
=
Hero
(
"后羿"
)
yase
.
combat
(
houyi
)
print
(
"玩家的血量值为"
,
player
.
hp
)
print
(
"玩家的血量值为"
,
player
.
attack
)
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