rts-commander / docs /GAMEPLAY_ISSUES.md
Luigi's picture
deploy(web): full clean snapshot with app code and assets
12d64f8

🎮 Gameplay Issues Analysis - Web vs Original

Issues Identifiés

❌ Issue #1: Attack Mechanics Missing

Problème: Impossible d'attaquer les ennemis Cause: La version web n'implémente PAS la logique d'attaque au clic droit

Original Pygame:

# Dans main.py, clic droit = attaque si ennemi cliqué
if e.button == 3:  # Right click
    target_unit = get_unit_at_position(mouse_x, mouse_y)
    if target_unit and target_unit.player != 0:
        for unit in selected_units:
            unit.target_unit = target_unit  # Attack!
    else:
        # Move to position

Web Version Actuelle:

// game.js - Seulement mouvement implémenté
onRightClick(e) {
    // ❌ Pas de détection d'ennemi
    // ❌ Pas d'ordre d'attaque
    this.moveSelectedUnits(worldX, worldY);
}

Solution Requise:

  1. Détecter les unités ennemies au clic droit
  2. Envoyer commande "attack_unit" au serveur
  3. Backend: implémenter logique de combat avec range/damage

❌ Issue #2: Production Requirements Not Enforced

Problème: "No suitable building found" pour Harvester depuis Refinery

Original Pygame:

'produce_harvester': {
    'requires': 'hq',  # ← Harvester se produit au HQ, PAS à la Refinery!
    'cost': 200
}
'produce_infantry': {
    'requires': 'barracks',  # Infantry = Barracks
    'cost': 100
}
'produce_tank': {
    'requires': 'war_factory',  # Tank = War Factory
    'cost': 500
}

Web Version Actuelle:

// static/game.js
setupBuildMenu() {
    // ❌ Pas de vérification "requires"
    // ❌ Pas de filtrage par type de bâtiment
    document.getElementById('train-infantry').onclick = 
        () => this.trainUnit('infantry');
}

Backend app.py:

async def handle_command(self, command):
    if cmd_type == "build_unit":
        building_id = command.get("building_id")
        # ❌ Pas de vérification du type de bâtiment requis
        building.production_queue.append(unit_type)

📋 Gameplay Logic - Original vs Web

Unités et Bâtiments Requis

Unité Bâtiment Requis Implémenté Web?
Infantry Barracks ❌ Non vérifié
Tank War Factory ❌ Non vérifié
Artillery War Factory ❌ Non vérifié
Helicopter War Factory ❌ Non vérifié
Harvester HQ (pas Refinery!) ❌ Non vérifié

Bâtiments et Prérequis

Bâtiment Prérequis Implémenté Web?
HQ Aucun ✅ Oui
Barracks Aucun ❌ Non vérifié
War Factory Barracks ❌ Non vérifié
Refinery Aucun ❌ Non vérifié
Power Plant Aucun ❌ Non vérifié
Radar Power Plant ❌ Non vérifié
Turret Power Plant ❌ Non vérifié
Superweapon War Factory ❌ Non vérifié

🔍 Différences Majeures

Combat System

Original:

  • ✅ Clic droit sur ennemi = attaque
  • ✅ Range check (portée d'attaque)
  • ✅ Attack cooldown (cadence de tir)
  • ✅ Damage calculation
  • ✅ Visual feedback (red line, muzzle flash)

Web:

  • ❌ Pas d'attaque implémentée
  • ❌ Pas de détection d'ennemis
  • ❌ Pas de combat

Production System

Original:

  • ✅ Vérification "requires" stricte
  • ✅ Recherche du bon type de bâtiment
  • ✅ Queue de production par bâtiment
  • ✅ Affichage du temps restant

Web:

  • ❌ Pas de vérification "requires"
  • ❌ Production globale au lieu de par bâtiment
  • ❌ Pas de sélection de bâtiment spécifique

Economy

Original:

  • ✅ Harvester collecte minerai
  • ✅ Retourne à Refinery
  • ✅ Génère crédits
  • ✅ Refinery = depot, HQ = fallback

Web:

  • ⚠️ Logique simplifiée ou manquante

✅ Solutions à Implémenter

Priority 1: Attack System

// game.js
onRightClick(e) {
    const clickedUnit = this.getUnitAt(worldX, worldY);
    
    if (clickedUnit && clickedUnit.player_id !== 0) {
        // ATTACK ENEMY
        this.sendCommand({
            type: 'attack_unit',
            attacker_ids: Array.from(this.selectedUnits),
            target_id: clickedUnit.id
        });
    } else {
        // MOVE
        this.moveSelectedUnits(worldX, worldY);
    }
}
# app.py
async def handle_command(self, command):
    elif cmd_type == "attack_unit":
        attacker_ids = command.get("attacker_ids", [])
        target_id = command.get("target_id")
        
        for uid in attacker_ids:
            if uid in self.game_state.units:
                attacker = self.game_state.units[uid]
                if target_id in self.game_state.units:
                    attacker.target_unit = self.game_state.units[target_id]

Priority 2: Production Requirements

# app.py
PRODUCTION_REQUIREMENTS = {
    'infantry': 'barracks',
    'tank': 'war_factory',
    'artillery': 'war_factory',
    'helicopter': 'war_factory',
    'harvester': 'hq'  # ← IMPORTANT!
}

async def handle_command(self, command):
    elif cmd_type == "build_unit":
        unit_type = command.get("unit_type")
        player_id = command.get("player_id", 0)
        
        # Find suitable building
        required_type = PRODUCTION_REQUIREMENTS.get(unit_type)
        suitable_building = None
        
        for building in self.game_state.buildings.values():
            if (building.player_id == player_id and 
                building.type == required_type):
                suitable_building = building
                break
        
        if suitable_building:
            suitable_building.production_queue.append(unit_type)
        else:
            # Send error to client
            await websocket.send_json({
                "type": "error",
                "message": f"No {required_type} found!"
            })

Priority 3: UI Improvements

// game.js - Disable buttons if requirements not met
setupBuildMenu() {
    const hasBarracks = this.hasBuilding('barracks');
    const hasWarFactory = this.hasBuilding('war_factory');
    const hasHQ = this.hasBuilding('hq');
    
    document.getElementById('train-infantry').disabled = !hasBarracks;
    document.getElementById('train-tank').disabled = !hasWarFactory;
    document.getElementById('train-harvester').disabled = !hasHQ;
    
    // Show tooltip explaining requirement
    if (!hasHQ) {
        document.getElementById('train-harvester').title = 
            "Requires HQ";
    }
}

📊 Fidélité au Gameplay Original

✅ Ce qui est Fidèle

  • Architecture générale (unités, bâtiments, ressources)
  • Types d'unités et bâtiments
  • Interface utilisateur similaire
  • Minimap

❌ Ce qui Manque

  • Combat system (priorité critique!)
  • Production requirements (priorité critique!)
  • A* pathfinding (simplifié)
  • Harvester AI (collection minerai)
  • Fog of war
  • Sounds
  • AI sophistiqué

🎯 Roadmap de Correction

  1. Immédiat: Implémenter attack system (clic droit)
  2. Immédiat: Fix production requirements (HQ pour Harvester!)
  3. Court terme: Harvester collection logic
  4. Moyen terme: A* pathfinding
  5. Long terme: AI amélioré, fog of war

💡 Réponse à vos Questions

1. "How to attack enemy?"

Réponse: Actuellement IMPOSSIBLE - fonctionnalité non implémentée dans la version web. Doit être ajoutée.

2. "I built refinery but cannot produce harvester"

Réponse: C'est CORRECT dans l'original ! Les Harvesters se produisent au HQ, pas à la Refinery. La Refinery sert uniquement de dépôt pour les minerais collectés.

3. "Does gameplay remain faithful?"

Réponse: Partiellement fidèle :

  • ✅ Structure générale OK
  • ❌ Combat system manquant (critique)
  • ❌ Production requirements non vérifiés (critique)
  • ⚠️ Simplifié pour le web

Conclusion: La version web est une base solide mais nécessite l'implémentation des mécaniques de combat et la validation des prérequis de production pour être fidèle au gameplay original.