-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEazyGame.lua
More file actions
143 lines (126 loc) · 3.4 KB
/
EazyGame.lua
File metadata and controls
143 lines (126 loc) · 3.4 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
-- 引入必要的库
local utils = require('.utils')
-- 初始化随机数种子
math.randomseed(os.time())
-- 定义随机生成器
function Random_percentage()
return math.random(100)
end
-- 随机生成牛
function Generate_random_numbers()
local numbers = {}
for i = 1, 5 do
numbers[i] = math.random(1, 5)
end
return numbers
end
-- 定义转账函数(直接集成在此脚本中)
function Transfer_funds(Balances, recipient, amount)
if Balances[ao.id] and tonumber(Balances[ao.id]) >= amount then
Balances[ao.id] = utils.subtract(Balances[ao.id], tostring(amount))
Balances[recipient] = utils.add(Balances[recipient] or "0", tostring(amount))
return true
end
return false
end
-- 定义 5 个不同成功率的函数
function Function1(Balances, recipient)
if Random_percentage() <= 80 then
return Transfer_funds(Balances, recipient, 1)
end
return false
end
function Function2(Balances, recipient)
if Random_percentage() <= 60 then
return Transfer_funds(Balances, recipient, 2)
end
return false
end
function Function3(Balances, recipient)
if Random_percentage() <= 40 then
return Transfer_funds(Balances, recipient, 3)
end
return false
end
function Function4(Balances, recipient)
if Random_percentage() <= 20 then
return Transfer_funds(Balances, recipient, 4)
end
return false
end
function Function5(Balances, recipient)
if Random_percentage() <= 10 then
return Transfer_funds(Balances, recipient, 5)
end
return false
end
-- 使用 Handlers.add 并提供正确的参数
Handlers.add('get_random_numbers',
function(msg)
-- 这里可以根据消息的某些条件来决定返回 1(处理)、0(跳过)、-1(中止)
return 1 -- 继续处理消息
end,
function(msg)
msg.reply(Generate_random_numbers())
end
)
Handlers.add('get_bull_1',
function(msg)
return 1 -- 继续处理
end,
function(msg)
if Function1(Balances, msg.recipient) then
msg.reply("Transfer successful")
else
msg.reply("Transfer failed")
end
end
)
Handlers.add('get_bull_2',
function(msg)
return 1 -- 继续处理
end,
function(msg)
if Function2(Balances, msg.recipient) then
msg.reply("Transfer successful")
else
msg.reply("Transfer failed")
end
end
)
Handlers.add('get_bull_3',
function(msg)
return 1 -- 继续处理
end,
function(msg)
if Function3(Balances, msg.recipient) then
msg.reply("Transfer successful")
else
msg.reply("Transfer failed")
end
end
)
Handlers.add('get_bull_4',
function(msg)
return 1 -- 继续处理
end,
function(msg)
if Function4(Balances, msg.recipient) then
msg.reply("Transfer successful")
else
msg.reply("Transfer failed")
end
end
)
Handlers.add('get_bull_5',
function(msg)
return 1 -- 继续处理
end,
function(msg)
if Function5(Balances, msg.recipient) then
msg.reply("Transfer successful")
else
msg.reply("Transfer failed")
end
end
)