Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson15_3
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
05344d1f
authored
Sep 08, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
67966cb5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
5 deletions
diy3.py
diy3.py
View file @
05344d1f
import
random
import
random
name_log
=
[]
co_log
=
{}
hp_log
=
[]
log
=
{}
class
yx
:
class
yx
:
def
__init__
(
self
,
name
,
hp
,
lv
):
def
__init__
(
self
,
name
,
hp
,
lv
):
self
.
name
=
name
self
.
name
=
name
self
.
lv
=
lv
self
.
lv
=
lv
self
.
hp
=
hp
self
.
hp
=
hp
self
.
att
=
random
.
randint
(
1
,
200
)
self
.
att
=
random
.
randint
(
1
,
200
)
self
.
num
=
0
print
(
'角色'
,
str
(
self
.
name
),
'创建成功!血量:'
,
str
(
self
.
hp
),
'攻击力:'
,
str
(
self
.
att
),
'等级:'
,
str
(
self
.
lv
))
print
(
'角色'
,
str
(
self
.
name
),
'创建成功!血量:'
,
str
(
self
.
hp
),
'攻击力:'
,
str
(
self
.
att
),
'等级:'
,
str
(
self
.
lv
))
def
combat
(
self
,
name
):
def
combat
(
self
,
name
):
name
.
hp
=
name
.
hp
-
self
.
att
name
.
hp
=
name
.
hp
-
self
.
att
print
(
str
(
self
.
name
),
'向'
,
str
(
name
.
name
),
'使用了'
,
str
(
self
.
att
),
'点伤害,'
,
str
(
name
.
name
),
'还剩'
,
str
(
name
.
hp
),
'点血量'
)
print
(
str
(
self
.
name
),
'向'
,
str
(
name
.
name
),
'使用了'
,
str
(
self
.
att
),
'点伤害,'
,
str
(
name
.
name
),
'还剩'
,
str
(
name
.
hp
),
'点血量'
)
co_log
[
"发起攻击"
]
=
self
.
name
co_log
[
"受到攻击"
]
=
name
.
name
co_log
[
"伤害点数"
]
=
self
.
att
co_log
[
"剩余点数"
]
=
name
.
hp
log
[
self
.
num
]
=
co_log
self
.
num
=
self
.
num
+
1
a
=
yx
(
'a'
,
200
,
1
)
a
=
yx
(
'a'
,
200
,
1
)
b
=
yx
(
'b'
,
2000
,
1
)
b
=
yx
(
'b'
,
3000
,
1
)
a
.
combat
(
b
)
while
True
:
\ No newline at end of file
if
input
(
"请输入指令:"
)
==
"1"
:
a
.
combat
(
b
)
else
:
print
(
"无效的字符数!"
)
if
int
(
b
.
hp
)
<
0
:
print
(
'游戏结束!'
)
print
(
log
)
break
\ No newline at end of file
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