Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson14_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
55732b82
authored
Jul 30, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
8f38a15e
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
135 additions
and
1 deletions
diy2.py
diy2.py
View file @
55732b82
#~ 洪荒 ~ 源码
#~ 洪荒 ~ 源码
import
random
x
=
0
n
=
0
player
=
[
'太上老君'
,
'玉皇大帝'
,
'东皇太一'
,
'妲己'
]
class
Hero
:
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
1
self
.
level
=
1
...
@@ -13,6 +17,111 @@ class Hero:
...
@@ -13,6 +17,111 @@ class Hero:
self
.
level
=
self
.
level
+
1
self
.
level
=
self
.
level
+
1
self
.
hp
=
self
.
hp
+
110
self
.
hp
=
self
.
hp
+
110
self
.
attack
=
self
.
attack
+
10
self
.
attack
=
self
.
attack
+
10
def
register
():
answer
=
input
(
'登录游戏请按q'
)
while
True
:
if
answer
==
'q'
:
n
=
1
return
n
break
# if answer == 'w':
n
=
2
return
n
break
if
answer
!=
'q'
:
n
=
3
return
n
break
def
look
():
while
True
:
y
=
input
(
'输入角色名可查看属性(按q退出)'
)
if
y
==
'q'
:
break
else
:
if
y
==
'太上老君'
:
print
(
'太上老君:'
+
'基础生命值:'
+
str
(
TSLJ
.
hp
)
+
' '
+
'基础攻击力:'
+
str
(
TSLJ
.
attack
))
else
:
if
y
==
'玉皇大帝'
:
print
(
'玉皇大帝:'
+
'基础生命值:'
+
str
(
YHDD
.
hp
)
+
' '
+
'基础攻击力:'
+
str
(
YHDD
.
attack
))
else
:
if
y
==
'东皇太一'
:
print
(
'东皇太一:'
+
'基础生命值:'
+
str
(
DHTY
.
hp
)
+
' '
+
'基础攻击力:'
+
str
(
DHTY
.
attack
))
else
:
if
y
==
'妲己'
:
print
(
'妲己:'
+
'基础生命值:'
+
str
(
DJ
.
hp
)
+
' '
+
'基础攻击力:'
+
str
(
DJ
.
attack
))
else
:
if
y
==
'天道鸿钧'
:
print
(
'天道鸿钧:'
+
'基础生命值:'
+
str
(
TDHJ
.
hp
)
+
' '
+
'基础攻击力:'
+
str
(
TDHJ
.
attack
))
else
:
print
(
'输入错误,未查询到该角色'
)
def
choose_player
():
while
True
:
y
=
input
(
'请选择你的角色'
)
if
y
==
'878652'
:
print
(
'哦?奇怪'
)
else
:
if
y
==
'太上老君'
:
print
(
'太上老君'
+
' '
+
'已选择'
)
y
=
TSLJ
return
y
else
:
if
y
==
'玉皇大帝'
:
print
(
'玉皇大帝'
+
' '
+
'已选择'
)
y
=
YHDD
return
y
else
:
if
y
==
'东皇太一'
:
print
(
'东皇太一'
+
' '
+
'已选择'
)
y
=
DHTY
return
y
else
:
if
y
==
'妲己'
:
print
(
'妲己'
+
' '
+
'已选择'
)
y
=
DJ
return
y
else
:
if
y
==
'天道鸿钧'
:
print
(
'天道鸿钧'
+
' '
+
'已选择'
)
y
=
TDHJ
return
y
else
:
print
(
'输入错误,未查询到该角色'
)
def
fight
():
z
=
random
.
randint
(
1
,
2
)
if
z
==
1
:
print
(
'****************************************'
)
n
=
1
print
(
'玩家1 先手!'
)
print
(
'****************************************'
)
if
z
==
2
:
print
(
'****************************************'
)
n
=
2
print
(
'玩家2 先手!'
)
print
(
'****************************************'
)
while
True
:
if
game_player1
.
hp
<
1
:
print
(
'玩家2 获胜!'
)
break
if
game_player2
.
hp
<
1
:
print
(
'玩家1 获胜!'
)
break
print
(
game_player1
.
name
+
' '
+
game_player2
.
name
)
j
=
input
(
'请使用技能!(1:普攻 2:二技能 3:三技能)'
)
if
j
==
str
(
1
):
if
n
%
2
==
0
:
game_player1
.
hp
=
game_player1
.
hp
-
game_player2
.
attack
print
(
game_player2
.
name
+
' '
+
'对'
+
game_player1
.
name
+
' '
+
'使用了普攻'
+
' 造成了'
+
str
(
game_player2
.
attack
)
+
'点伤害!'
)
print
(
game_player1
.
name
+
' 余剩生命'
+
str
(
game_player1
.
hp
)
+
'点,'
+
game_player2
.
name
+
' 余剩生命'
+
str
(
game_player2
.
hp
)
+
'点'
)
print
(
'****************************************'
)
n
=
n
+
1
continue
if
n
%
2
!=
0
:
game_player2
.
hp
=
game_player2
.
hp
-
game_player1
.
attack
print
(
game_player1
.
name
+
' '
+
'对'
+
game_player2
.
name
+
' '
+
'使用了普攻'
+
' 造成了'
+
str
(
game_player1
.
attack
)
+
'点伤害!'
)
print
(
game_player1
.
name
+
' 余剩生命'
+
str
(
game_player1
.
hp
)
+
'点,'
+
game_player2
.
name
+
' 余剩生命'
+
str
(
game_player2
.
hp
)
+
'点'
)
print
(
'****************************************'
)
n
=
n
+
1
continue
#仙人阵营
#仙人阵营
TSLJ
=
Hero
(
'太上老君'
,
500
,
35
)
TSLJ
=
Hero
(
'太上老君'
,
500
,
35
)
YHDD
=
Hero
(
'玉皇大帝'
,
450
,
45
)
YHDD
=
Hero
(
'玉皇大帝'
,
450
,
45
)
...
@@ -20,4 +129,28 @@ YHDD = Hero('玉皇大帝',450,45)
...
@@ -20,4 +129,28 @@ YHDD = Hero('玉皇大帝',450,45)
DHTY
=
Hero
(
'东皇太一'
,
700
,
20
)
DHTY
=
Hero
(
'东皇太一'
,
700
,
20
)
DJ
=
Hero
(
'妲己'
,
200
,
55
)
DJ
=
Hero
(
'妲己'
,
200
,
55
)
#作弊隐藏角色(慎用)
#作弊隐藏角色(慎用)
TDHJ
=
Hero
(
'天道鸿钧'
,
99999999999
,
9999999999
)
TDHJ
=
Hero
(
'天道鸿钧'
,
9999999999999999999
,
99999999999999999999999
)
#登录界面
x
=
register
()
if
x
==
3
:
register
()
#功能不完善,暂时屏蔽
#if x == 2:
# print('正在注册账号')
# with open(r'D:\洪荒\game_player.txt','a',encoding = 'utf-8') as file:
# user = input('请输入用户名')
# file.write(user)
if
x
==
1
:
print
(
'正在登录账号'
)
#选择角色
print
(
'可选择的角色有'
)
for
i
in
player
:
print
(
i
,
end
=
' '
)
print
(
''
)
look
()
b
=
choose_player
()
game_player1
=
b
look
()
b
=
choose_player
()
game_player2
=
b
fight
()
\ 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