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
3676c523
authored
Sep 01, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
cf284f16
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
6 deletions
diy2.py
diy2.py
View file @
3676c523
import
random
class
Hero
:
# 英雄类
class
Hero
:
# 英雄类
def
__init__
(
self
,
name
):
# 实例属性
def
__init__
(
self
,
name
):
# 实例属性
self
.
name
=
name
self
.
name
=
name
...
@@ -21,10 +23,13 @@ class Hero: # 英雄类
...
@@ -21,10 +23,13 @@ class Hero: # 英雄类
print
(
info
)
print
(
info
)
exit
()
exit
()
def
ziliao
(
self
,
ememy
):
def
ziliao
(
self
,
ememy
):
ememy
.
hp
=
ememy
.
hp
+
10
ememy
.
hp
=
ememy
.
hp
+
10
print
(
ememy
,
'回血成功!血量加10点'
)
print
(
str
(
ememy
.
name
),
'回血成功!血量加10点,目前血量:'
,
str
(
ememy
.
hp
))
def
pl_hp
(
self
,
ememy
):
return
int
(
ememy
.
hp
)
class
Player
(
Hero
):
# 玩家英雄
class
Player
(
Hero
):
# 玩家英雄
def
__init__
(
self
,
name
,
hp
,
attack
):
def
__init__
(
self
,
name
,
hp
,
attack
):
super
()
.
__init__
(
name
)
super
()
.
__init__
(
name
)
...
@@ -40,5 +45,6 @@ while True:
...
@@ -40,5 +45,6 @@ while True:
user_input
=
str
(
input
(
'请选择英雄技能(1:攻击,2:回血)'
))
user_input
=
str
(
input
(
'请选择英雄技能(1:攻击,2:回血)'
))
if
user_input
==
"1"
:
if
user_input
==
"1"
:
player1
.
combat
(
player2
)
player1
.
combat
(
player2
)
if
user_input
==
"2"
:
if
user_input
==
"2"
:
pass
player2
.
ziliao
(
player1
)
\ No newline at end of file
\ 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