-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest_v040_compatibility.py
More file actions
277 lines (212 loc) · 7.69 KB
/
test_v040_compatibility.py
File metadata and controls
277 lines (212 loc) · 7.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
"""
Test de compatibilité des frontends avec dnd-5e-core v0.4.0
Valide que tous les frontends fonctionnent avec la nouvelle version
"""
import sys
from pathlib import Path
# Ajouter le répertoire courant au path
sys.path.insert(0, str(Path(__file__).parent))
def test_dnd_5e_core_version():
"""Vérifier que dnd-5e-core v0.4.0+ est installé"""
print("\n" + "="*80)
print("TEST 1: Version dnd-5e-core")
print("="*80)
try:
import dnd_5e_core
version = dnd_5e_core.__version__
print(f"✅ dnd-5e-core installé: v{version}")
# Vérifier version >= 0.4.0
major, minor = map(int, version.split('.')[:2])
if major == 0 and minor >= 4:
print(f"✅ Version compatible (>= 0.4.0)")
return True
else:
print(f"⚠️ Version ancienne: {version}")
return False
except ImportError:
print("❌ dnd-5e-core non installé!")
return False
def test_main_py_imports():
"""Vérifier que main.py peut importer dnd-5e-core"""
print("\n" + "="*80)
print("TEST 2: main.py Imports")
print("="*80)
try:
# Simuler les imports de main.py
from dnd_5e_core import (
Character, Monster, Abilities, ClassType,
load_monster, simple_character_generator
)
print(f"✅ Imports basiques OK")
# Test création personnage avec ClassAbilities
fighter = simple_character_generator(level=5, class_name='fighter', name='Test')
if hasattr(fighter, 'multi_attacks'):
print(f"✅ ClassAbilities appliquées (Extra Attack: {fighter.multi_attacks})")
else:
print(f"⚠️ ClassAbilities non détectées")
return True
except Exception as e:
print(f"❌ Erreur: {e}")
import traceback
traceback.print_exc()
return False
def test_conditions_available():
"""Vérifier que le système de conditions est disponible"""
print("\n" + "="*80)
print("TEST 3: Système de Conditions")
print("="*80)
try:
from dnd_5e_core.combat.condition import (
Condition, ConditionType,
create_poisoned_condition
)
print(f"✅ Module condition importé")
condition = create_poisoned_condition()
print(f"✅ Condition créée")
return True
except Exception as e:
print(f"❌ Erreur: {e}")
return False
def test_magic_items_available():
"""Vérifier que les magic items sont disponibles"""
print("\n" + "="*80)
print("TEST 4: Magic Items")
print("="*80)
try:
from dnd_5e_core.equipment import (
create_ring_of_protection,
create_wand_of_magic_missiles,
create_staff_of_healing
)
items = [
create_ring_of_protection(),
create_wand_of_magic_missiles(),
create_staff_of_healing()
]
print(f"✅ {len(items)} magic items créés")
for item in items:
print(f" - {item.name} ({item.rarity.value})")
return True
except Exception as e:
print(f"❌ Erreur: {e}")
import traceback
traceback.print_exc()
return False
def test_multiclass_system():
"""Vérifier que le système de multiclassing est disponible"""
print("\n" + "="*80)
print("TEST 5: Système de Multiclassing")
print("="*80)
try:
from dnd_5e_core.classes.multiclass import (
can_multiclass_into,
MULTICLASS_PREREQUISITES
)
print(f"✅ Module multiclass importé")
print(f"✅ {len(MULTICLASS_PREREQUISITES)} classes supportées")
return True
except Exception as e:
print(f"❌ Erreur: {e}")
return False
def test_frontend_main_compatibility():
"""Vérifier compatibilité basique de main.py"""
print("\n" + "="*80)
print("TEST 6: Frontend main.py")
print("="*80)
try:
# On ne peut pas vraiment importer main.py sans lancer le jeu
# Mais on peut vérifier que le fichier existe et contient les bons imports
main_file = Path(__file__).parent / "main.py"
if not main_file.exists():
print(f"❌ main.py non trouvé")
return False
content = main_file.read_text()
# Vérifier imports clés
required_imports = [
"from dnd_5e_core",
"Character",
"Monster"
]
missing = []
for imp in required_imports:
if imp not in content:
missing.append(imp)
if missing:
print(f"⚠️ Imports manquants: {missing}")
else:
print(f"✅ main.py utilise dnd-5e-core")
# Vérifier migration marker
if "[MIGRATION v2]" in content or "dnd-5e-core package" in content:
print(f"✅ main.py migré vers dnd-5e-core")
return True
except Exception as e:
print(f"❌ Erreur: {e}")
return False
def test_pygame_compatibility():
"""Vérifier compatibilité de dungeon_pygame.py"""
print("\n" + "="*80)
print("TEST 7: Frontend Pygame")
print("="*80)
try:
pygame_file = Path(__file__).parent / "dungeon_pygame.py"
if not pygame_file.exists():
print(f"⚠️ dungeon_pygame.py non trouvé")
return True # Pas bloquant
content = pygame_file.read_text()
if "from dnd_5e_core" in content:
print(f"✅ dungeon_pygame.py utilise dnd-5e-core")
else:
print(f"⚠️ dungeon_pygame.py n'utilise pas dnd-5e-core?")
return True
except Exception as e:
print(f"⚠️ Erreur (non bloquant): {e}")
return True
def run_all_tests():
"""Exécuter tous les tests de compatibilité"""
print("\n" + "🧪"*40)
print("TESTS DE COMPATIBILITÉ FRONTENDS - dnd-5e-core v0.4.0")
print("🧪"*40)
tests = [
("Version dnd-5e-core", test_dnd_5e_core_version),
("main.py Imports", test_main_py_imports),
("Système de Conditions", test_conditions_available),
("Magic Items", test_magic_items_available),
("Multiclassing", test_multiclass_system),
("Frontend main.py", test_frontend_main_compatibility),
("Frontend Pygame", test_pygame_compatibility),
]
results = []
for test_name, test_func in tests:
try:
result = test_func()
results.append((test_name, result))
except Exception as e:
print(f"\n❌ ERREUR dans {test_name}: {e}")
results.append((test_name, False))
# Résumé
print("\n" + "="*80)
print("📊 RÉSUMÉ DES TESTS")
print("="*80)
passed = 0
for test_name, result in results:
status = "✅ SUCCÈS" if result else "❌ ÉCHEC"
print(f"{status}: {test_name}")
if result:
passed += 1
print(f"\nScore: {passed}/{len(results)} ({passed*100//len(results)}%)")
if passed == len(results):
print("\n🎉 TOUS LES TESTS RÉUSSIS!")
print("✅ DnD-5th-Edition-API est compatible avec dnd-5e-core v0.4.0")
print("\n💡 Les frontends bénéficient automatiquement:")
print(" - ClassAbilities (Extra Attack, Rage, etc.)")
print(" - RacialTraits (Darkvision, Lucky, etc.)")
print(" - Conditions (Poisoned, Restrained, etc.)")
print(" - Magic Items (10+ items prédéfinis)")
print(" - Multiclassing (validation + spell slots)")
return True
else:
print(f"\n⚠️ {len(results) - passed} test(s) échoué(s)")
return False
if __name__ == "__main__":
success = run_all_tests()
sys.exit(0 if success else 1)