2
0
Эх сурвалжийг харах

Merge pull request #306 from djeada/copilot/enable-mounted-knight-recruitment

⚔️ Enable Mounted Knight recruitment via Barracks (Player + AI + UI)
Adam Djellouli 1 сар өмнө
parent
commit
0c05cad32a

+ 18 - 0
game/systems/nation_registry.cpp

@@ -142,6 +142,24 @@ void NationRegistry::initializeDefaults() {
   knight.priority = 10;
   kingdomOfIron.availableTroops.push_back(knight);
 
+  TroopType spearman;
+  spearman.unitType = Game::Units::TroopType::Spearman;
+  spearman.displayName = "Spearman";
+  spearman.isMelee = true;
+  spearman.cost = 75;
+  spearman.buildTime = 6.0f;
+  spearman.priority = 5;
+  kingdomOfIron.availableTroops.push_back(spearman);
+
+  TroopType mountedKnight;
+  mountedKnight.unitType = Game::Units::TroopType::MountedKnight;
+  mountedKnight.displayName = "Mounted Knight";
+  mountedKnight.isMelee = true;
+  mountedKnight.cost = 150;
+  mountedKnight.buildTime = 10.0f;
+  mountedKnight.priority = 15;
+  kingdomOfIron.availableTroops.push_back(mountedKnight);
+
   registerNation(std::move(kingdomOfIron));
 
   m_defaultNation = "kingdom_of_iron";

+ 79 - 5
ui/qml/ProductionPanel.qml

@@ -94,8 +94,8 @@ Rectangle {
                                             else
                                                 unitType = "archer";
                                         }
-                                        if (typeof Theme !== 'undefined' && Theme.unitIcons)
-                                            return Theme.unitIcons[unitType] || Theme.unitIcons["default"] || "👤";
+                                        if (typeof StyleGuide !== 'undefined' && StyleGuide.unitIcons)
+                                            return StyleGuide.unitIcons[unitType] || StyleGuide.unitIcons["default"] || "👤";
 
                                         return "🏹";
                                     }
@@ -270,7 +270,7 @@ Rectangle {
 
                                 Text {
                                     anchors.horizontalCenter: parent.horizontalCenter
-                                    text: (typeof Theme !== 'undefined' && Theme.unitIcons) ? Theme.unitIcons["archer"] || "🏹" : "🏹"
+                                    text: (typeof StyleGuide !== 'undefined' && StyleGuide.unitIcons) ? StyleGuide.unitIcons["archer"] || "🏹" : "🏹"
                                     color: parent.parent.parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
                                     font.pointSize: 24
                                 }
@@ -344,7 +344,7 @@ Rectangle {
 
                                 Text {
                                     anchors.horizontalCenter: parent.horizontalCenter
-                                    text: (typeof Theme !== 'undefined' && Theme.unitIcons) ? Theme.unitIcons["knight"] || "⚔️" : "⚔️"
+                                    text: (typeof StyleGuide !== 'undefined' && StyleGuide.unitIcons) ? StyleGuide.unitIcons["knight"] || "⚔️" : "⚔️"
                                     color: parent.parent.parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
                                     font.pointSize: 24
                                 }
@@ -418,7 +418,7 @@ Rectangle {
 
                                 Text {
                                     anchors.horizontalCenter: parent.horizontalCenter
-                                    text: (typeof Theme !== 'undefined' && Theme.unitIcons) ? Theme.unitIcons["spearman"] || "🛡️" : "🛡️"
+                                    text: (typeof StyleGuide !== 'undefined' && StyleGuide.unitIcons) ? StyleGuide.unitIcons["spearman"] || "🛡️" : "🛡️"
                                     color: parent.parent.parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
                                     font.pointSize: 24
                                 }
@@ -474,6 +474,80 @@ Rectangle {
 
                         }
 
+                        Rectangle {
+                            property int queueTotal: (unitGridContent.prod.inProgress ? 1 : 0) + (unitGridContent.prod.queueSize || 0)
+                            property bool isEnabled: unitGridContent.prod.hasBarracks && unitGridContent.prod.producedCount < unitGridContent.prod.maxUnits && queueTotal < 5
+
+                            width: 110
+                            height: 80
+                            radius: 6
+                            color: isEnabled ? (mountedKnightMouseArea.containsMouse ? "#34495e" : "#2c3e50") : "#1a1a1a"
+                            border.color: isEnabled ? "#4a6572" : "#2a2a2a"
+                            border.width: 2
+                            opacity: isEnabled ? 1 : 0.5
+
+                            Column {
+                                anchors.centerIn: parent
+                                spacing: 4
+
+                                Text {
+                                    anchors.horizontalCenter: parent.horizontalCenter
+                                    text: (typeof StyleGuide !== 'undefined' && StyleGuide.unitIcons) ? StyleGuide.unitIcons["mounted_knight"] || "🐴" : "🐴"
+                                    color: parent.parent.parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
+                                    font.pointSize: 24
+                                }
+
+                                Text {
+                                    anchors.horizontalCenter: parent.horizontalCenter
+                                    text: qsTr("Mounted Knight")
+                                    color: parent.parent.parent.isEnabled ? "#ecf0f1" : "#5a5a5a"
+                                    font.pointSize: 10
+                                    font.bold: true
+                                }
+
+                                Row {
+                                    anchors.horizontalCenter: parent.horizontalCenter
+                                    spacing: 4
+
+                                    Text {
+                                        text: "👥"
+                                        color: parent.parent.parent.parent.isEnabled ? "#f39c12" : "#5a5a5a"
+                                        font.pointSize: 9
+                                    }
+
+                                    Text {
+                                        text: unitGridContent.prod.villagerCost || 1
+                                        color: parent.parent.parent.parent.isEnabled ? "#f39c12" : "#5a5a5a"
+                                        font.pointSize: 9
+                                        font.bold: true
+                                    }
+
+                                }
+
+                            }
+
+                            MouseArea {
+                                id: mountedKnightMouseArea
+
+                                anchors.fill: parent
+                                hoverEnabled: true
+                                enabled: parent.isEnabled
+                                onClicked: productionPanel.recruitUnit("mounted_knight")
+                                cursorShape: parent.isEnabled ? Qt.PointingHandCursor : Qt.ForbiddenCursor
+                                ToolTip.visible: containsMouse
+                                ToolTip.text: parent.isEnabled ? qsTr("Recruit Mounted Knight\nCost: %1 villagers\nBuild time: %2s").arg(unitGridContent.prod.villagerCost || 1).arg((unitGridContent.prod.buildTime || 0).toFixed(0)) : (parent.queueTotal >= 5 ? qsTr("Queue is full (5/5)") : (unitGridContent.prod.producedCount >= unitGridContent.prod.maxUnits ? qsTr("Unit cap reached") : qsTr("Cannot recruit")))
+                                ToolTip.delay: 300
+                            }
+
+                            Rectangle {
+                                anchors.fill: parent
+                                color: "#ffffff"
+                                opacity: mountedKnightMouseArea.pressed ? 0.2 : 0
+                                radius: parent.radius
+                            }
+
+                        }
+
                     }
 
                 }

+ 7 - 0
ui/qml/StyleGuide.qml

@@ -123,4 +123,11 @@ QtObject {
         "normal": 160,
         "slow": 200
     })
+    readonly property var unitIcons: ({
+        "archer": "🏹",
+        "knight": "⚔️",
+        "spearman": "🛡️",
+        "mounted_knight": "🐴",
+        "default": "👤"
+    })
 }