Category Archives: Android

Zookeeper Battle – Another reason to root an Android phone

It’s no secret that I have a keen interest in video games – from large-production epic console titles to casual smartphone games, and everything in between.  There’s a recent growing trend in mobile games, where a game is advertised as “free” but requires some kind of in-game purchase in order to unlock or make significant progress.  This is really starting to piss me off, but I’ve managed to get something positive from this frustration, as a result of working around the crippled functionality of just such a game.

I’m a shameless addict of so-called “match three” casual games – the most famous example of which is probably PopCap’s excellent “Bejeweled”.  However, I am currently hooked on the cute art style and naff music delivered by the Zoo Keeper collections of games, across several platforms, so I was delighted when I discovered Zookeeper Battle for Android (and iOS).  Finally I could play challenge matches with random strangers on the internet, and it was free!

Well, after the first few games, it seemed that all was not as good as I had naively thought.  Only the first few blocks of game credits are free, and then the game is crippled. The game credit indicator is a bar with 6 spaces which are initially full. You start out with a few “power bottles”, each of which will completely refill this bar.  Each game empties one of the spaces on the bar and, upon depletion, the bar refills one slot every 6 minutes, but only up to a maximum of 2 slots.

Since I enjoy this game so much, I would happily pay a few pounds for an unlimited version, but a browse of the in-game store reveals no such option.  One can buy a single “power bottle” (to refill all 6 slots) for $0.99, 6 bottles for $4.50, or 14 for $8.50 – respective rates of $0.165, $0.125 and $0.10 per game.  Really, $0.10 is the cheapest option to play this game.  I regularly come up against opponents who have played several thousand games – does this mean that they have stumped up in excess of $300 to the mobile game gods?  I sincerely hope not!

Being a little devious, I decided to have a poke around the files which this game deploys on one’s Android device (and, without getting into too much detail, this kind of thing is exactly why I chose Android over iOS for my phone) and found a very interesting XML file containing all kinds of data for the game.  With a bit of experimentation, I was able to determine that, while most of the data appears to have been written to the file following a download from the game server, some of the elements are read directly from file – including the “number of game credits” field.

Following a very brief spot of Perl scripting using the incredibly handy SL4A package, I now have a solid workaround for this game- (and wallet-) crippling “feature”, which is as follows.  Note – this does require root on your Android device.  If you do not know what this means then please Google – this particular post is not intended as a “how to root an Android device” tutorial.

  • Play until you see the dreaded “give us more money to keep playing” screen, and then hit cancel and quit the application.  It’s important that you *actually* quit, rather than just jumping to the Home screen:

2013-03-02 23.11.12

  • Using your file explorer/editor of choice (or a command shell), update the permissions on ‘/data/data/jp.kiteretsu.zookeeperbattle.google/zk.dat’ to make it world readable and writeable:

2013-03-02 23.11.56

 

  • Fire up SL4A and create a new Perl script as follows.  I saved this as “zkpatch.pl” – note, you only need to create the script the first time:

use Android;

my $droid = Android->new();
my $datafile = '/data/data/jp.kiteretsu.zookeeperbattle.google/zk.dat';

unless ( open FILE, $datafile ) {
 $droid->dialogCreateAlert('Error',"Failed to read file: $!");
 $droid->dialogShow();
 exit 1;
}
my @content = <FILE>;
close FILE;

unless ( open WRITE, ">$datafile" ) {
 $droid->dialogCreateAlert('Error',"Failed to write file: $!");
 $droid->dialogShow();
 exit 1;
}

foreach my $line (@content) {
 $line =~ s!<zk_cp>.*?</zk_cp>!<zk_cp>6</zk_cp>!;
 print WRITE $line;
}
close WRITE;

$droid->dialogCreateAlert('Done',"$datafile has been patched");
$droid->dialogShow();

  • Now execute this from within the SL4A app.  It will show an alert if there’s an error opening or updating the file, and a confirmation if it’s successful:

2013-03-02 23.12.17

2013-03-02 23.12.27

  • Reload the game and enjoy your full credit bar!

2013-03-02 23.12.46

 

There you have it – a nice workaround for a stupid game payment mechanic!

Ideally, I’d like to wrap this up in a standalone application for Android, rather than using the Perl script.  Also there is word that future version of SL4A will allow performing operations as root – this would allow me to set the target file’s permissions from the script for a more elegant solution.  Until then, I’d rather take 10 seconds to perform these steps than wait 6 minutes to play another game.

17 Comments

Filed under Android, Dev