J'ai commencé a apprendre a coder la semaine dernière en regardant des vidéos et surtout grâce a ChatGPT, et j'aimerai avoir l'avis de personnes confirmés sur ma manière de coder, et si possibles me donner des conseils pour optimiser mon code.

J'ai commencé par faire quelques codes tests, mais je me suis principalement concentré sur un code pour un jeu.

Quand le jeu commence vous arrivez sur un exemple de map:
@ représente votre joueur et $ est un marchand
Vous pouvez utiliser "zqsd" pour vous déplacer et "menu" pour ouvrir un menu avec des actions disponnibles.

Mon but est d'apprendre a coder, donc j'évite d'importer des bibliothèques exterieurs a Python.


Voici mon code pour l'instant:
Jus.py

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
 
 
import random
import time
import datetime
from text import read
from text import input_read
import math
 
 
game_date = datetime.datetime(793, 7, 30, 12, 0, 0)#Défini la date de départ du jeu
 
# La liste des poissons avec leur poids et leur valeur monétaire
poissons = {
    'carpe':{
        "name": "carpe",
        "quantity": 0,
        "price": 3,
        "description": "Restaure 50 points de vie."
    },
    'truite': {
        "name": "truite",
        "quantity": 0,
        "price": 5,
        "description": "Restaure 50 points de vie."
    },
    'saumon': {
        "name": "saumon",
        "quantity": 0,
        "price": 10,
        "description": "Restaure 50 points de vie."
    },
    'poisson-chat': {
        "name": "poisson-chat",
        "quantity": 0,
        "price": 12,
        "description": "Restaure 50 points de vie."
    },
}
#La liste des recettes possibles avec leurs résultats
recipes = {
    "hache en silex" :
        {
        "name": "hache en silex",
        "ingredients": {"branche taillée": 1, "silex": 1, "ficelle": 2},
        "result":
            {
            "name": "hache en silex",
            "quantity": 0,
            "price": 10,
            "description": "Restaure 50 points de vie."
             }
        },
    "tissus propre":
        {
        "name": "tissus propre",
        "ingredients": {"tissus sale": 1, "eau": 1},
        "result":
            {
            "name": "tissus propre",
            "quantity": 0,
            "price": 10,
            "description": "Restaure 50 points de vie."
             }
        }
}
 
#Définition de la classe Marchand
class Marchand:
    def __init__(self, name):
        self.name = name
        self.body_parts = {}
        self.inventory = {}
        self.pieces_or = 50
        self.map = {}
 
    def show_inventory(self):
        if not self.inventory:
            read("L'inventaire inventaire de {} est vide.".format(self.name))
        else:
            print()
            read("{} propose de vendre :".format(self.name))
            for item, item_data in self.inventory.items():
                read(f"-{item_data['name'].capitalize()}   x{item_data['quantity']}")
        read("il a {} pièces d'or.".format(self.pieces_or))
 
    def add_inventory(self, item_add, quantity=1):
        if item_add["name"] in self.inventory:
            self.inventory[item_add["name"]]["quantity"] += quantity
        else:
            self.inventory[item_add["name"]] = {
                "name": item_add["name"],
                "quantity": quantity,
                "price": item_add["price"],
                "description": item_add["description"]
            }
 
    def remove_inventory(self, item_remove, quantity=1):
        if item_remove["name"] in self.inventory:
            self.inventory[item_remove["name"]]["quantity"] -= quantity
            if self.inventory[item_remove["name"]]["quantity"] <= 0:
                del self.inventory[item_remove["name"]]
 
 
# Définition de la classe Personnage
class Personnage:
    def __init__(self, name, sexe, age):
        self.name = name
        self.sexe = sexe
        self.age = age
        self.inventory = {}
        self.pieces_or = 10
        self.body_parts = {}
        self.stats = {}
        self.map = {}
 
    def move (self): #Permet de bouger sur la map
        move = input("Move")
        if move == "z":
            self.map["y"] -= 1
        elif move == "q":
            self.map["x"] -= 1
        elif move == "s":
            self.map["y"] += 1
        elif move == "d":
            self.map["x"] += 1
        elif move == "menu":
            self.show_menu()
        else:
            print("Invalid key.")
 
    def show_menu (self): # Affichage du menu du jeu
        while True :
            print()
            read("Que souhaitez vous faire ?")
            print()
            read("1- Aller chez le marchand")
            read("2- Pecher")
            read("3- Crafter")
            read("4- Voir votre inventaire")
            read("5- Voir vos stats")
            read("6- Quitter le jeu")
            read("7- Attaquer le marchand")
            print()
            choice = input_read("Entrez votre choix (1-6) : ")
 
            if choice == "marchand" or choice == "1":
                personnage.aller_chez_le_marchand()
            elif choice == "peche" or choice == "2":
                personnage.pecher()
            if choice == "3":
                personnage.craft_item()
 
            elif choice == "inventaire" or choice == "4":
                personnage.navigate_inventory()
            elif choice == "stats" or choice == "5":
                personnage.show_stats()
            elif choice == "quit" or choice == "6":
                break
            elif choice == "mal" or choice == "7":
                personnage.attack(marchand1)
 
 
    def calcul_damage(self):
        return random.randint(1 + 1 * self.stats["Force"]["Niveau"], 3 + 2 * self.stats["Force"]["Niveau"])
 
    def target_body_part(self, target):
        target_body_limb = random.choice(list(target.body_parts.keys()))
        target_body_part = random.choice(list(target.body_parts[target_body_limb]["sous_partie"].keys()))
        hit_parts = {target_body_limb: target_body_part}
        return hit_parts
 
    def damage_body_parts(self, target, hit_parts, damage):
        # necessite la création d'une liste tel que : {body_limb : body_part}
        for body_limb, body_part in hit_parts.items():
            body_limb_hit = target.body_parts[body_limb]
            if body_limb_hit is not None:
                target.body_parts[body_limb]["points_de_vie"] -= damage
                read("{} -{}PV    PV restants: {}".format(body_limb, damage,
                                                           target.body_parts[body_limb]["points_de_vie"]))
            else:
                print(f"{body_limb} non trouvé")
 
        for body_limb, body_part in hit_parts.items():
            body_part_hit = target.body_parts[body_limb]["sous_partie"][body_part]
            if body_part_hit is not None:
                target.body_parts[body_limb]["sous_partie"][body_part]["points_de_vie"] -= damage
                read("{} -{}PV    PV restants: {}".format(body_part, damage,
                                                           target.body_parts[body_limb]["sous_partie"][body_part][
                                                               "points_de_vie"]))
            else:
                print(f"{body_part} non trouvé")
 
    def attack(self, target):
        read("{} attaque {} !".format(self.name, target.name))
        hit_parts = self.target_body_part(target)
        damage = self.calcul_damage()
        self.damage_body_parts(target, hit_parts, damage)
 
    def show_inventory(self):
        if not self.inventory:
            read("Votre inventaire est vide.")
        else:
            print()
            read("Inventaire :")
            for item, item_data in self.inventory.items():
                read(f"-{item_data['name'].capitalize()}   x{item_data['quantity']}")
            read("Vous avez {} pièces d'or.".format(self.pieces_or))
 
    def navigate_inventory(self):
        while True:
            self.show_inventory()
            print()
            item_select = input_read("Selectionner un item ou quitter l'inventaire (0)")
            print()
            if item_select == "0":
                break
            if item_select not in self.inventory :
                read("Vous ne possedez pas cet item.")
            else:
                while True :
                    action_item = input_read("Item selectionné : {} 1)Lire la description 2)Drop 3)Annuler".format(self.inventory[item_select]["name"]))
                    print()
                    if action_item == "1" :
                        read(self.inventory[item_select]["description"])
                        print()
                    if action_item == "2" :
                        self.remove_inventory(self.inventory[item_select],1)
                        break
                    if action_item == "3" :
                        break
 
 
    def add_inventory(self, item_add, quantity=1):
        if item_add["name"] in self.inventory:
            self.inventory[item_add["name"]]["quantity"] += quantity
        else:
            self.inventory[item_add["name"]] = {
                "name": item_add["name"],
                "quantity": quantity,
                "price": item_add["price"],
                "description": item_add["description"]
            }
 
    def remove_inventory(self, item_remove, quantity=1):
        if item_remove["name"] in self.inventory:
            self.inventory[item_remove["name"]]["quantity"] -= quantity
            if self.inventory[item_remove["name"]]["quantity"] <= 0:
                del self.inventory[item_remove["name"]]
 
    def show_stats (self) :
        for i in self.stats :
            read("{}        Niveau {}".format(i,self.stats[i]["Niveau"]))
 
 
    def craft_item(self):
        while True:
            # Affiche les recettes disponibles
            read("Recettes :")
            for i, recipe in enumerate(recipes):
                read(f"{i + 1}. {recipes[recipe]['name']}")
            # Demande à l'utilisateur de choisir une recette
            recipe_choice = int(
                input_read(
                    "Entrez le numéro de la recette que vous souhaitez crafter (ou '0' pour annuler) : "))
            if recipe_choice == 0:
                break
            # Vérifie que l'index de recette est valide
            if recipe_choice < 0 or recipe_choice >= (len(recipes) + 1):
                read("Recette invalide.")
            else:
                recipe = list(recipes.values())[recipe_choice - 1]
                # Vérifie si tous les ingrédients sont disponibles dans l'inventaire
                for ingredient, quantity in recipe["ingredients"].items():
                    if ingredient not in self.inventory or self.inventory[ingredient]["quantity"] < quantity:
                        read("Vous n'avez pas tous les ingrédients nécessaires.")
                        return False
                for ingredient, quantity in recipe["ingredients"].items():#retire les ingredients de l'inventaire
                    self.remove_inventory(self.inventory[ingredient], quantity)
                # Ajoute l'objet résultant à l'inventaire
                item_add = recipe["result"]
                self.add_inventory(item_add,1)
                read("Vous avez fabriqué un(e) {}.".format(recipe["name"]))
                print()
 
 
    def pecher(self):
        if 'canne à pêche' not in self.inventory:
            read("Vous n'avez pas de canne à pêche.")
            return
        read("Vous lancez votre ligne à l'eau...")
        time.sleep(2)
        key = random.choice(list(poissons.keys()))
        poisson = poissons[key]
        self.add_inventory(poisson,1)
        read("Vous avez attrapé un {},  il vaut {} pièces d'or.".format(poisson["name"],poisson["price"]))
 
    def aller_chez_le_marchand(self):
        self.show_inventory()
        marchand1.show_inventory()
        # demander à l'utilisateur ce qu'il veut acheter ou vendre
        print()
        action = input_read("Que voulez-vous faire ? acheter ou vendre?")
        print()
        if action == "acheter":
            marchand1.show_inventory()
 
            # demander à l'utilisateur ce qu'il veut acheter et combien
            print()
            item_choice = input_read("Que voulez-vous acheter ? ")
            print()
            if item_choice not in marchand1.inventory:
                print()
                read("Le marchand ne vend pas cet article.")
                print()
                return
            item_buy = marchand1.inventory[item_choice]
            price = item_buy["price"]
            print()
            quantity = input_read("Combien de {} voulez-vous acheter ? ".format(item_buy["name"]))
            quantity = int(quantity)
 
            if self.pieces_or < price * quantity:
                print()
                read("Vous n'avez pas assez d'argent.")
                print()
                return
 
            self.add_inventory(item_buy, quantity)
            self.pieces_or -= price * quantity
            marchand1.remove_inventory(item_buy, quantity)
            marchand1.pieces_or += price * quantity
            print()
            read("Vous avez acheté {} {} pour {} pièces d'or.".format(quantity, item_buy["name"],price * quantity))
            print()
            self.show_inventory()
            marchand1.show_inventory()
 
        elif action == "vendre":
            # demander à l'utilisateur ce qu'il veut vendre et combien
            self.show_inventory()
            print()
            item_choice = input_read("Que voulez-vous vendre ? ")
            print()
            if item_choice not in self.inventory:
                print()
                read("Vous n'avez pas cet article.")
                print()
                return
            item_sell = self.inventory[item_choice]
            price = item_sell["price"]
            print()
            quantity = input_read("Combien de {} voulez-vous vendre ? ".format(item_sell["name"]))
            print()
            quantity = int(quantity)
 
            self.remove_inventory(item_sell, quantity)
            self.pieces_or += price * quantity
            marchand1.add_inventory(item_sell, quantity)
            marchand1.pieces_or -= price * quantity
            print()
            read("Vous avez vendu {} pour {} pièces d'or.".format(quantity, item_sell["name"], price * quantity))
            print()
            self.show_inventory()
            marchand1.show_inventory()
 
 
marchand1 = Marchand ("Pierre")#Crée un Marchand Pierre, défini son inventaire et ses body parts
marchand1.body_parts = {
    "tête": {
        "points_de_vie": 10,
        "sous_partie": {
            "crâne" : {"points_de_vie" : 5, },
            "joue gauche": {"points_de_vie" : 5, },
            "joue droite": {"points_de_vie" : 5, },
            "front": {"points_de_vie" : 5, },
            "oeil gauche": {"points_de_vie" : 5, },
            "oeil droit": {"points_de_vie" : 5, },
            "nez": {"points_de_vie" : 5, },
            "bouche": {"points_de_vie" : 5, },
            "menton": {"points_de_vie" : 5, },
            "oreille droite": {"points_de_vie" : 5, },
            "oreille gauche": {"points_de_vie" : 5, }
        },
    },
    "cou": {
        "points_de_vie": 8,
        "sous_partie": {},
    },
    "bras gauche": {
        "points_de_vie": 8,
        "sous_partie": {
            "épaule gauche": {"points_de_vie": 5},
            "biceps gauche": {"points_de_vie" : 5, },
            "triceps gauche": {"points_de_vie" : 5, },
            "avant-bras gauche": {"points_de_vie" : 5, },
            "coude gauche": {"points_de_vie" : 5, },
            "poignet gauche": {"points_de_vie" : 5, },
            "main gauche": {"points_de_vie" : 5, }
            },
    },
    "bras droit": {
        "points_de_vie": 8,
        "sous_partie": {
            "épaule droite": {"points_de_vie": 5},
            "biceps droit": {"points_de_vie" : 5, },
            "triceps droit": {"points_de_vie" : 5, },
            "avant-bras droit": {"points_de_vie" : 5, },
            "coude droit": {"points_de_vie" : 5, },
            "poignet droit": {"points_de_vie" : 5, },
            "main droite": {"points_de_vie" : 5, }
            },
    },
    "dos": {
        "points_de_vie": 10,
        "sous_partie": {
            "trapèzes": {"points_de_vie" : 5, },
            "rhomboïdes": {"points_de_vie" : 5, },
            "lombaires": {"points_de_vie" : 5, }
        },
    },
    "abdomen": {
        "points_de_vie": 10,
        "sous_partie": {
            "abdominaux": {"points_de_vie" : 5, },
            "pectoral gauche": {"points_de_vie" : 5, },
            "pectoral droit": {"points_de_vie" : 5, },
            "sternum": {"points_de_vie" : 5, }
        },
    },
    "hanche": {
        "points_de_vie": 7,
        "sous_partie": {
            "fessiers": {"points_de_vie" : 5, },
            "hanches": {"points_de_vie" : 5, }
            },
    },
    "jambe gauche": {
        "points_de_vie": 8,
        "sous_partie": {
            "cuisse gauche": {"points_de_vie" : 5, },
            "mollet gauche": {"points_de_vie" : 5, },
            "genou gauche": {"points_de_vie" : 5, },
            "cheville gauche": {"points_de_vie" : 5, },
            "pied gauche": {"points_de_vie" : 5, }},
    },
    "jambe droite": {
        "points_de_vie": 8,
        "sous_partie": {
            "cuisse droite": {"points_de_vie" : 5, },
            "mollet droit": {"points_de_vie" : 5, },
            "genou droit": {"points_de_vie" : 5, },
            "cheville droite": {"points_de_vie" : 5, },
            "pied droit": {"points_de_vie" : 5, }},
    },
}
marchand1.inventory = {
    "branche taillée": {
        "name": "branche taillée",
        "quantity": 5,
        "price": 10,
        "description": "Restaure 50 points de vie."
    },
    "silex": {
        "name": "silex",
        "quantity": 1,
        "price": 7,
        "description": "Une épée en fer standard."
    },
    "ficelle": {
        "name": "ficelle",
        "quantity": 2,
        "price": 20,
        "description": "Un bouclier en bois standard."
    },
    "eau": {
        "name": "eau",
        "quantity": 2,
        "price": 20,
        "description": "Un bouclier en bois standard."
    },
    "tissus sale": {
        "name": "tissus sale",
        "quantity": 2,
        "price": 20,
        "description": "Un bouclier en bois standard."
    },
    "canne à pêche": {
            "name": "canne à pêche",
            "quantity": 1,
            "price": 10,
            "description": "Restaure 50 points de vie."
    },
}
marchand1.map = {"x": 45, "y": 20, "shape": "$"}#Défini où le personnage se trouve sur la carte
 
read("Bienvenue dans cette aventure !")#Premier texte d'arrivé
 
name = input_read("Entrez votre nom : ")#Initier les valeurs du joueur
age = input_read("Entrez votre âge : ")
sexe = input_read("Entrez votre sexe : ")
personnage = Personnage(name, sexe, age)
personnage.inventory = {
    "branche taillée": {
        "name": "branche taillée",
        "quantity": 5,
        "price": 10,
        "description": "Restaure 50 points de vie."
    },
    "silex": {
        "name": "silex",
        "quantity": 1,
        "price": 50,
        "description": "Une épée en fer standard."
    },
    "ficelle": {
        "name": "ficelle",
        "quantity": 2,
        "price": 20,
        "description": "Un bouclier en bois standard."
    },
    "eau": {
        "name": "eau",
        "quantity": 2,
        "price": 20,
        "description": "Un bouclier en bois standard."
    },
    "tissus sale": {
        "name": "tissus sale",
        "quantity": 2,
        "price": 20,
        "description": "Un bouclier en bois standard."
    }
}#Défini l'inventaire, les body parts, et les stats du joueur
personnage.body_parts = {
    "tête": {
        "points_de_vie": 10,
        "sous_partie": {
            "crâne" : {"points_de_vie" : 5, },
            "joue gauche": {"points_de_vie" : 5, },
            "joue droite": {"points_de_vie" : 5, },
            "front": {"points_de_vie" : 5, },
            "oeil gauche": {"points_de_vie" : 5, },
            "oeil droit": {"points_de_vie" : 5, },
            "nez": {"points_de_vie" : 5, },
            "bouche": {"points_de_vie" : 5, },
            "menton": {"points_de_vie" : 5, },
            "oreille droite": {"points_de_vie" : 5, },
            "oreille gauche": {"points_de_vie" : 5, }
        },
    },
    "cou": {
        "points_de_vie": 8,
        "sous_partie": {},
    },
    "bras gauche": {
        "points_de_vie": 8,
        "sous_partie": {
            "épaule gauche": {"points_de_vie": 5},
            "biceps gauche": {"points_de_vie" : 5, },
            "triceps gauche": {"points_de_vie" : 5, },
            "avant-bras gauche": {"points_de_vie" : 5, },
            "coude gauche": {"points_de_vie" : 5, },
            "poignet gauche": {"points_de_vie" : 5, },
            "main gauche": {"points_de_vie" : 5, }
            },
    },
    "bras droit": {
        "points_de_vie": 8,
        "sous_partie": {
            "épaule droite": {"points_de_vie": 5},
            "biceps droit": {"points_de_vie" : 5, },
            "triceps droit": {"points_de_vie" : 5, },
            "avant-bras droit": {"points_de_vie" : 5, },
            "coude droit": {"points_de_vie" : 5, },
            "poignet droit": {"points_de_vie" : 5, },
            "main droite": {"points_de_vie" : 5, }
            },
    },
    "dos": {
        "points_de_vie": 10,
        "sous_partie": {
            "trapèzes": {"points_de_vie" : 5, },
            "rhomboïdes": {"points_de_vie" : 5, },
            "lombaires": {"points_de_vie" : 5, }
        },
    },
    "abdomen": {
        "points_de_vie": 10,
        "sous_partie": {
            "abdominaux": {"points_de_vie" : 5, },
            "pectoral gauche": {"points_de_vie" : 5, },
            "pectoral droit": {"points_de_vie" : 5, },
            "sternum": {"points_de_vie" : 5, }
        },
    },
    "hanche": {
        "points_de_vie": 7,
        "sous_partie": {
            "fessiers": {"points_de_vie" : 5, },
            "hanches": {"points_de_vie" : 5, }
            },
    },
    "jambe gauche": {
        "points_de_vie": 8,
        "sous_partie": {
            "cuisse gauche": {"points_de_vie" : 5, },
            "mollet gauche": {"points_de_vie" : 5, },
            "genou gauche": {"points_de_vie" : 5, },
            "cheville gauche": {"points_de_vie" : 5, },
            "pied gauche": {"points_de_vie" : 5, }},
    },
    "jambe droite": {
        "points_de_vie": 8,
        "sous_partie": {
            "cuisse droite": {"points_de_vie" : 5, },
            "mollet droit": {"points_de_vie" : 5, },
            "genou droit": {"points_de_vie" : 5, },
            "cheville droite": {"points_de_vie" : 5, },
            "pied droit": {"points_de_vie" : 5, }},
    },
}
personnage.stats = {
    "Force" :{
        "Niveau" : 0
    },
    "Agilité": {
        "Niveau" : 0
    },
    "Endurance": {
        "Niveau" : 0
    },
    "Perception": {
        "Niveau" : 0
    },
    "Intelligence": {
        "Niveau" : 0
    },
    "Charisme": {
        "Niveau" : 0
    },
    "Chance": {
        "Niveau" : 0
    },
 
}
personnage.map = {"x": 50, "y": 20,"shape": "@"}#Défini où le personnage se trouve sur la carte
 
dimension = {"x": 150, "y": 30}#Crée la taille de la fenêtre de jeu, puis importe les localisation des personnage,...
points = [{"x": 30, "y": 20,"shape": "&"}, marchand1.map, {"x": 90, "y": 10, "shape": "#"},personnage.map]
 
logo = """
 ___ ___                       ______                                                  __   _______     __                       __
|   |   |.-----..--.--..----. |   __ \.-----..----..-----..-----..-----..-----..---.-.|  | |   _   |.--|  |.--.--..-----..-----.|  |_ .--.--..----..-----.
 \     / |  _  ||  |  ||   _| |    __/|  -__||   _||__ --||  _  ||     ||     ||  _  ||  | |       ||  _  ||  |  ||  -__||     ||   _||  |  ||   _||  -__|
  |___|  |_____||_____||__|   |___|   |_____||__|  |_____||_____||__|__||__|__||___._||__| |___|___||_____| \___/ |_____||__|__||____||_____||__|  |_____|
"""
print(logo)
 
read("Bienvenue dans notre aventure {} !".format(personnage.name))
read("Nous sommes le {}".format(game_date.strftime("%d/%m/%Y, %H:%M")))
 
#Boucle du jeu
while True:
    #Affichage de la fenêtre de jeu
    for i in range(dimension["y"]):
        row = ""
        for j in range(dimension["x"]):
            has_b = False
            for point in points:
                if point["x"] - 1 == j and point["y"] == i:
                    row += point["shape"]
                    has_b = True
                    break
            if not has_b:
                row += " "
        print(row)
    if math.sqrt((personnage.map["x"] - marchand1.map["x"])**2 + (personnage.map["y"] - marchand1.map["y"])**2) <= 1 :
        action = input("Appuie sur a pour parler à {}".format(marchand1.name))
        if action == "a" :
            personnage.aller_chez_le_marchand()
        else :
            personnage.move()
    else :
        personnage.move()
EDIT (La methode read):
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 
import time
 
def read(texte):
    texte = texte.center(150)
    for i, c in enumerate(texte):
        if c.isspace():
            print(c, end='')
        else:
            print(texte[i], end='', flush=True)
            time.sleep(0.02)
    print() # Ajout d'un retour à la ligne à la fin
 
# Utilisation de la fonction
 
 
def input_read(message):
    read(message)
    return input()