Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_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
03135a36
authored
Apr 15, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
cd80437c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
18 deletions
diy2.py
diy2.py
View file @
03135a36
import
random
class
Hero
:
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
1
self
.
level
=
1
...
@@ -15,28 +16,41 @@ class Hero:
...
@@ -15,28 +16,41 @@ class Hero:
if
self
.
hp
>
self
.
maxhp
:
if
self
.
hp
>
self
.
maxhp
:
self
.
hp
=
self
.
maxhp
self
.
hp
=
self
.
maxhp
print
(
'加60血,,'
,
self
.
hp
)
print
(
'加60血,,'
,
self
.
hp
)
a
=
Hero
(
'yase'
,
300
,
20
)
class
Player
(
Hero
):
print
(
a
.
attack
)
def
__init__
(
self
,
name
,
hp
,
attack
):
a
.
e
()
super
()
.
__init__
(
name
,
hp
,
attack
)
a
.
e
()
#self.hp=250
print
(
a
.
attack
)
#self.attack=50
d
=
Hero
(
'hy'
,
250
,
23
)
#self.maxhp=self.hp
print
(
d
.
attack
)
# a.e()
d
.
e
()
# a.e()
d
.
e
()
# print(a.attack)
print
(
d
.
attack
)
# d=Hero('hy',250,23)
# print(d.attack)
# d.e()
# d.e()
# print(d.attack)
c
=
Hero
(
'K'
,
5600
,
199
)
# c=Hero('K',5600,199)
print
(
c
.
attack
)
# print(c.attack)
c
.
e
()
# c.e()
c
.
e
()
# c.e()
c
.
s
()
# c.s()
print
(
c
.
attack
)
# print(c.attack)
c
=
Player
(
'K'
,
250
,
30
)
d
=
Hero
(
'hy'
,
250
,
23
)
print
(
30
*
'-'
)
print
(
30
*
'-'
)
print
(
' 战斗开始'
)
print
(
' 战斗开始'
)
while
True
:
while
True
:
print
(
30
*
'-'
)
print
(
30
*
'-'
)
ww
=
input
(
'技能1|2'
)
ww
=
input
(
'技能1|2'
)
if
ww
==
'1'
:
c
.
e
()
elif
ww
==
'2'
:
c
.
s
()
xxs
=
random
.
randint
(
1
,
2
)
if
xxs
==
'1'
:
d
.
e
()
elif
xxs
==
'2'
:
d
.
s
()
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