claude-configs/skills/paper-dynasty/scripts/distribute_packs.py
Cal Corum 8642bb539a Migrate Gitea ops to MCP, update Paper Dynasty skill, sync plugins
- CLAUDE.md + commit-push-pr: prefer gitea-mcp over tea CLI
- Paper Dynasty: updated api_client, cli, distribute_packs
- New skill: resume-tailoring
- Plugins: updated marketplaces, blocklist, install counts
- Settings and MCP config updates

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 18:59:49 -06:00

135 lines
3.9 KiB
Python
Executable File

#!/usr/bin/env python3
"""
Distribute packs to all human-controlled teams in Paper Dynasty
Standalone script for pack distribution that can be used from the Paper Dynasty skill.
Works with both production and development environments.
This script uses the Paper Dynasty API client for all operations.
"""
import argparse
import logging
import os
import sys
from pathlib import Path
# Add parent directory to path to import api_client
sys.path.insert(0, str(Path(__file__).parent.parent))
from api_client import PaperDynastyAPI
# Set up logging
logging.basicConfig(
level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s"
)
logger = logging.getLogger("pack_distribution")
def distribute_packs(
num_packs: int = 5,
exclude_team_abbrev: list[str] = None,
pack_type_id: int = 1,
cardset_id: int = None,
):
"""Distribute packs to all human-controlled teams using Paper Dynasty API client
Args:
num_packs: Number of packs to give to each team (default: 5)
exclude_team_abbrev: List of team abbreviations to exclude (default: None)
pack_type_id: Pack type ID (default: 1 = Standard packs)
cardset_id: Cardset ID for pack types that require it (e.g., Promo Choice = type 9)
"""
if exclude_team_abbrev is None:
exclude_team_abbrev = []
# Get environment
database_env = os.getenv("DATABASE", "dev").lower()
try:
# Initialize API client
api = PaperDynastyAPI(environment=database_env, verbose=True)
# Use the distribute_packs method
result = api.distribute_packs(
num_packs=num_packs,
exclude_team_abbrev=exclude_team_abbrev,
pack_type_id=pack_type_id,
cardset_id=cardset_id,
)
# Log final summary
logger.info(
f"\n🎉 All done! Distributed {result['total_packs']} packs to {result['teams_count']} teams"
)
except ValueError as e:
logger.error(f"Configuration error: {e}")
sys.exit(1)
except Exception as e:
logger.error(f"Unexpected error: {e}")
sys.exit(1)
if __name__ == "__main__":
parser = argparse.ArgumentParser(
description="Distribute packs to all human-controlled teams",
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
Examples:
# Give 5 packs to all teams (default)
python distribute_packs.py
# Give 10 packs to all teams
python distribute_packs.py --num-packs 10
# Give 5 packs, excluding certain teams
python distribute_packs.py --exclude-team-abbrev NYY BOS
# Give 3 packs, excluding one team
python distribute_packs.py --num-packs 3 --exclude-team-abbrev LAD
# Production environment
DATABASE=prod python distribute_packs.py --num-packs 10
# Exclude specific team in production
DATABASE=prod python distribute_packs.py --num-packs 11 --exclude-team-abbrev CAR
Environment Variables:
API_TOKEN - Required: API authentication token
DATABASE - Optional: 'dev' (default) or 'prod'
""",
)
parser.add_argument(
"--num-packs",
type=int,
default=5,
help="Number of packs to give to each team (default: 5)",
)
parser.add_argument(
"--exclude-team-abbrev",
nargs="*",
default=[],
help="Team abbreviations to exclude (space-separated, e.g., NYY BOS LAD)",
)
parser.add_argument(
"--pack-type-id",
type=int,
default=1,
help="Pack type ID (default: 1 = Standard packs)",
)
parser.add_argument(
"--cardset-id",
type=int,
default=None,
help="Cardset ID for pack types that require it (e.g., Promo Choice = type 9)",
)
args = parser.parse_args()
distribute_packs(
num_packs=args.num_packs,
exclude_team_abbrev=args.exclude_team_abbrev,
pack_type_id=args.pack_type_id,
cardset_id=args.cardset_id,
)