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
c28a2893
authored
Apr 01, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
1752bb84
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
7 deletions
diy1.py
diy1.py
View file @
c28a2893
...
@@ -5,7 +5,7 @@ class Hero(object):
...
@@ -5,7 +5,7 @@ class Hero(object):
self
.
hp
=
250
self
.
hp
=
250
self
.
attack
=
40
self
.
attack
=
40
self
.
name
=
name
self
.
name
=
name
def
combat
(
self
,
enemy
):
# 攻击
def
combat
(
self
,
enemy
):
# 攻击
m1
=
print
(
self
.
name
+
"对"
+
enemy
.
name
+
"发起攻击"
)
m1
=
print
(
self
.
name
+
"对"
+
enemy
.
name
+
"发起攻击"
)
m2
=
print
(
"并造成"
+
str
(
self
.
attack
)
+
"单位伤害"
)
m2
=
print
(
"并造成"
+
str
(
self
.
attack
)
+
"单位伤害"
)
...
@@ -17,14 +17,26 @@ class Hero(object):
...
@@ -17,14 +17,26 @@ class Hero(object):
m3
=
enemy
.
name
+
"已死亡"
m3
=
enemy
.
name
+
"已死亡"
print
(
m1
+
m2
+
m3
)
print
(
m1
+
m2
+
m3
)
yase
=
Hero
(
"垭瑟"
)
#yase = Hero("垭瑟")
class
Player
(
Hero
):
class
Player
(
Hero
):
def
__init__
(
self
,
name
):
def
__init__
(
self
,
name
,
herotype
):
super
()
.
__init__
(
name
)
super
()
.
__init__
(
name
)
self
.
hp
=
200
self
.
hp
=
200
self
.
attack
=
50
self
.
attack
=
50
self
.
herotype
=
herotype
print
(
"运行角色 OK,玩家"
+
self
.
name
+
" 已创建"
)
print
(
"当前血量/攻击值:"
+
str
(
self
.
hp
)
+
"/"
+
str
(
self
.
attack
)
+
"
\n
"
+
"- "
*
15
)
player
=
Player
(
"后羿"
)
print
(
"玩家血量值:"
,
player
.
hp
)
class
Cpt
(
Player
):
print
(
"玩家血量值:"
,
player
.
attack
)
def
__init__
(
self
,
name
,
herotype
):
\ No newline at end of file
super
()
.
__init__
(
name
,
herotype
)
self
.
herotype
=
herotype
print
(
"运行程序 OK,电脑"
+
self
.
name
+
" 已生成"
)
print
(
"设置血量/攻击值为 "
+
str
(
self
.
hp
)
+
"/"
+
str
(
self
.
attack
)
+
"
\n
"
+
"- "
*
15
)
player
=
Player
(
"后羿"
,
"射手"
)
computer
=
Cpt
(
"垭瑟"
,
"None"
)
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