Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson16_4
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
1c674b8c
authored
Jul 03, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
bb789f05
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
123 additions
and
0 deletions
1.py
1.py
0 → 100644
View file @
1c674b8c
import
random
class
Sans
:
def
__init__
(
self
,
AT
,
HP
,
HUP
,
AUP
,
name
,
MP
):
self
.
Level
=
1
self
.
HitPoint
=
HP
self
.
Attack
=
AT
self
.
HitPoint_UpPoint
=
HUP
self
.
Attack_UpPoint
=
AUP
self
.
Name
=
name
self
.
Max_HP
=
MP
def
Level_UP
(
Character
):
Character
.
Level
+=
1
Character
.
HitPoint
+=
0.5
*
Character
.
HitPoint_UpPoint
Character
.
Max_HP
+=
0.5
*
Character
.
HitPoint_UpPoint
Character
.
Attack
+=
0.25
*
Character
.
Attack_UpPoint
print
(
str
(
Character
.
Name
)
+
'升级了,现等级:'
+
str
(
Character
.
Level
))
def
combat
(
self
,
diren
):
# 攻击
diren
.
HitPoint
-=
self
.
Attack
DataA
=
str
(
self
.
Name
)
+
'发起攻击,'
DataB
=
str
(
diren
.
Name
)
+
'受到'
+
str
(
self
.
Attack
)
+
'点伤害,'
DataC
=
'现在'
+
str
(
diren
.
Name
)
+
'有'
+
str
(
diren
.
HitPoint
)
+
'滴血.'
if
diren
.
HitPoint
>=
0
:
print
(
DataA
+
DataB
+
DataC
)
if
diren
.
HitPoint
<=
0
:
print
(
str
(
diren
.
Name
)
+
'阵亡,游戏结束'
)
exit
()
def
Data_Check
(
Hero
):
print
(
Hero
.
Name
+
'的等级'
+
str
(
Hero
.
Level
)
+
'
\n
'
+
Hero
.
Name
+
'的血量'
+
str
(
Hero
.
HitPoint
)
+
'
\n
'
+
Hero
.
Name
+
'的攻击'
+
str
(
Hero
.
Attack
)
+
'
\n
'
+
Hero
.
Name
+
'的血量成长点'
+
str
(
Hero
.
HitPoint_UpPoint
)
+
'
\n
'
+
Hero
.
Name
+
'的攻击成长点'
+
str
(
Hero
.
Attack_UpPoint
)
+
'
\n
'
)
def
cure
(
plus
):
f
=
random
.
choice
([
20
,
30
,
40
,
50
,
60
])
plus
.
HitPoint
+=
f
print
(
plus
.
Name
+
'回血'
+
str
(
f
)
+
',现血量:'
+
str
(
plus
.
HitPoint
))
if
plus
.
HitPoint
>=
plus
.
Max_HP
:
plus
.
HitPoint
=
plus
.
Max_HP
class
Sanses
(
Sans
):
def
__init__
(
self
,
AT
,
HP
,
HUP
,
AUP
,
name
):
super
()
.
__init__
(
AT
,
HP
,
HUP
,
AUP
,
name
)
def
cure
(
plus
):
f
=
random
.
choice
([
60
])
plus
.
HitPoint
+=
f
print
(
plus
.
Name
+
'回血'
+
str
(
f
)
+
',现血量:'
+
str
(
plus
.
HitPoint
))
if
plus
.
HitPoint
>=
plus
.
Max_HP
:
plus
.
HitPoint
=
plus
.
Max_HP
Outer
=
Sans
(
30
,
200
,
20
,
20
,
'Outer!Sans'
,
200
)
Mudder
=
Sans
(
20
,
350
,
18
,
16
,
'Mudder!Sans'
,
350
)
while
True
:
choose
=
input
(
'玩家选英雄(a.Outer/b.Mudder):'
)
if
choose
==
'Outer'
or
choose
==
'a'
:
Player1
=
Outer
break
print
(
'-'
*
60
)
if
choose
==
'Mudder'
or
choose
==
'a'
:
Player1
=
Mudder
break
print
(
'-'
*
60
)
else
:
print
(
'请重新选择'
)
continue
while
True
:
choose1
=
input
(
'为电脑选英雄(a.Outer/b.Mudder):'
)
if
choose1
==
'Outer'
or
choose1
==
'a'
:
Player2
=
Outer
break
print
(
'-'
*
60
)
if
choose1
==
'Mudder'
or
choose1
==
'b'
:
Player2
=
Mudder
break
print
(
'-'
*
60
)
else
:
print
(
'请重新选择'
)
continue
print
(
'-'
*
60
)
print
(
'游戏开始'
)
print
(
'-'
*
60
)
PVN
=
1
while
True
:
print
(
'第'
+
str
(
PVN
)
+
'回合'
)
if
PVN
!=
0
and
PVN
%
3
==
0
:
Player1
.
Level_UP
()
print
(
'玩家升级了'
)
while
True
:
a
=
input
(
'请行动(1·治疗/2·攻击/3·查看/4·退出):'
)
if
a
==
'1'
:
Player1
.
cure
()
print
(
'-'
*
60
)
break
if
a
==
'2'
:
Player1
.
combat
(
Player2
)
print
(
'-'
*
60
)
break
if
a
==
'3'
:
Player1
.
Data_Check
()
if
a
==
'4'
:
exit
()
else
:
print
(
'无效的输入'
)
continue
b
=
str
(
random
.
choice
([
1
,
2
]))
if
PVN
!=
0
and
PVN
%
3
==
0
:
Player2
.
Level_UP
()
print
(
'电脑升级了'
)
if
b
==
'1'
:
Player2
.
cure
()
print
(
'-'
*
60
)
if
b
==
'2'
:
Player2
.
combat
(
Player1
)
print
(
'-'
*
60
)
PVN
+=
1
\ 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