SecretOfGaia.Terrain.ajouterCarte C# (CSharp) Method

ajouterCarte() public method

public ajouterCarte ( SecretOfGaia.Carte curCarte, int position = -1, bool remplaceExistante = true ) : bool
curCarte SecretOfGaia.Carte
position int
remplaceExistante bool
return bool
        public override bool ajouterCarte(Carte curCarte, int position = -1, bool remplaceExistante = true)
        {
            if (positionsLibres.Count == 0)
            {
                return false;
            }
            int positionLibre = positionsLibres.First();
            _cartes[positionLibre] = curCarte;
            return true;
        }

Usage Example

        public void TestAjoutCarteEnTrop()
        {
            Terrain curPose = new Terrain(2);
            Assert.AreEqual(curPose.Count, 0, "Création de Terrain NOK");
            Carte maCarte1 = new Carte("Carte1", TypeCarte.Instantanee, 1, 1, 12);
            bool AjoutOK =  curPose.ajouterCarte(maCarte1);
            Carte maCarte2 = new Carte("Carte2", TypeCarte.Instantanee, 1, 1, 7);
            AjoutOK = curPose.ajouterCarte(maCarte2);
            Assert.AreEqual(true, AjoutOK, "Ajout Carte autorise NOK sur retour ajouterCarte");
            Assert.AreEqual(2, curPose.Count, "Ajout de 2 Cartes NOK");
            Assert.AreEqual(maCarte2, curPose[2], "Ajout 2éme carte pas à la bonne position ");
            Assert.AreEqual(maCarte1, curPose.prochaineCarte, "Prochaine Carte NOK avec 2 éléements ");
            Carte maCarte3 = new Carte("Carte3", TypeCarte.Instantanee, 1, 1, 7);
            AjoutOK = curPose.ajouterCarte(maCarte3);
            Assert.AreEqual(false, AjoutOK, "Ajout Carte Interdite NOK sur retour ajouterCarte");
            Assert.AreEqual(2, curPose.Count, "Ajout de 2 Cartes NOK sur Count");

        }
All Usage Examples Of SecretOfGaia.Terrain::ajouterCarte