Skip to content

Commit

Permalink
TsumBeta Release v67 (#528)
Browse files Browse the repository at this point in the history
* TsumBeta: Allow callback URL for script monitor

* TsumBeta: Fix shopping if ads are possible

* TsumBeta: Fix Int'l UI change (Home and Ranking tabs)

* TsumBeta: Release v67
  • Loading branch information
mcs authored Jun 30, 2024
1 parent 3dab69e commit f3dc8ac
Show file tree
Hide file tree
Showing 6 changed files with 80 additions and 18 deletions.
4 changes: 2 additions & 2 deletions script-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@
"com.r2studio.TsumBeta": {
"id": "com.r2studio.TsumBeta",
"title": "Disney Tsum Tsum",
"versionCode": 66,
"description": "<b style='color: #2196f3;'>\uD83D\uDD16 版本 v66 Beta</b>\n<ul>\n <li>修正<br>Bugfixes</li>\n <li>小改进<br>Minor improvements</li>\n</ul>",
"versionCode": 67,
"description": "<b style='color: #2196f3;'>\uD83D\uDD16 版本 v67 Beta</b>\n<ul>\n <li>检测新的国际主屏幕<br>Detect new Int'l Home screen</li>\n</ul>",
"packageName": "com.linecorp.LGTMTMG",
"downloadURL": "https://github.com/r2-studio/robotmon-scripts/raw/master/scripts/com.r2studio.TsumBeta/index.zip",
"dependencies": []
Expand Down
11 changes: 11 additions & 0 deletions scripts/com.r2studio.TsumBeta/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ All notable changes to the TsumBeta script will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).


## [v67] - 2024-06-29

### Added
- Allow script to repeatedly call a configurable HTTP endpoint. This allows keeping track if the script is unhealthy for
some time and for example react on that by restarting the virtual machine where the script runs in.

### Fixed
- After Int'l UI change, the new Ranking page could not be found anymore.
- Tsum Store now also works if ads are available.


## [v66] - 2024-02-27

### Fixed
Expand Down
1 change: 1 addition & 0 deletions scripts/com.r2studio.TsumBeta/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ The script has various settings. Here is a brief description of every setting.
| Auto buy boxes | This will attempt to buy the amount of boxes you entered once. Setting it to "30" and then starting the script will navigate to the Tsum Tsum Store and then buy 30 of either Premium or Select boxes / Capsules, depending if there are 2 or 3 box types available.<br>This setting is not persisted, so if you close the script (I mean "close", not "pause/stop"!), then on the next script load the setting will be 0 again.<br>***Warning:*** Tested for select boxes, pickup capsules and premium boxes, with and without mission bar on the bottom of the store. Any other store events might lead to non-deterministic behaviour. Stay near the script while using this feature. |
| No skill last fever seconds | Setting this to a value height than 0, the script won't trigger the Tsum's skill if there is currently fever active which approximately ends within X seconds, while "X" is the value you configured here. Can be useful to max out fever times per game. |
| Claim All old mails | Retrieves all heart mails containing coins one by one until heart mails contain no coins anymore. Starts then collecting again until heart mails don't contain hearts within 5 mails. Then clicks "Claim All" |
| URL to Tsum Monitor | If you have the "Tsum Monitor" running somewhere, enter the url to it here in the format "http://192.168.56.1:8888". This will regularly call the monitor so it knows that the script is still alive. Leave this empty if you don't know what that means at all. |

### Developer options

Expand Down
Binary file modified scripts/com.r2studio.TsumBeta/index.zip
Binary file not shown.
74 changes: 59 additions & 15 deletions scripts/com.r2studio.TsumBeta/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,12 +145,12 @@ var Button = {
var AbstractPage = {
TsumStore: {
colorsTwoBoxTypes: [
{x: 270, y: 920, r: 22, g: 125, b: 65, match: true, threshold: 30}, // green ribbon of happy box on left button
{x: 150, y: 750, r: 247, g: 189, b: 8, match: true, threshold: 30}, // yellow button happy box top left
{x: 460, y: 760, r: 247, g: 187, b: 8, match: true, threshold: 30}, // yellow button happy box top right
{x: 818, y: 862, r: 242, g: 90, b: 121, match: true, threshold: 30}, // red premium box on right button
{x: 590, y: 810, r: 240, g: 178, b: 8, match: true, threshold: 30}, // yellow button premium box top left
{x: 950, y: 980, r: 238, g: 173, b: 8, match: true, threshold: 30} // right side of premium box button
{x: 270, y: 920, r: 22, g: 125, b: 65, match: true, threshold: 30}, // green ribbon of happy box on left button
{x: 150, y: 750, r: 247, g: 189, b: 8, match: true, threshold: 30}, // yellow button happy box top left
{x: 460, y: 860, r: 238, g: 178, b: 16, match: true, threshold: 30}, // yellow button happy box mid right
{x: 818, y: 862, r: 242, g: 90, b: 121, match: true, threshold: 30}, // red premium box on right button
{x: 590, y: 810, r: 240, g: 178, b: 8, match: true, threshold: 30}, // yellow button premium box top left
{x: 950, y: 980, r: 238, g: 173, b: 8, match: true, threshold: 30} // right side of premium box button
],
colorsThreeBoxTypes: [
{x: 204, y: 920, r: 16, g: 125, b: 66, match: true, threshold: 30}, // green ribbon of happy box on left button
Expand Down Expand Up @@ -191,16 +191,31 @@ var Page = {
back: {x: 309, y: 1653},
next: {x: 784, y: 1653}
},
ProfilePage: {
ProfilePageJp: {
name: 'ProfilePage',
colors: [
{x: 540, y: 1592, r: 246, g: 135, b: 17, match: true, threshold: 80}, // top of the start button
{x: 187, y: 1599, r: 240, g: 218, b: 72, match: true, threshold: 80}, // top of the card button
{x: 799, y: 1653, r: 232, g: 170, b: 7, match: true, threshold: 80}, // left of the myTsum button
{x: 698, y: 464, r: 244, g: 249, b: 243, match: true, threshold: 80}, // above the ranking title
{x: 34, y: 1004, r: 247, g: 178, b: 8, match: true, threshold: 80}, // left home tab button
{x: 16, y: 1120, r: 46, g: 135, b: 232, match: true, threshold: 80}, // left ranking tab button
{x: 16, y: 1270, r: 44, g: 134, b: 233, match: true, threshold: 80} // left square tab button
{x: 6, y: 1120, r: 46, g: 135, b: 232, match: true, threshold: 80}, // left ranking tab button
{x: 6, y: 1270, r: 44, g: 134, b: 233, match: true, threshold: 80} // left square tab button
],
back: {x: 31, y: 1126},
next: {x: 31, y: 1126},
tsums: {x: 900, y: 1653}
},
ProfilePageIntl: {
name: 'ProfilePage',
colors: [
{x: 540, y: 1592, r: 246, g: 135, b: 17, match: true, threshold: 80}, // top of the start button
{x: 187, y: 1599, r: 240, g: 218, b: 72, match: true, threshold: 80}, // top of the card button
{x: 799, y: 1653, r: 232, g: 170, b: 7, match: true, threshold: 80}, // left of the myTsum button
{x: 698, y: 464, r: 244, g: 249, b: 243, match: true, threshold: 80}, // above the ranking title
{x: 34, y: 1004, r: 247, g: 178, b: 8, match: true, threshold: 80}, // left home tab button
{x: 6, y: 1120, r: 46, g: 135, b: 232, match: true, threshold: 80}, // left ranking tab button
{x: 6, y: 1270, r: 52, g: 98, b: 143, match: true, threshold: 80} // left border where in JP left square tab button is
],
back: {x: 31, y: 1126},
next: {x: 31, y: 1126},
Expand Down Expand Up @@ -493,11 +508,11 @@ var Page = {
GamePause: {
name: 'GamePause',
colors: [
{x: 165, y: 1077, r: 234, g: 173, b: 7 , match: true, threshold: 80},
{x: 594, y: 1073, r: 233, g: 171, b: 8 , match: true, threshold: 80},
{x: 367, y: 774, r: 24 , g: 191, b: 225, match: true, threshold: 80},
{x: 738, y: 612, r: 248, g: 244, b: 245, match: true, threshold: 80},
{x: 550, y: 1336, r: 236, g: 182, b: 11 , match: true, threshold: 80}
{x: 165, y: 1077, r: 234, g: 173, b: 7, match: true, threshold: 80},
{x: 586, y: 1080, r: 239, g: 174, b: 7, match: true, threshold: 80},
{x: 367, y: 774, r: 24, g: 191, b: 225, match: true, threshold: 80},
{x: 738, y: 612, r: 248, g: 244, b: 245, match: true, threshold: 80},
{x: 550, y: 1336, r: 247, g: 185, b: 8, match: true, threshold: 80}
],
back: {x: 331, y: 1080},
next: {x: 561, y: 1422}
Expand Down Expand Up @@ -1167,6 +1182,7 @@ function Tsum(isJP, detect, logs) {
this.autobuyBoxes = 0;
this.noSkillLastFeverSec = 0;
this.claimAllWithoutCoins = false;
this.nextMonitorExecution = 0;
this.init(detect);
}

Expand Down Expand Up @@ -1938,6 +1954,7 @@ Tsum.prototype.scanBoardQuick = function() {
}

Tsum.prototype.taskPlayGameQuick = function() {
this.requestTsumMonitor();
log(this.logs.gameStart);
this.goGamePlayingPage();
log(this.logs.fastGaming);
Expand Down Expand Up @@ -2006,6 +2023,7 @@ Tsum.prototype.taskPlayGameQuick = function() {
Tsum.prototype.taskReceiveAllItems = function() {
if (this.findPage() === 'GamePause')
return;
this.requestTsumMonitor();
log(this.logs.friendsPage);
this.goFriendPage();
this.sleep(1000);
Expand Down Expand Up @@ -2162,6 +2180,7 @@ Tsum.prototype.taskReceiveOneItem = function() {
var maxTimeoutCount = 100;
var receivedHeartWithoutCoins = 0;
while (this.isRunning && timeoutCounter < maxTimeoutCount) {
this.requestTsumMonitor();
var img = this.screenshot();
var isItem = isSameColor(Button.outReceiveOne.color, this.getColor(img, Button.outReceiveOne), 35);
var isRuby = isSameColor(Button.outReceiveOneRuby.color, this.getColor(img, Button.outReceiveOneRuby), 35);
Expand Down Expand Up @@ -2330,6 +2349,7 @@ Tsum.prototype.taskSendHearts = function() {
var hfy = Button.outSendHeartFrom.y - 40; // hearts from y
var hty = Button.outSendHeartTo.y + 30; // hearts to y
while(this.isRunning) {
this.requestTsumMonitor();
times++;
if (times % 15 === 0) {
debug("Ensuring friends page");
Expand Down Expand Up @@ -2496,6 +2516,7 @@ Tsum.prototype.taskAutoUnlockLevel = function() {

// check all
do {
this.requestTsumMonitor();
var allLocked = true;
var lockIcons = Page.TsumsPage.lockIcons;
img = this.screenshot();
Expand Down Expand Up @@ -2567,6 +2588,7 @@ Tsum.prototype.taskAutoBuyBoxes = function() {
log("Start buying ", this.autobuyBoxes, "boxes - taskAutoBuyBoxes");
var countUnknownPages = 0;
while (this.isRunning && this.autobuyBoxes > 0) {
this.requestTsumMonitor();
var page = this.findPageObject(1, 200);
if (page != null) {
countUnknownPages = 0;
Expand Down Expand Up @@ -2602,6 +2624,24 @@ Tsum.prototype.taskAutoBuyBoxes = function() {
log("Finished taskAutoBuyBoxes");
}

Tsum.prototype.taskRequestTsumMonitor = function() {
this.requestTsumMonitor(true);
}

Tsum.prototype.requestTsumMonitor = function(force) {
var url = this.tsumMonitorUrl;
if (url.length === 0)
return;
if (force || this.nextMonitorExecution <= Date.now()) {
log("TsumMonitor - GET", url);
var response = httpClient('GET', url, '', {});
log("TsumMonitor - Response:", response);
this.nextMonitorExecution = Date.now() + 60 * 1000;
} else {
debug("Skipping TsumMonitor call");
}
}

Tsum.prototype.sendHeart = function(btn) {
var unknownCount = 0;
var isGift = false;
Expand Down Expand Up @@ -2723,13 +2763,17 @@ function start(settings) {
ts.autobuyBoxes = settings['autobuyBoxes'];
ts.noSkillLastFeverSec = settings['noSkillLastFeverSec'];
ts.claimAllWithoutCoins = settings['claimAllWithoutCoins'];
ts.tsumMonitorUrl = settings['tsumMonitorUrl'] || "";

if (!checkFunction(TaskController)) {
console.log("File lose...");
return;
}

gTaskController = new TaskController();
if (ts.tsumMonitorUrl.length > 0) {
gTaskController.newTask('requestTsumMonitor', ts.taskRequestTsumMonitor.bind(ts), 30 * 1000, 0);
}
gTaskController.newTask('taskAutoBuyBoxes', ts.taskAutoBuyBoxes.bind(ts), 60 * 1000, 0);
if (settings['receiveHeartsOneByOne']) {
gTaskController.newTask('receiveOneItem', ts.taskReceiveOneItem.bind(ts), settings['mailMinWait'] * 60 * 1000, 0);
Expand Down Expand Up @@ -2863,4 +2907,4 @@ function rgb2hsv(rgb) {
var v = Math.max(r, g, b), c = v - Math.min(r, g, b);
var h = c && ((v === r) ? (g - b) / c : ((v === g) ? 2 + (b - r) / c : 4 + (r - g) / c));
return {h: 60 * (h < 0 ? h + 6 : h), s: Math.round(v && c / v * 100), v: Math.round(v * 100)};
}
}
8 changes: 7 additions & 1 deletion scripts/com.r2studio.TsumBeta/src/settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var VERSION = 66;
var VERSION = 67;

/**
* Returns the language parameter for the currently active locale.
Expand Down Expand Up @@ -319,6 +319,12 @@ var settings = [
title: 'Claim All old mails',
title_zh_TW: '认领所有旧邮件',
default: false
},
{
key: 'tsumMonitorUrl',
title: 'URL to Tsum Monitor',
title_zh_TW: '链接到 Tsum 监视器',
default: ""
}
]
];
Expand Down

0 comments on commit f3dc8ac

Please sign in to comment.