Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson12-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
9fe9d09d
authored
Jun 04, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
b949b556
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16404 additions
and
81 deletions
kii.py/j.py
kii.py/j.py
View file @
9fe9d09d
import
random
import
pygame
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
,
max_hp
):
pygame
.
init
()
self
.
level
=
1
self
.
name
=
name
screen
=
pygame
.
display
.
set_mode
((
600
,
800
))
self
.
hp
=
hp
self
.
attack
=
attack
screen
.
done
()
self
.
max_hp
=
self
.
hp
def
combat
(
self
,
enmey
):
info1
=
self
.
name
+
'对'
+
enmey
.
name
+
'发起进攻,'
info2
=
'造成'
+
self
.
attack
+
'点伤害,'
enmey
.
hp
-=
self
.
attack
if
enmey
.
hp
>
0
:
info3
=
enmey
.
name
+
'还剩下'
+
enmey
.
hp
+
'点生命值'
info
=
info1
+
info2
+
info3
print
(
info
)
else
:
info3
=
enmey
.
name
+
'阵亡,游戏结束'
info
=
info1
+
info2
+
info3
print
(
info
)
exit
()
def
cure
(
self
):
self
.
hp
=
self
.
hp
+
60
if
self
.
hp
>
self
.
max_hp
:
self
.
hp
=
self
.
max_hp
class
Player
(
Hero
):
def
__init__
(
self
,
name
,
hero_type
):
super
(
Player
,
self
)
.
__init__
(
name
)
self
.
hp
=
200
self
.
attack
=
50
self
.
hero_type
=
hero_type
print
(
'角色'
+
self
.
name
+
'已经创建'
,
'英雄类型为'
+
self
.
hero_type
)
print
(
'当前等级,血量,攻击力为'
+
self
.
name
+
self
.
attack
)
def
cure
(
self
):
hp
=
random
.
randint
(
0
,
3
)
player
=
Player
(
'后羿'
,
'射手'
)
yase
=
Hero
(
'亚瑟'
)
print
(
'-'
*
30
)
print
(
' 战斗开始!'
)
while
True
:
print
(
'-'
*
30
)
a
=
input
(
'请输入技能(1攻击/2治疗)'
)
if
a
==
'q'
:
print
(
'游戏结束'
)
break
elif
a
==
'1'
:
player
.
combat
(
yase
)
elif
a
==
'2'
:
player
.
cure
()
else
:
print
(
'请重新输入'
)
continue
enmey
.
choice
=
random
.
randint
(
1
,
3
)
if
enmey
.
choice
==
'1'
:
player
.
cure
()
else
:
player
.
combat
(
yase
)
#def upgrade(self):
#self.level = self.level+1
#self.hp = self.hp+50
#self.attack = self.attack
#yase = Hero('亚瑟',300,20)
#yase.upgrade()
\ No newline at end of file
凄凄切切群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群群
00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333
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