Spaces:
Sleeping
Sleeping
Commit
·
e38635d
1
Parent(s):
73216d8
a9
Browse files
app.py
CHANGED
|
@@ -7,23 +7,29 @@ import shutil
|
|
| 7 |
import re
|
| 8 |
|
| 9 |
def format_colors(text):
|
| 10 |
-
"""
|
| 11 |
-
# Substituições específicas antes da limpeza geral
|
| 12 |
-
text = text.replace("\\u001B[31m", "<span style='color:red;'>")
|
| 13 |
-
text = text.replace("\\u001B[34m", "<span style='color:blue;'>")
|
| 14 |
-
text = text.replace("\\u001B[32m", "<span style='color:green;'>")
|
| 15 |
-
text = text.replace("\\u001B[0m", "</span>")
|
| 16 |
|
| 17 |
-
#
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
text = text.replace("[32m", "<span style='color:green;'>")
|
| 21 |
-
text = text.replace("[0m", "</span>")
|
| 22 |
-
|
| 23 |
-
# Padrão para capturar códigos ANSI restantes e removê-los
|
| 24 |
-
ansi_pattern = r'\x1b\[[0-9;]*m'
|
| 25 |
text = re.sub(ansi_pattern, '', text)
|
| 26 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
return text
|
| 28 |
|
| 29 |
def check_and_install_java():
|
|
@@ -82,6 +88,14 @@ import java.util.Random;
|
|
| 82 |
* - radar: Radar (0-10) - Capacidade de detectar projéteis inimigos
|
| 83 |
* - doubleShot: Tiro duplo (0-10) - Permite disparar em duas altitudes diferentes
|
| 84 |
* - nuclearPower: Poder nuclear (0-10) - Poder do míssil nuclear (dano massivo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
*/
|
| 86 |
public class Team1Aircraft extends Aircraft {
|
| 87 |
private Random random = new Random();
|
|
@@ -101,7 +115,7 @@ public class Team1Aircraft extends Aircraft {
|
|
| 101 |
2, // Radar (0-10)
|
| 102 |
2, // Tiro duplo (0-10)
|
| 103 |
1, // Poder nuclear (0-10)
|
| 104 |
-
"
|
| 105 |
);
|
| 106 |
|
| 107 |
// IMPORTANTE: A soma de todos os atributos deve ser <= 100
|
|
@@ -229,6 +243,14 @@ import java.util.Random;
|
|
| 229 |
* - radar: Radar (0-10) - Capacidade de detectar projéteis inimigos
|
| 230 |
* - doubleShot: Tiro duplo (0-10) - Permite disparar em duas altitudes diferentes
|
| 231 |
* - nuclearPower: Poder nuclear (0-10) - Poder do míssil nuclear (dano massivo)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 232 |
*/
|
| 233 |
public class Team2Aircraft extends Aircraft {
|
| 234 |
private Random random = new Random();
|
|
@@ -248,7 +270,7 @@ public class Team2Aircraft extends Aircraft {
|
|
| 248 |
2, // Radar (0-10)
|
| 249 |
2, // Tiro duplo (0-10)
|
| 250 |
1, // Poder nuclear (0-10)
|
| 251 |
-
"
|
| 252 |
);
|
| 253 |
|
| 254 |
// IMPORTANTE: A soma de todos os atributos deve ser <= 100
|
|
@@ -645,9 +667,9 @@ public class BattleMain {{
|
|
| 645 |
}}
|
| 646 |
}}
|
| 647 |
|
| 648 |
-
// Posicionar aeronaves no campo de batalha
|
| 649 |
-
battlefield[team1.getPositionY()][p1PosX] =
|
| 650 |
-
battlefield[team2.getPositionY()][p2PosX] =
|
| 651 |
|
| 652 |
// Mover projéteis e verificar colisões
|
| 653 |
Iterator<Projectile> iterator = projectiles.iterator();
|
|
@@ -727,14 +749,9 @@ public class BattleMain {{
|
|
| 727 |
continue;
|
| 728 |
}}
|
| 729 |
|
| 730 |
-
// Mostrar projéteis no campo de batalha
|
| 731 |
if (p.posX >= 0 && p.posX < screenWidth && p.posY >= 0 && p.posY < battlefieldHeight) {{
|
| 732 |
-
|
| 733 |
-
if (p.direction > 0) {{
|
| 734 |
-
battlefield[p.posY][p.posX] = "\\u001B[34m" + p.symbol + "\\u001B[0m"; // Azul para Time 1
|
| 735 |
-
}} else {{
|
| 736 |
-
battlefield[p.posY][p.posX] = "\\u001B[31m" + p.symbol + "\\u001B[0m"; // Vermelho para Time 2
|
| 737 |
-
}}
|
| 738 |
}}
|
| 739 |
}}
|
| 740 |
|
|
|
|
| 7 |
import re
|
| 8 |
|
| 9 |
def format_colors(text):
|
| 10 |
+
"""Aplica cores no HTML baseado nos símbolos"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
+
# Primeiro, remover qualquer código ANSI que possa existir
|
| 13 |
+
import re
|
| 14 |
+
ansi_pattern = r'\x1b\[[0-9;]*m|\[([0-9;]*)m'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
text = re.sub(ansi_pattern, '', text)
|
| 16 |
|
| 17 |
+
# Colorir baseado nos símbolos
|
| 18 |
+
# Time 1 (azul): > e projéteis que vão para direita
|
| 19 |
+
text = text.replace('>', '<span style="color:blue; font-weight:bold;">></span>')
|
| 20 |
+
text = text.replace('->', '<span style="color:blue;">-></span>')
|
| 21 |
+
text = text.replace('>>', '<span style="color:blue;">>></span>')
|
| 22 |
+
text = text.replace('=>', '<span style="color:blue;">=></span>')
|
| 23 |
+
text = text.replace('-N->', '<span style="color:blue;">-N-></span>')
|
| 24 |
+
|
| 25 |
+
# Time 2 (vermelho): < e projéteis que vão para esquerda
|
| 26 |
+
text = text.replace('<span style="color:blue; font-weight:bold;">></span><span style="color:blue;">=></span>', '<span style="color:blue;">=></span>') # Fix overlap
|
| 27 |
+
text = text.replace('<', '<span style="color:red; font-weight:bold;"><</span>')
|
| 28 |
+
text = text.replace('<-', '<span style="color:red;"><-</span>')
|
| 29 |
+
text = text.replace('<<', '<span style="color:red;"><<</span>')
|
| 30 |
+
text = text.replace('<=', '<span style="color:red;"><=</span>')
|
| 31 |
+
text = text.replace('<-N-', '<span style="color:red;"><-N-</span>')
|
| 32 |
+
|
| 33 |
return text
|
| 34 |
|
| 35 |
def check_and_install_java():
|
|
|
|
| 88 |
* - radar: Radar (0-10) - Capacidade de detectar projéteis inimigos
|
| 89 |
* - doubleShot: Tiro duplo (0-10) - Permite disparar em duas altitudes diferentes
|
| 90 |
* - nuclearPower: Poder nuclear (0-10) - Poder do míssil nuclear (dano massivo)
|
| 91 |
+
*
|
| 92 |
+
* SÍMBOLOS:
|
| 93 |
+
* - Aeronave: > (Time 1 em azul)
|
| 94 |
+
* - Tiro normal: ->
|
| 95 |
+
* - Tiro supersônico: >>
|
| 96 |
+
* - Míssil especial: =>
|
| 97 |
+
* - Tiro duplo: =>
|
| 98 |
+
* - Míssil nuclear: -N->
|
| 99 |
*/
|
| 100 |
public class Team1Aircraft extends Aircraft {
|
| 101 |
private Random random = new Random();
|
|
|
|
| 115 |
2, // Radar (0-10)
|
| 116 |
2, // Tiro duplo (0-10)
|
| 117 |
1, // Poder nuclear (0-10)
|
| 118 |
+
">" // Símbolo da aeronave (não altere)
|
| 119 |
);
|
| 120 |
|
| 121 |
// IMPORTANTE: A soma de todos os atributos deve ser <= 100
|
|
|
|
| 243 |
* - radar: Radar (0-10) - Capacidade de detectar projéteis inimigos
|
| 244 |
* - doubleShot: Tiro duplo (0-10) - Permite disparar em duas altitudes diferentes
|
| 245 |
* - nuclearPower: Poder nuclear (0-10) - Poder do míssil nuclear (dano massivo)
|
| 246 |
+
*
|
| 247 |
+
* SÍMBOLOS:
|
| 248 |
+
* - Aeronave: < (Time 2 em vermelho)
|
| 249 |
+
* - Tiro normal: <-
|
| 250 |
+
* - Tiro supersônico: <<
|
| 251 |
+
* - Míssil especial: <=
|
| 252 |
+
* - Tiro duplo: <=
|
| 253 |
+
* - Míssil nuclear: <-N-
|
| 254 |
*/
|
| 255 |
public class Team2Aircraft extends Aircraft {
|
| 256 |
private Random random = new Random();
|
|
|
|
| 270 |
2, // Radar (0-10)
|
| 271 |
2, // Tiro duplo (0-10)
|
| 272 |
1, // Poder nuclear (0-10)
|
| 273 |
+
"<" // Símbolo da aeronave (não altere)
|
| 274 |
);
|
| 275 |
|
| 276 |
// IMPORTANTE: A soma de todos os atributos deve ser <= 100
|
|
|
|
| 667 |
}}
|
| 668 |
}}
|
| 669 |
|
| 670 |
+
// Posicionar aeronaves no campo de batalha sem cores
|
| 671 |
+
battlefield[team1.getPositionY()][p1PosX] = team1.symbol; // Time 1
|
| 672 |
+
battlefield[team2.getPositionY()][p2PosX] = team2.symbol; // Time 2
|
| 673 |
|
| 674 |
// Mover projéteis e verificar colisões
|
| 675 |
Iterator<Projectile> iterator = projectiles.iterator();
|
|
|
|
| 749 |
continue;
|
| 750 |
}}
|
| 751 |
|
| 752 |
+
// Mostrar projéteis no campo de batalha sem cores
|
| 753 |
if (p.posX >= 0 && p.posX < screenWidth && p.posY >= 0 && p.posY < battlefieldHeight) {{
|
| 754 |
+
battlefield[p.posY][p.posX] = p.symbol;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 755 |
}}
|
| 756 |
}}
|
| 757 |
|