-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpushbox.py
82 lines (69 loc) · 2.32 KB
/
pushbox.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# 定义地图
map = [
"#####",
"# #",
"# #",
"#O #",
"#####"
]
# 定义玩家初始位置
player_x, player_y = 3, 1
# 定义箱子初始位置
box_x, box_y = 3, 2
# 游戏循环
while True:
# 打印地图
for row in map:
print(row)
# 玩家移动
move = input("请输入移动方向(上:w,下:s,左:a,右:d):")
if move == "w":
if map[player_y - 1][player_x] == " ":
player_y -= 1
elif map[player_y - 1][player_x] == "O" and map[player_y - 2][player_x] == " ":
player_y -= 1
box_y -= 1
elif move == "s":
if map[player_y + 1][player_x] == " ":
player_y += 1
elif map[player_y + 1][player_x] == "O" and map[player_y + 2][player_x] == " ":
player_y += 1
box_y += 1
elif move == "a":
if map[player_y][player_x - 1] == " ":
player_x -= 1
elif map[player_y][player_x - 1] == "O" and map[player_y][player_x - 2] == " ":
player_x -= 1
box_x -= 1
elif move == "d":
if map[player_y][player_x + 1] == " ":
player_x += 1
elif map[player_y][player_x + 1] == "O" and map[player_y][player_x + 2] == " ":
player_x += 1
box_x += 1
# 更新地图
map[box_y] = map[box_y][:box_x] + "O" + map[box_y][box_x + 1:]
map[player_y] = map[player_y][:player_x] + "P" + map[player_y][player_x + 1:]
# 判断是否胜利
if map[box_y][box_x] == "X":
print("恭喜你,通关了!")
break
from O365 import Account
# 替换为你的应用程序的客户端 ID 和客户端密钥
client_id = 'your_client_id'
client_secret = 'your_client_secret'
# 创建一个 O365 账户
credentials = (client_id, client_secret)
account = Account(credentials)
# 登录到账户
if not account.is_authenticated:
# 如果没有授权,进行授权
account.authenticate(scopes=['basic', 'message_all'])
# 或者使用 account.authenticate(scopes=['basic', 'message_all', 'onedrive_all']) 来获取更多权限
# 创建一封新邮件
m = account.new_message()
m.to.add('[email protected]') # 替换为你要发送的收件人邮箱地址
m.subject = '通关啦!'
m.body = "恭喜你,成功通关迷宫游戏!"
m.send()
print("通关消息已发送!")