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
6a90ca8e
authored
Apr 02, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
d410c2f7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
4 deletions
1.py/1.py
diy1.py
1.py/1.py
0 → 100644
View file @
6a90ca8e
class
Hero
(
object
):
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
250
self
.
attack
=
50
self
.
name
=
name
\ No newline at end of file
diy1.py
View file @
6a90ca8e
# 英雄角色类
import
random
class
Hero
(
object
):
def
__init__
(
self
,
name
):
self
.
level
=
1
self
.
hp
=
250
self
.
attack
=
40
self
.
hp
=
random
.
randint
(
300
,
1000
)
self
.
attack
=
random
.
randint
(
50
,
100
)
self
.
name
=
name
def
combat
(
self
,
enemy
):
def
combat
(
self
,
duifang
):
duifang
.
hp
=
duifang
.
hp
-
self
.
attack
info1
=
self
.
name
+
'攻击了'
+
duifang
.
name
info2
=
duifang
.
name
+
'减少了'
+
str
(
self
.
attack
)
+
'点血量'
...
...
@@ -16,10 +17,25 @@ class Hero(object):
info
=
info1
+
info2
+
info3
print
(
info
)
else
:
info3
=
duifang
.
name
+
'去世
,拜拜了
'
info3
=
duifang
.
name
+
'去世
了,您本次扣除段位分'
+
str
(
random
.
randint
(
10
,
50
))
+
'分
'
info
=
info1
+
info2
+
info3
print
(
info
)
a
=
[
'普通'
,
'神话'
,
'史诗'
]
class
pleyer
(
Hero
):
def
__init__
(
self
,
name
,
attack
,
hp
,
typ
):
super
()
.
__init__
(
name
)
self
.
hp
=
hp
self
.
attack
=
attack
self
.
typ
=
typ
print
(
self
.
name
+
'角色创建成功'
+
'本角色为'
+
random
.
choice
(
a
)
+
'等级'
)
print
(
'本角色血量,攻击力,名字,身份为'
+
str
(
self
.
hp
)
+
','
+
str
(
self
.
attack
)
+
','
+
self
.
name
+
','
+
self
.
typ
)
sabi
=
pleyer
(
'sabi'
,
1
,
10
,
'丐帮帮主'
)
李锦隆
=
pleyer
(
'李锦隆'
,
70
,
300
,
'刺客'
)
yase
=
Hero
(
"垭瑟"
)
houyi
=
Hero
(
"后羿"
)
yase
.
combat
(
houyi
)
yase
.
combat
(
houyi
)
yase
.
combat
(
houyi
)
yase
.
combat
(
houyi
)
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