From c074ba7ae2b0b3b6ca1cae00e1d41ac7f6ac7b33 Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 27 Dec 2023 21:39:18 +0100 Subject: [PATCH] sanity check and error messages --- src/Butin/PieceButin.cpp | 1 + src/Dames/Dames.cpp | 4 ++++ src/Dames/PieceDames.cpp | 1 + src/Safari/PieceSafari.cpp | 1 + 4 files changed, 7 insertions(+) diff --git a/src/Butin/PieceButin.cpp b/src/Butin/PieceButin.cpp index bccd638..98f2f39 100644 --- a/src/Butin/PieceButin.cpp +++ b/src/Butin/PieceButin.cpp @@ -18,6 +18,7 @@ std::string PieceButin::to_string(const enum Categorie cat) const { return "Noire"; default: + std::cerr << "Catégorie inconnue (PieceButin).\n"; exit(EXIT_FAILURE); } } diff --git a/src/Dames/Dames.cpp b/src/Dames/Dames.cpp index d2f00f7..0d1b7f8 100644 --- a/src/Dames/Dames.cpp +++ b/src/Dames/Dames.cpp @@ -55,6 +55,10 @@ bool Dames::prisePossible(Joueur &joueur) const { int y = 1; for (int i = 0; i < pieces.size(); i++) { PieceDames *p = dynamic_cast(pieces[i]); + if (!p) { + std::cerr << "Cette pièce est.. étrange.\n"; + exit(EXIT_FAILURE); + } if (p->getDame()) { // if(plateau[x][y] == nullptr) } diff --git a/src/Dames/PieceDames.cpp b/src/Dames/PieceDames.cpp index 24ffd86..1b84825 100644 --- a/src/Dames/PieceDames.cpp +++ b/src/Dames/PieceDames.cpp @@ -23,6 +23,7 @@ std::string PieceDames::to_string(const enum Categorie cat) const { return "Noire"; default: + std::cerr << "Catégorie inconnue (PieceDames).\n"; exit(EXIT_FAILURE); } } diff --git a/src/Safari/PieceSafari.cpp b/src/Safari/PieceSafari.cpp index 7a9af78..07240fc 100644 --- a/src/Safari/PieceSafari.cpp +++ b/src/Safari/PieceSafari.cpp @@ -18,6 +18,7 @@ std::string PieceSafari::to_string(const enum Categorie cat) const { return "Lion"; default: + std::cerr << "Catégorie inconnue (PieceSafari).\n"; exit(EXIT_FAILURE); } }