Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
bellcode
/
lesson2-4-1_DIY1
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
7f1fa142
authored
Aug 13, 2021
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
6c60e7d0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
12 deletions
test.py
test.py
View file @
7f1fa142
import
random
username
=
"白茹,李沛霖,李博"
userpassword
=
"312316,198401,195708"
while
True
:
name
=
input
(
"请输入用户名:"
)
password
=
input
(
"请输入密码:"
)
if
name
in
username
and
password
in
userpassword
:
break
print
(
"登录成功!"
)
if
name
!=
usernam
:
print
(
"用户名错误。"
)
if
password
!=
userpassword
:
print
(
"账号错误。"
)
player
=
input
(
"请出拳(石头/剪刀/布):"
)
print
(
"玩家出拳"
+
player
)
print
(
"欢迎来到famaly官网!---"
,
name
)
a
=
input
(
"你要玩什么游戏?英雄升级/猜拳游戏"
)
if
a
==
"英雄升级"
:
class
Hero
:
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
1
self
.
hp
=
hp
self
.
attack
=
attack
#
def
upgrad
(
self
):
self
.
level
=
yase
.
level
*
2
self
.
hp
=
yase
.
hp
*
2
self
.
attack
=
yase
.
attack
*
2
#
wudi
=
Hero
(
"无敌"
,
99999999999999999999999999999999999999999999999999999
,
9999999999999999999999999999999999999999999
)
yase
=
Hero
(
"亚瑟"
,
300
,
20
)
#
def
upgrad_yase
():
yase
.
level
=
yase
.
level
*
2
yase
.
hp
=
yase
.
hp
*
2
yase
.
attack
=
yase
.
attack
*
2
#
def
upgrad_wudi
():
wudi
.
level
=
wudi
.
level
*
2
wudi
.
hp
=
wudi
.
hp
*
2
wudi
.
attack
=
wudi
.
attack
*
2
input_name
=
input
(
"你要升级哪个英雄?无敌
\
亚瑟 "
)
c
=
input
(
"几级?"
)
#
if
input_name
==
"无敌"
:
for
i
in
range
(
int
(
c
)):
upgrad_wudi
()
print
(
"当前等级、血量、攻击力分别为:"
,
wudi
.
level
,
wudi
.
hp
,
wudi
.
attack
)
if
input_name
==
"亚瑟"
:
for
i
in
range
(
int
(
c
)):
upgrad_yase
()
print
(
"当前等级、血量、攻击力分别为:"
,
yase
.
level
,
yase
.
hp
,
yase
.
attack
)
# yase.upgrad()
# print("亚瑟的血量为",yase.hp)
list
=
[
"石头"
,
"剪刀"
,
"布"
]
computer
=
random
.
choice
(
list
)
print
(
"电脑出拳:"
+
computer
)
if
player
==
computer
:
print
(
"平局"
)
elif
(
player
==
"剪刀"
and
computer
==
"布"
)
or
(
player
==
"石头"
and
computer
==
"剪刀"
)
or
(
player
==
"布"
and
computer
==
"石头"
):
print
(
"恭喜你赢了!"
)
else
:
else
:
print
(
"很遗憾你输了"
)
import
random
while
True
:
player
=
input
(
"请出拳(石头/剪刀/布):a键退出。"
)
print
(
"玩家出拳"
+
player
)
list
=
[
"石头"
,
"剪刀"
,
"布"
]
computer
=
random
.
choice
(
list
)
print
(
"电脑出拳:"
+
computer
)
if
player
==
computer
:
print
(
"平局"
)
elif
(
player
==
"剪刀"
and
computer
==
"布"
)
or
(
player
==
"石头"
and
computer
==
"剪刀"
)
or
(
player
==
"布"
and
computer
==
"石头"
):
print
(
"恭喜你赢了!"
)
else
:
print
(
"很遗憾你输了"
)
if
player
==
"a"
:
print
(
"退出成功"
)
break
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