-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_functions.py
45 lines (37 loc) · 1.18 KB
/
game_functions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
from Country import Country
from punishment import *
from target import *
import pygame
# 获取参数的变量名
loc = locals()
def get_variable_name(variable) -> str:
for key in loc:
if loc[key] == variable:
return key
def country_init(x):
"""自定义你的国家"""
init_input = "请输入" + str(x) + "国的"
nuclear_lock = input("\n"+ init_input + "核能上限: ")
ice_lock = input("\n"+ init_input + "可燃冰上限: ")
creature_lock = input("\n"+ init_input + "生物质能上限: ")
oil_lock = input("\n" + init_input + "石油上限: ")
coal_lock = input("\n"+ init_input + "煤上限: ")
x = Country(nuclear_lock,ice_lock,creature_lock,oil_lock,coal_lock)
def bout(x):
"""x国家的一个回合"""
random_target(x)
print("")
x.change_country()
print("")
random_punishment(x)
x.show()
input("\nPlease Press <enter>")
def get_variable_name(hh):
"""获取一个变量名"""
name_dict = locals()
print(name_dict)
for key in name_dict.keys():
if name_dict[key] == hh:
print(key)
haha = 55
get_variable_name(haha)