1:
2: adaptOrientation(ORIENTATION_TYPE.PORTRAIT);
3:
4: -- ------------------------------------
5: --
6: -- ------------------------------------
7:
8: -- イベント
9: local SW_EVENT = false;
10:
11: -- 移動経路 circle, minicircle
12: local SW_ROUTE = "minicircle";
13:
14: -- スキルボタン
15: local LOC_SKILL = {90, 970}
16:
17: -- 回転ボタン
18: local LOC_ROTATION = {540,970}
19:
20: -- ツムのマス目設定
21: local TSUMUXMIN = 40;
22: local TSUMUXMAX = 580;
23: local TSUMUYMIN = 320;
24: local TSUMUYMAX = 800;
25: local TSUMUSTEP = 80;
26:
27: -- ------------------------------------
28: -- image tap:
29: -- ------------------------------------
30: function imagetap(result)
31: for i, v in pairs(result) do
32: tap(v[1], v[2]);
33: return true;
34: end
35: return false;
36: end
37:
38: -- ------------------------------------
39: -- image check:
40: -- ------------------------------------
41: function imagecheck(result)
42: for i, v in pairs(result) do
43: return true;
44: end
45: return false;
46: end
47:
48: -- ------------------------------------
49: -- skill_tap:
50: -- ------------------------------------
51: function skill_tap()
52: tap(LOC_SKILL[1], LOC_SKILL[2]);
53: usleep(16000)
54: end
55:
56: -- ------------------------------------
57: -- rotation_tap:
58: -- ------------------------------------
59: function rotation_tap()
60: tap(LOC_ROTATION[1], LOC_ROTATION[2]);
61: usleep(16000)
62: end
63:
64: -- ------------------------------------
65: -- tsumu class:
66: -- ------------------------------------
67: tsumu = {}
68: tsumu.new = function(xfr, xto, yfr, yto, step)
69: obj = {}
70: obj.rows = {}
71: obj.xfr = xfr;
72: obj.xto = xto;
73: obj.yfr = yfr;
74: obj.yto = yto;
75: obj.step = step;
76: obj.rowcount = 0;
77: obj.colcount = 0;
78:
79: for y = obj.yfr, obj.yto, obj.step do
80: local cols = {}
81: for x = obj.xfr, obj.xto, obj.step do
82: table.insert(cols, {x, y});
83: end
84: table.insert(obj.rows, cols);
85: end
86:
87: for y = obj.yfr, obj.yto, obj.step do
88: obj.rowcount = obj.rowcount + 1;
89: end
90:
91: for x = obj.xfr, obj.xto, obj.step do
92: obj.colcount = obj.colcount + 1;
93: end
94:
95: obj.row = function(self)
96: return self.rowcount;
97: end
98:
99: obj.col = function(self)
100: return self.colcount;
101: end
102:
103: return obj;
104:
105: end
106:
107: -- ------------------------------------
108: -- route class:
109: -- ------------------------------------
110: route = {}
111: route.select = function(self)
112: local i = math.random(self.ts:row());
113: local j = math.random(self.ts:col());
114: self.row = i;
115: self.col = j;
116: self.target = {i, j}
117: end
118:
119: route.up = function(self)
120: self.row = self.row - 1;
121: if (self.row > 0) and (self.row <= self.ts:row()) and
122: (self.col > 0) and (self.col <= self.ts:col()) then
123: table.insert(self.route, self.ts.rows[self.row][self.col]);
124: end
125: end
126:
127: route.right = function(self)
128: self.col = self.col + 1;
129: if (self.row > 0) and (self.row <= self.ts:row()) and
130: (self.col > 0) and (self.col <= self.ts:col()) then
131: table.insert(self.route, self.ts.rows[self.row][self.col]);
132: end
133: end
134:
135: route.down = function(self)
136: self.row = self.row + 1;
137: if (self.row > 0) and (self.row <= self.ts:row()) and
138: (self.col > 0) and (self.col <= self.ts:col()) then
139: table.insert(self.route, self.ts.rows[self.row][self.col]);
140: end
141: end
142:
143: route.left = function(self)
144: self.col = self.col - 1;
145: if (self.row > 0) and (self.row <= self.ts:row()) and
146: (self.col > 0) and (self.col <= self.ts:col()) then
147: table.insert(self.route, self.ts.rows[self.row][self.col]);
148: end
149: end
150:
151: route.run = function(self)
152: local x = self.ts.rows[self.target[1]][self.target[2]][1];
153: local y = self.ts.rows[self.target[1]][self.target[2]][2];
154: local w = 10000;
155: touchDown(0, x, y); usleep(w);
156: for key, val in pairs(self.route) do
157: x = val[1];
158: y = val[2];
159: touchMove(0, x, y); usleep(w);
160: end
161: touchUp(0, x, y); usleep(w);
162: end
163:
164: -- ------------------------------------
165: -- create route class: circle
166: -- ------------------------------------
167: route_circle = {}
168: route_circle.new = function(ts)
169: obj = {}
170: obj.route = {}
171: obj.row = 0;
172: obj.col = 0;
173: obj.ts = ts;
174: obj.target = {}
175: setmetatable(obj, {__index=route})
176:
177: obj:select();
178:
179: -- 1周目
180: obj:up();
181: obj:right();
182: obj:down();
183: obj:down();
184: obj:left();
185: obj:left();
186: obj:up();
187: obj:up();
188:
189: -- 2周目
190: obj:up();
191: obj:right();
192: obj:right();
193: obj:right();
194: obj:down();
195: obj:down();
196: obj:down();
197: obj:down();
198: obj:left();
199: obj:left();
200: obj:left();
201: obj:left();
202: obj:up();
203: obj:up();
204: obj:up();
205: obj:up();
206:
207: -- 3周目
208: obj:up();
209: obj:right();
210: obj:right();
211: obj:right();
212: obj:right();
213: obj:right();
214: obj:down();
215: obj:down();
216: obj:down();
217: obj:down();
218: obj:down();
219: obj:down();
220: obj:left();
221: obj:left();
222: obj:left();
223: obj:left();
224: obj:left();
225: obj:left();
226: obj:up();
227: obj:up();
228: obj:up();
229: obj:up();
230: obj:up();
231: obj:up();
232:
233: return obj;
234: end
235:
236: -- ------------------------------------
237: -- create route class: circle
238: -- ------------------------------------
239: route_minicircle = {}
240: route_minicircle.new = function(ts)
241: obj = {}
242: obj.route = {}
243: obj.row = 0;
244: obj.col = 0;
245: obj.ts = ts;
246: obj.target = {}
247: setmetatable(obj, {__index=route})
248:
249: obj:select();
250:
251: -- 1周目
252: obj:up();
253: obj:right();
254: obj:down();
255: obj:down();
256: obj:left();
257: obj:left();
258: obj:up();
259: obj:up();
260:
261: -- 2週目
262: obj:up();
263: obj:right();
264: obj:right();
265: obj:right();
266: obj:down();
267: obj:down();
268: obj:down();
269: obj:down();
270: obj:left();
271: obj:left();
272: obj:left();
273: obj:left();
274: obj:up();
275: obj:up();
276: obj:up();
277: obj:up();
278:
279: return obj;
280: end
281:
282: -- ------------------------------------
283: -- main
284: -- ------------------------------------
285: math.randomseed(os.time());
286:
287: local area_range = {}
288: local ts = tsumu.new(TSUMUXMIN, TSUMUXMAX, TSUMUYMIN, TSUMUYMAX, TSUMUSTEP);
289: local rt = {}
290:
291: while true do
292:
293: -- 「プレイ中」判別
294: area_range = {999, 999, 999, 999};
295: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
296: if imagecheck(result) then
297: if SW_ROUTE == "circle" then
298: rt = route_circle.new(ts);
299: rt:run();
300: skill_tap();
301: elseif SW_ROUTE == "minicircle" then
302: rt = route_minicircle.new(ts);
303: rt:run();
304: skill_tap();
305: end
306:
307: else
308: -- 「スタート」ボタン
309: area_range = {999, 999, 999, 999};
310: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
311: if imagecheck(result) then
312: usleep(5000000);
313: imagetap(result);
314: usleep(1000000);
315: end
316:
317: -- 「リトライ」ボタン
318: area_range = {999, 999, 999, 999};
319: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
320: if imagecheck(result) then
321: imagetap(result);
322: usleep(1000000);
323: end
324:
325: -- 「閉じる」ボタン
326: area_range = {999, 999, 999, 999};
327: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
328: if imagecheck(result) then
329: imagetap(result);
330: usleep(1000000);
331: end
332:
333: -- ハイスコア「閉じる」ボタン
334: area_range = {999, 999, 999, 999};
335: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
336: if imagecheck(result) then
337: imagetap(result);
338: usleep(1000000);
339: end
340:
341: -- 「続けてプレイしますか?」
342: area_range = {999, 999, 999, 999};
343: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
344: if imagecheck(result) then
345: -- 「キャンセル」
346: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
347: if imagecheck(result) then
348: imagetap(result);
349: usleep(1000000);
350: end
351: end
352:
353:
354:
355: if SW_EVENT then
356: -- 「あきらめる」ボタン
357: area_range = {999, 999, 999, 999};
358: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
359: if imagecheck(result) then
360: imagetap(result);
361: usleep(1000000);
362: end
363:
364: -- 「ダイスを振る」ボタン
365: area_range = {999, 999, 999, 999};
366: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
367: if imagecheck(result) then
368: imagetap(result);
369: usleep(1000000);
370: end
371:
372: -- 「閉じる」ボタン
373: area_range = {999, 999, 999, 999};
374: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
375: if imagecheck(result) then
376: imagetap(result);
377: usleep(1000000);
378: end
379:
380: -- ロゴ
381: area_range = {999, 999, 999, 999};
382: local result = findColors({{99999999,0,0}, {99999999,9,9}, {99999999,9,9}, {99999999,9,9}}, 0, area_range);
383: if imagecheck(result) then
384: imagetap(result);
385: usleep(1000000);
386: end
387:
388: end
389:
390: end
391:
392: end