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
55fbbb8d
authored
Oct 29, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
dfb5d1b6
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
diy2.py
diy2.py
0 → 100644
View file @
55fbbb8d
class
country
:
def
__init__
(
self
,
name
,
hp
,
attack
):
self
.
level
=
1
self
.
name
=
name
self
.
hp
=
hp
self
.
attack
=
attack
def
upgrade
(
self
):
if
self
.
name
==
"德意志国"
:
self
.
level
+=
1
self
.
hp
+=
30
self
.
attack
+=
12
if
self
.
name
==
"Soviet Union"
:
self
.
level
+=
1
self
.
hp
+=
45
self
.
attack
+=
6
if
self
.
level
==
10
:
self
.
level
+=
1
self
.
hp
-=
20
self
.
attack
+=
100
def
combat
(
self
,
enemy
):
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起进攻"
info2
=
"歼灭"
+
str
(
self
.
attack
)
+
"支部队"
enemy
.
hp
-=
self
.
attack
if
enemy
.
hp
>
0
:
info3
=
enemy
.
name
+
"还剩下"
+
str
(
enemy
.
hp
)
+
"支部队"
info
=
info1
+
info2
+
info3
print
(
info
)
else
:
info3
=
"和平! "
+
enemy
.
name
+
"被"
+
self
.
name
+
"傀儡"
info
=
info1
+
info2
+
info3
print
(
info
)
class
player
(
country
):
def
__init__
(
self
,
name
,
hp
,
attack
):
super
(
player
,
self
)
.
__init__
(
name
)
self
.
level
=
1
self
.
hp
=
hp
self
.
attack
=
attack
self
.
party_type
=
"德意志民族社会主义工人党(法西斯主义)"
self
.
army_type
=
"机动作战学说"
self
.
airforce_type
=
"战场支援学说"
print
(
"国家"
+
player
.
name
+
"作战指挥连接成功,国家政党为"
+
self
.
party_type
+
"陆军学说为"
+
self
.
army_type
+
"空军学说为"
+
self
.
airforce_type
)
print
(
"当前军队level,hp,attack分别为"
,
self
.
level
,
self
.
hp
,
self
.
attack
)
player
=
player
(
"德意志国"
,
350
,
50
)
ger
=
country
(
"德意志国"
,
350
,
50
)
sov
=
country
(
"Soviet Union"
,
600
,
20
)
ger
.
upgrade
()
print
(
player
.
hp
)
print
(
sov
.
hp
)
player
.
combat
(
sov
)
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