Navigation

Gridiron Playmaker Integration

Connect your standalone Gridiron game to the Mothership pearl economy

Generate Credentials
Quick Stats
Pearl Rate:10 pearls per win
Game Type:NFL Idioms
Difficulty:Medium-Hard
Security:HMAC SHA-256
Setup Instructions
Integration Code Example
<!-- 1. Add this to your Gridiron Playmaker HTML -->
<script src="https://snappy-english-prod.base44.run/mothership-sdk.js"></script>

<script>
// 2. Initialize the SDK
const mothership = new MothershipSDK({
  gameId: 'YOUR_GAME_ID',
  secretKey: 'YOUR_SECRET_KEY',
  apiUrl: 'https://snappy-english-prod.base44.run/functions/gameAPISupabase'
});

// 3. When player completes a level (wins)
async function handleGameComplete(playerEmail, rollCount, ladders, snakes, idioms) {
  try {
    const result = await mothership.reportCompletion(
      playerEmail,
      `game_${Date.now()}`,  // Unique level ID per game
      'win',
      {
        timeSpent: Math.floor(Date.now() / 1000),
        difficulty: 'medium',
        totalRolls: rollCount,
        laddersHit: ladders,
        snakesHit: snakes,
        idiomsEncountered: idioms
      }
    );

    if (result.success) {
      // Show pearl reward to player
      alert(`You earned ${result.pearlsAwarded} pearls! New balance: ${result.newBalance}`);
    } else if (result.alreadyRewarded) {
      alert('You already got pearls for this game!');
    }
  } catch (error) {
    console.error('Failed to award pearls:', error);
    alert('Game completed, but pearl award failed. Contact support.');
  }
}

// 4. Get player's progress
async function loadPlayerProgress(playerEmail) {
  try {
    const progress = await mothership.getProgress(playerEmail);
    console.log('Player pearl balance:', progress.pearlBalance);
    console.log('Completed levels:', progress.completedLevels);
  } catch (error) {
    console.error('Failed to load progress:', error);
  }
}
</script>