v0.8.9 (Bugfixes + translations) released to Google Play!

Useful links
Source code of the game - Contribution guide - ATCS Editor - Translate the game on Weblate - Example walkthrough - Andor's Trail Directory - Join the Discord
Get the game (v0.8.9) from Google, F-Droid, our server, or itch.io

Source Code Autoformat

Discussions of the development process of the game.
Post Reply
Todor Balabanov
Posts: 5
Joined: Mon Nov 18, 2013 11:06 am
android_version: 4.0

Source Code Autoformat

Post by Todor Balabanov »

Hi!

Is it possible source code auto-format to be done in Android Studio for all Java files in the project?

All the best,
Todor
User avatar
Zukero
Lead Developer
Posts: 2028
Joined: Thu Jul 21, 2011 9:56 am
android_version: 8.0
Location: Eclipse

Re: Source Code Autoformat

Post by Zukero »

Hello and welcome to the forums !

I don't know about Android Studio. You can search for "IntelliJ Idea" in google. Android Studio is based on this software (a non-free Java IDE).
I use the Eclipse ADT bundle, as IMHO, android studio is not mature enough yet, and I'm more familiar with eclipse. In eclipse, you can use Ctrl+Shift+F to reformat a source file, or a whole project, or Ctrl+I to only redo the indentation of a selected piece of code.

However, if you intend to contribute some source code, I would advise against reformatting the files, as GIT would think you have changed all the lines of all the files.

Good luck !
Lvl: 78, XP: 8622632, Gold: 271542, RoLS: 1, ElyR: -, RoL: -, ChaR: 1, GoLF: 1, ShaF: 1, SRoV: 1, VSH: 1, WMC: 1, GoW: 1
HP: 71, AC: 301%, AD: 38-47, AP: 3, ECC: 50%, CM: 3.75, BC: 101%, DR: 2
Todor Balabanov
Posts: 5
Joined: Mon Nov 18, 2013 11:06 am
android_version: 4.0

Re: Source Code Autoformat

Post by Todor Balabanov »

Thanks.

At the moment it is pretty difficult to read the code. I have better experience with Eclipse, but the tutorial says that Android Studio should be used and that is why I have asked for it.

May be the better question is why the source code is not auto-formated already?

Is there any chance project admins to take decision for source code auto-format?

I would like to contribute, but I think it is too early for me to offer something useful.

Todor
User avatar
Zukero
Lead Developer
Posts: 2028
Joined: Thu Jul 21, 2011 9:56 am
android_version: 8.0
Location: Eclipse

Re: Source Code Autoformat

Post by Zukero »

Where did you get the source ?
I get it from Oskar's github repo, and it looks well formatted to me. Indent uses tab, opening brackets not on a new line, and methods parameters on a new line when numerous are the choices made.
Lvl: 78, XP: 8622632, Gold: 271542, RoLS: 1, ElyR: -, RoL: -, ChaR: 1, GoLF: 1, ShaF: 1, SRoV: 1, VSH: 1, WMC: 1, GoW: 1
HP: 71, AC: 301%, AD: 38-47, AP: 3, ECC: 50%, CM: 3.75, BC: 101%, DR: 2
Todor Balabanov
Posts: 5
Joined: Mon Nov 18, 2013 11:06 am
android_version: 4.0

Re: Source Code Autoformat

Post by Todor Balabanov »

I see it seams it is my mistake. I am taking it from here: https://code.google.com/p/andors-trail/ ... ndorsTrail
Todor Balabanov
Posts: 5
Joined: Mon Nov 18, 2013 11:06 am
android_version: 4.0

I see some interesting functions.

Post by Todor Balabanov »

Do you thik that it will be useful to rewrite some of them?

Code: Select all

	private static int getRandomConditionForRejuvenate(Player player) {
		ArrayList<Integer> potentialConditions = new ArrayList<Integer>();
		for (int i = 0; i < player.conditions.size(); ++i) {
			ActorCondition c = player.conditions.get(i);
			if (!c.isTemporaryEffect())
				continue;
			if (c.conditionType.isPositive)
				continue;
			if (c.conditionType.conditionCategory == ActorConditionType.ConditionCategory.spiritual)
				continue;
			potentialConditions.add(i);
		}
		if (potentialConditions.isEmpty())
			return -1;

		return potentialConditions.get(Constants.rnd
				.nextInt(potentialConditions.size()));
	}

Code: Select all

	private static int getRandomConditionForRejuvenate2(Player player) {
		int i = -1;
		int count = 0;
		int potentialConditions[] = new int[player.conditions.size()];
		for (ActorCondition c : player.conditions) {
			i++;

			if (!c.isTemporaryEffect())
				continue;
			if (c.conditionType.isPositive)
				continue;
			if (c.conditionType.conditionCategory == ActorConditionType.ConditionCategory.spiritual)
				continue;

			potentialConditions[count++] = i;
		}

		if (count == 0)
			return -1;

		return potentialConditions[Constants.rnd.nextInt(count)];
	}
Post Reply