Code Contribution Workflow
This guide explains how to contribute code to the Andor's Trail project.
Overview
Andor's Trail uses GitHub for version control and collaboration. The contribution workflow follows a fork-and-pull-request model.
Prerequisites
Git is installed and configured.
GitHub account.
Development environment set up (see Development Environment Setup).
Understanding of Java and Android development.
Familiarity with the Andor's Trail codebase.
Step 1: Fork the Repository
Click the "Fork" button in the top-right corner.
Select your account (you now have your own copy of the repository).
Note the URL of your fork:
https://github.com/YOUR_USERNAME/andors-trail
Step 2: Clone Your Fork
bash# Clone your fork
git clone https://github.com/YOUR_USERNAME/andors-trail.git
cd andors-trail
# Add upstream remote (the original repository)
git remote add upstream https://github.com/AndorsTrailRelease/andors-trail.git
# Verify remotes
git remote -v
# Should show:
# origin → your fork
# upstream → original repositoryStep 3: Create a Feature Branch
Always create a new branch for your work:
bash# Update master with latest changes
git checkout master
git pull upstream master
# Create feature branch
git checkout -b feature/description-of-change
# Examples:
# git checkout -b fix/npc-dialogue-bug
# git checkout -b feature/add-new-skill
# git checkout -b improvement/optimize-combat-calculationBranch Naming Conventions
Use prefixes to categorize your branch:
fix/- Bug fixesfeature/- New featuresimprovement/- Code improvements or refactoringdocs/- Documentation updatestest/- Test additions or improvements
Follow with a descriptive name using hyphens (not spaces):
fix/combat-hit-chance-calculationfeature/new-actor-conditionimprovement/reduce-memory-usage
Step 4: Make Changes
Edit files in your IDE (Android Studio).
Follow the coding style guidelines (see below).
Build and test your changes.
Coding Style Guidelines
Java Code Style
java// Class names: PascalCase
public class PlayerInventory {
// Method names: camelCase
public void addItem(Item item) {
// Constant names: UPPER_SNAKE_CASE
final int MAX_ITEMS = 100;
// Variable names: camelCase
int itemCount = items.size();
// Indentation: 4 spaces
if (itemCount < MAX_ITEMS) {
items.add(item);
}
}
// Javadoc comments for public methods
/**
* Removes an item from the player's inventory.
*
* @param itemId The ID of the item to remove
* @return true if item was found and removed, false otherwise
*/
public boolean removeItem(String itemId) {
return items.removeIf(item -> item.getId().equals(itemId));
}
}Formatting Rules
Use 4 spaces for indentation (not tabs).
Maximum line length: 100 characters.
Add blank lines between methods.
Add spaces around operators:
a + b, nota+bOpen braces on same line:
if (condition) {notif (condition)\n{
Comments
java// Single-line comments for code explanation
int result = calculate(x, y); // Calculate result
/**
* Multi-line comments (Javadoc) for public methods
* describing purpose, parameters, and return value
*/
public int calculate(int x, int y) {
// TODO: Add validation
// FIXME: Handle edge case
return x + y;
}Step 5: Test Your Changes
Build the Project
bash./gradlew clean buildRun Tests
bash# Run all tests
./gradlew test
# Run specific test
./gradlew test --tests com.gpl.rpg.AndorsTrail.SomeTest
# Run with coverage
./gradlew test jacocoTestReportTest on Device/Emulator
Open Android Studio.
Click Run → Run 'AndorsTrail'.
Select an emulator or device.
Verify your changes work as expected.
Manual Testing
Test the specific feature you modified.
Test edge cases and error conditions.
Verify no regressions in other areas.
Document your testing in the PR description.
Step 6: Commit Changes
Use clear, descriptive commit messages:
bash# Stage files
git add src/com/gpl/rpg/AndorsTrail/SomeFile.java
git add test/com/gpl/rpg/AndorsTrail/SomeFileTest.java
# Commit with message
git commit -m "Fix combat hit chance calculation formula
- Updated ATAN formula to match specification
- Added edge case handling for zero values
- Updated related unit tests
- Fixes #123"Commit Message Format
text<type>: <subject>
<body>
<footer>Type:
fix:- Bug fixfeature:- New featurerefactor:- Code refactoringtest:- Test additionsdocs:- Documentation
Subject:
Use imperative mood ("fix", not "fixed").
Don't capitalize the first letter.
No period at the end.
Maximum 50 characters.
Body:
Explain what and why, not how.
Wrap at 72 characters.
Reference issue numbers:
Fixes #123,Closes #456
Example:
textfix: correct player health calculation
The health calculation was using integer division instead of
proper rounding, causing incorrect damage calculations in edge
cases. Updated to use Math.round() for proper rounding.
Fixes #189Step 7: Keep Your Branch Updated
Before submitting, sync with upstream:
bash# Fetch latest changes
git fetch upstream
# Rebase on master
git rebase upstream/master
# If there are conflicts, resolve them:
# 1. Edit conflicted files
# 2. Mark as resolved: git add <file>
# 3. Continue rebase: git rebase --continueAlternatively, merge if rebase is complex:
bashgit merge upstream/masterStep 8: Push to Your Fork
bash# Push your branch
git push origin feature/description-of-change
# To force update (after rebase)
git push origin feature/description-of-change --forceStep 9: Create a Pull Request
Visit your fork on GitHub,
Click "Compare & pull request" button,
Fill in the PR form:
PR Title
Clear, concise description:
"Fix combat hit chance calculation",
"Add new actor condition: Petrified",
"Optimize memory usage in map loading",
PR Description
text## Description
Brief description of what this PR does.
## Type of Change
- [ ] Bug fix
- [ ] New feature
- [ ] Improvement
- [ ] Documentation
## Changes Made
- Change 1
- Change 2
- Change 3
## Testing
Describe how you tested the changes:
- Tested on emulator (API 25)
- Tested on device (Pixel 4, Android 11)
- All unit tests pass
## Closes
Fixes #123
## Additional Notes
Any additional context.Request reviewers (if known),
Click "Create pull request",
Step 10: Code Review
Reviewers will:
Examine your code,
Check for bugs and issues,
Verify adherence to style guidelines,
Request changes if needed,
Responding to Review Comments
Don't be defensive - feedback improves code quality,
Make requested changes in new commits,
Push changes to the same branch (automatically updates PR),
Reply to comments explaining changes,
Click "Resolve conversation" when addressed,
Addressing Review Feedback
bash# Make requested changes
# Edit files...
# Commit changes
git commit -m "Address review feedback
- Improved variable naming
- Added error handling
- Updated documentation"
# Push to branch
git push origin feature/description-of-changeStep 11: Merge
Once approved:
The maintainers will merge your PR.
Your branch can be deleted.
Changes are now in the main repository.
After Merge
bash# Update local master
git checkout master
git pull upstream master
# Delete local feature branch
git branch -d feature/description-of-change
# Delete remote feature branch (if not auto-deleted)
git push origin --delete feature/description-of-changeCoding Standards
Javadoc Requirements
All public classes and methods must have Javadoc.
Describe purpose, parameters, return value, and exceptions.
Include example usage for complex methods.
java/**
* Calculates player attack chance against a target.
*
* Formula: AC = 50 + (2/π) * arctan((AC - 50) / 40)
*
* @param playerAC Player's attack chance (0-100)
* @param targetBC Target's block chance (0-100)
* @return Effective attack chance (0-100)
*/
public int calculateHitChance(int playerAC, int targetBC) {
// Implementation
}Error Handling
Check for null values.
Handle expected exceptions.
Use meaningful error messages.
Log errors appropriately.
javapublic Item getItem(String itemId) {
if (itemId == null || itemId.isEmpty()) {
throw new IllegalArgumentException("Item ID cannot be null or empty");
}
Item item = items.get(itemId);
if (item == null) {
Log.w(TAG, "Item not found: " + itemId);
return null;
}
return item;
}Testing Requirements
Write unit tests for new functionality.
Maintain or improve code coverage.
Test edge cases and error conditions.
javapublic class PlayerInventoryTest {
@Test
public void testAddItem() {
PlayerInventory inventory = new PlayerInventory();
Item item = new Item("sword");
inventory.addItem(item);
assertTrue(inventory.contains("sword"));
}
@Test
public void testAddItemWithNull() {
PlayerInventory inventory = new PlayerInventory();
assertThrows(NullPointerException.class,
() -> inventory.addItem(null));
}
}Common Issues
PR Not Updating After Changes
bash# Ensure you're pushing to the same branch
git push origin feature/description-of-change
# If force push was needed
git push origin feature/description-of-change --forceMerge Conflicts
bash# Update your branch
git fetch upstream
git rebase upstream/master
# Resolve conflicts in editor, then:
git add .
git rebase --continue
git push origin feature/description-of-change --forceCI/CD Pipeline Failed
Check the build logs:
View logs in GitHub (GitHub Actions tab).
Fix issues indicated by failures.
Commit and push changes.
CI automatically reruns.
Review Checklist
Before submitting, verify:
Resources
Getting Help
Check existing issues and discussions.
Ask on Andor's Trail forums.
Comment on related GitHub issues.
Request help from maintainers.
Last updated