device-2017-03-08-124806A long long time ago
I can still remember how
That App used to make me smile….
And I knew if I had my chance
That I could make those dice dance
And maybe they’d be happy for a while….

Uh, wrong lyrics. Actually, it was quite a while ago that I made the Android app, Ships, Captain, and Crew! After the move from GitHub to GitLab, I decided to look over some of my old issues that were imported with GitLab’s great import tool. Among them, I found two issues for this old app that I had made.

The first was that of an issue with screen rotation causing the app to restart. I quickly fixed that by just setting the activity to portrait mode in the manifest file. You can check my commit if you need details.

The second issue was a bit more complicated, in that there was a problem with checking the dice for a ship, captain, or crew. Essentially, if you rolled a 4, 5, 6, 1, and 3, it would say you only have a ship (the 6) and no captain (5) or crew (4). Obviously that’s wrong. The issue is that you need a 6 before you can keep a 5 or 4. And since the dice were checked in order, when it looked at the 5 or 4, it did not have a 6 yet, so they were not “kept”.

This is how I fixed it:

for (int i = 0; i < 3; i++) {

// Check three times.

myNumber = firstDie;

diceCheck();

if (waschecked){

firstnotchecked = false;

}

dieOne.setImageResource(id);

myNumber = secondDie;

diceCheck();

if (waschecked){

secondnotchecked = false;

}

dieTwo.setImageResource(id);

myNumber = thirdDie;

diceCheck();

if (waschecked){

thirdnotchecked = false;

}

dieThree.setImageResource(id);

myNumber = fourthDie;

diceCheck();

if (waschecked){

fourthnotchecked = false;

}

dieFour.setImageResource(id);

myNumber = fifthDie;

diceCheck();

if (waschecked){

fifthnotchecked = false;

}


dieFive.setImageResource(id);


}

As you can see,  I told it to check the dice, first to last, three times. Yes, this is ugly and poor programming. Actually, I was almost ashamed of this early work, it looked so congested and terrible. However, my goal today was the quick fix, so that’s what I did. Hopefully, the update will be available on F-Droid soon, so you’ll have to check it out!

Linux – keep it simple.

Leave a Reply

Your email address will not be published. Required fields are marked *