} Array of participant player IDs
*/
- async getBattleParticipants(battleId) {
- try {
- const db = require('../../database/connection');
- const battle = await db('battles')
- .select('participants')
- .where('id', battleId)
- .first();
+ async getBattleParticipants(battleId) {
+ try {
+ const db = require('../../database/connection');
+ const battle = await db('battles')
+ .select('participants')
+ .where('id', battleId)
+ .first();
- if (!battle) return [];
+ if (!battle) return [];
- const participants = JSON.parse(battle.participants);
- const playerIds = [];
+ const participants = JSON.parse(battle.participants);
+ const playerIds = [];
- if (participants.attacker_player_id) {
- playerIds.push(participants.attacker_player_id);
- }
+ if (participants.attacker_player_id) {
+ playerIds.push(participants.attacker_player_id);
+ }
- const defendingPlayerId = await this.getDefendingPlayerId(participants);
- if (defendingPlayerId && !playerIds.includes(defendingPlayerId)) {
- playerIds.push(defendingPlayerId);
- }
+ const defendingPlayerId = await this.getDefendingPlayerId(participants);
+ if (defendingPlayerId && !playerIds.includes(defendingPlayerId)) {
+ playerIds.push(defendingPlayerId);
+ }
- return playerIds;
- } catch (error) {
- logger.error('Failed to get battle participants', {
- battleId,
- error: error.message
- });
- return [];
- }
+ return playerIds;
+ } catch (error) {
+ logger.error('Failed to get battle participants', {
+ battleId,
+ error: error.message,
+ });
+ return [];
}
+ }
}
-module.exports = GameEventService;
\ No newline at end of file
+module.exports = GameEventService;
diff --git a/src/templates/emails/README.md b/src/templates/emails/README.md
new file mode 100644
index 0000000..dd2844e
--- /dev/null
+++ b/src/templates/emails/README.md
@@ -0,0 +1,84 @@
+# Email Templates
+
+This directory contains HTML email templates for the Shattered Void MMO authentication system.
+
+## Template Structure
+
+### Base Template (`base.html`)
+The base template provides:
+- Consistent styling and branding
+- Responsive design for mobile devices
+- Dark mode considerations
+- Accessibility features
+- Social media links placeholder
+- Unsubscribe functionality
+
+### Individual Templates
+
+#### `verification.html`
+Used for email address verification during registration.
+- Variables: `{{username}}`, `{{verificationUrl}}`
+- Features: Game overview, verification link, security notice
+
+#### `password-reset.html`
+Used for password reset requests.
+- Variables: `{{username}}`, `{{resetUrl}}`
+- Features: Security warnings, password tips, expiration notice
+
+#### `security-alert.html`
+Used for security-related notifications.
+- Variables: `{{username}}`, `{{alertType}}`, `{{timestamp}}`, `{{details}}`
+- Features: Alert details, action buttons, security recommendations
+
+## Usage
+
+These templates are used by the EmailService class. The service automatically:
+1. Loads the appropriate template
+2. Replaces template variables with actual values
+3. Generates both HTML and plain text versions
+4. Handles inline styles for better email client compatibility
+
+## Template Variables
+
+Common variables available in all templates:
+- `{{username}}` - Player's username
+- `{{unsubscribeUrl}}` - Link to unsubscribe from emails
+- `{{preferencesUrl}}` - Link to email preferences
+- `{{supportUrl}}` - Link to support/help
+- `{{baseUrl}}` - Application base URL
+
+## Customization
+
+To customize templates:
+1. Edit the HTML files directly
+2. Use `{{variableName}}` for dynamic content
+3. Test with different email clients
+4. Ensure mobile responsiveness
+5. Maintain accessibility standards
+
+## Email Client Compatibility
+
+These templates are designed to work with:
+- Gmail (web, mobile, app)
+- Outlook (web, desktop, mobile)
+- Apple Mail (iOS, macOS)
+- Yahoo Mail
+- Thunderbird
+- Other major email clients
+
+## Security Considerations
+
+- All external links use HTTPS
+- No JavaScript or external resources
+- Inline styles for security
+- Proper HTML encoding for user data
+- Unsubscribe links included for compliance
+
+## Future Enhancements
+
+Planned template additions:
+- Welcome email after verification
+- Password change confirmation
+- Account suspension/reactivation
+- Game event notifications
+- Newsletter templates
\ No newline at end of file
diff --git a/src/templates/emails/base.html b/src/templates/emails/base.html
new file mode 100644
index 0000000..26b6e66
--- /dev/null
+++ b/src/templates/emails/base.html
@@ -0,0 +1,247 @@
+
+
+
+
+
+
+ {{subject}} - Shattered Void
+
+
+
+
+
+
+
+
+ {{content}}
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/templates/emails/password-reset.html b/src/templates/emails/password-reset.html
new file mode 100644
index 0000000..44596e2
--- /dev/null
+++ b/src/templates/emails/password-reset.html
@@ -0,0 +1,41 @@
+Password Reset Request
+
+Hello {{username}},
+
+We received a request to reset your password for your Shattered Void account. If you requested this, click the button below to set a new password.
+
+
+
+
+
⚠️ Security Notice
+
This reset link will expire in 1 hour for your security. If you need more time, you can request a new reset link.
+
+
+If the button above doesn't work, you can copy and paste this link into your browser:
+
+{{resetUrl}}
+
+
+
Password Security Tips:
+
+ - Use a unique password that you haven't used elsewhere
+ - Make it at least 12 characters long
+ - Include uppercase, lowercase, numbers, and special characters
+ - Consider using a password manager
+
+
+
+
+
Didn't request this?
+
If you didn't request a password reset, you can safely ignore this email. Your password will remain unchanged, and your account is secure.
+
If you're concerned about your account security, please contact our support team immediately.
+
+
+Need help? Reply to this email or contact our support team. We're here to help you get back into the galaxy safely.
+
+
+ The Shattered Void Security Team
+ Protecting the galaxy, one account at a time.
+
\ No newline at end of file
diff --git a/src/templates/emails/security-alert.html b/src/templates/emails/security-alert.html
new file mode 100644
index 0000000..2e32858
--- /dev/null
+++ b/src/templates/emails/security-alert.html
@@ -0,0 +1,52 @@
+🚨 Security Alert
+
+Hello {{username}},
+
+We detected security-related activity on your Shattered Void account that we wanted to bring to your attention.
+
+
+
Alert Type: {{alertType}}
+
Time: {{timestamp}}
+
Details: {{details}}
+
+
+
+
What should you do?
+
If this was you: No action is required. Your account remains secure.
+
If this was NOT you: Please take immediate action to secure your account:
+
+ - Change your password immediately
+ - Review your recent account activity
+ - Contact our support team if you need assistance
+
+
+
+
+
+Additional Security Recommendations:
+
+ - Enable two-factor authentication (coming soon)
+ - Use a strong, unique password
+ - Keep your email account secure
+ - Log out from shared or public computers
+ - Monitor your account activity regularly
+
+
+
+
Account Protection: We continuously monitor for suspicious activity to keep your galactic empire safe. This alert is part of our proactive security measures.
+
+
+If you have any questions or concerns about your account security, please don't hesitate to contact our support team. We're here to help protect your presence in the galaxy.
+
+
+ The Shattered Void Security Team
+ Your security is our priority.
+
+
+
+
About This Alert
+
This is an automated security notification. We send these alerts to help protect your account from unauthorized access. If you have security concerns, please contact support immediately.
+
\ No newline at end of file
diff --git a/src/templates/emails/verification.html b/src/templates/emails/verification.html
new file mode 100644
index 0000000..285937f
--- /dev/null
+++ b/src/templates/emails/verification.html
@@ -0,0 +1,37 @@
+Welcome to Shattered Void, {{username}}!
+
+Thank you for joining our post-collapse galaxy. To complete your registration and begin rebuilding civilization, please verify your email address.
+
+
+
+
+
Important: This verification link will expire in 24 hours for security reasons.
+
+
+If the button above doesn't work, you can copy and paste this link into your browser:
+
+{{verificationUrl}}
+
+Once your email is verified, you'll be able to:
+
+ - 🏗️ Establish your first colony
+ - ⚡ Manage resources and energy systems
+ - 🚀 Build and command fleets
+ - 🔬 Research new technologies
+ - 🤝 Form alliances with other survivors
+ - ⚔️ Engage in strategic combat
+
+
+
+
Didn't create an account?
+
If you didn't register for Shattered Void, you can safely ignore this email. No account will be created without email verification.
+
+
+Welcome to the galaxy, Commander. The future of civilization rests in your hands.
+
+
+ The Shattered Void Team
+ "From the ashes, we rise."
+
\ No newline at end of file
diff --git a/src/tests/helpers/test-helpers.js b/src/tests/helpers/test-helpers.js
index a731d81..8b7fe67 100644
--- a/src/tests/helpers/test-helpers.js
+++ b/src/tests/helpers/test-helpers.js
@@ -15,62 +15,62 @@ const bcrypt = require('bcrypt');
* @returns {Promise