Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson16_2
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
82909317
authored
Oct 29, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
e47cb26d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
0 deletions
diy1.py
diy1.py
0 → 100644
View file @
82909317
class
country
:
def
__init__
(
self
,
name
,
hp
,
attack
,
population
):
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
==
"苏维埃联盟"
:
self
.
level
+=
1
self
.
hp
+=
45
self
.
attack
+=
6
if
self
.
level
==
10
:
self
.
level
+=
1
self
.
hp
-=
20
self
.
attack
+=
100
def
Conscription
(
self
):
if
self
.
population
>=
50
:
print
(
self
.
name
+
"重整并征召了部队,征召"
,
50
,
"部队,目前还剩"
,
self
.
hp
,
"支部队"
)
self
.
hp
+=
50
self
.
population
-=
50
else
:
print
(
self
.
name
,
"无法征召人员"
,
"重整部队"
)
self
.
hp
+=
5
def
combat
(
self
,
enemy
):
info1
=
self
.
name
+
"对"
+
enemy
.
name
+
"发起进攻"
if
self
.
name
==
"德意志国"
and
self
.
level
<=
5
:
info2
=
"歼灭"
+
str
(
self
.
attack
+
20
)
+
"支部队"
else
:
info2
=
"歼灭"
+
str
(
self
.
attack
)
+
"支部队"
self
.
level
+=
1
if
self
.
name
==
"德意志国"
and
self
.
level
<=
5
:
enemy
.
hp
-=
self
.
attack
+
20
else
:
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
):
pass
player
=
player
(
"德意志国"
,
350
,
50
,
400
)
#ger=country("German Reich",350,50)
sov
=
country
(
"苏维埃联盟"
,
600
,
20
,
1000
)
#ger.upgrade()
print
(
"国家"
+
player
.
name
+
"作战指挥连接成功,国家政党为"
+
"德意志民族社会主义工人党(法西斯主义)"
+
"陆军学说为"
+
"机动作战学说"
+
"空军学说为"
+
"战场支援学说"
)
print
(
"当前军队level,hp,attack分别为"
,
player
.
level
,
player
.
hp
,
player
.
attack
)
print
(
"-"
*
30
)
print
(
"巴巴罗萨行动"
)
while
1
:
print
(
"-"
*
30
)
choice
=
input
(
"最高作战指令(1进攻/2征召)"
)
\ 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