Ejemplo n.º 1
0
        /// <summary>
        /// Lit l'ensemble des ordres d'ajustement notés dans les champs d'ordre
        /// (phase d'ajustement uniquement).
        /// </summary>
        /// <returns>Ensemble des ordres d'ajustement donnés pour le tour d'hiver courant.</returns>
        private List <Ajuster> LitAjustements()
        {
            Int32          compteur                = 0;
            Int32          placesDisponibles       = 0;
            String         belligerant             = null;
            List <Ajuster> ordresAjustements       = new List <Ajuster>();
            List <Ajuster> congediementTemporaires = new List <Ajuster>();

            foreach (ChampOrdre ordre in this.metaChampOrdre.ChampsOrdres)
            {
                Ajuster ordreAjustement = ordre.RetourneAjustement();
                congediementTemporaires.Add(ordreAjustement);
                if (ordre.NomBelligerant != belligerant)
                {
                    this.TraqueUnitesSuperfetatoires(compteur, placesDisponibles, congediementTemporaires, ordresAjustements);

                    congediementTemporaires.Clear();
                    belligerant = ordre.NomBelligerant;
                    compteur    = 0;
                    String nomCompletBelligerant = Convertisseurs.DepuisEBelligerantAbrege(ordre.NomBelligerant).ToString();
                    placesDisponibles = this.nombreCentres[nomCompletBelligerant] - this.nombreUnites[nomCompletBelligerant];
                }

                if (((ordreAjustement.Recrutement == EAjustement.Recrutement) && (compteur < placesDisponibles)) ||
                    (ordreAjustement.Recrutement == EAjustement.Congédiement))
                {
                    ordresAjustements.Add(ordreAjustement);
                    compteur++;
                }
            }

            this.TraqueUnitesSuperfetatoires(compteur, placesDisponibles, congediementTemporaires, ordresAjustements);
            return(ordresAjustements);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Classe les deux champs selon un ordre total (par belligérants, unité, et territoire).
 /// </summary>
 /// <param name="premierChamp">L'un des deux champs à comparer.</param>
 /// <param name="secondChamp">L'un des deux champs à comparer.</param>
 /// <returns>Valeur négative si premierChamp est avant premierChamp, et positive dans le cas opposé.</returns>
 public static Int32 ClasseChampsOrdres(ChampOrdre premierChamp, ChampOrdre secondChamp)
 {
     if (premierChamp.NomBelligerant != secondChamp.NomBelligerant)
     {
         EBelligerant premierBelligerant = Convertisseurs.DepuisEBelligerantAbrege(premierChamp.NomBelligerant);
         EBelligerant secondBelligerant  = Convertisseurs.DepuisEBelligerantAbrege(secondChamp.NomBelligerant);
         return(Convertisseurs.ClasseEBelligerants(premierBelligerant, secondBelligerant));
     }
     else
     {
         if (premierChamp.NomUnite != secondChamp.NomUnite)
         {
             if (premierChamp.NomUnite == "A")
             {
                 return(-1);
             }
             else
             {
                 return(1);
             }
         }
         else
         {
             Int32 triAlphabetique = String.Compare(premierChamp.NomRegion, secondChamp.NomRegion);
             return(triAlphabetique);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Retourne l'ordre associé au contrôle.
        /// </summary>
        /// <returns>Ordre associé au contrôle.</returns>
        public OrdreAbstrait RetourneOrdre()
        {
            String[] ordre = this.Ordre.Text.Split(' ');

            String       regionConcernee = this.region.Text;
            EUnite       unite           = Convertisseurs.DepuisEUniteAbrege(this.Unite.Text);
            EBelligerant belligerant     = Convertisseurs.DepuisEBelligerantAbrege(this.Belligerant.Text);

            if (ordre[0] == "-")
            {
                String   regionAttaquee = ordre[1];
                Attaquer attaque        = new Attaquer(unite, belligerant, regionConcernee, regionAttaquee);
                return(attaque);
            }
            else if (ordre[0] == "c")
            {
                String regionAttaquante = ordre[1];
                String regionAttaquee   = ordre[3];

                Convoyer convoi = new Convoyer(belligerant, regionConcernee, regionAttaquante, regionAttaquee);
                return(convoi);
            }
            else if (ordre[0] == "s")
            {
                if (ordre.Length < 4)
                {
                    String regionSoutenue = ordre[1];

                    SoutenirDefensif soutieDefensif = new SoutenirDefensif(unite, belligerant, regionConcernee, regionSoutenue);
                    return(soutieDefensif);
                }
                else
                {
                    String regionAttaquante = ordre[1];
                    String regionAttaquee   = ordre[3];

                    SoutenirOffensif soutienOffensif = new SoutenirOffensif(
                        unite,
                        belligerant,
                        regionConcernee,
                        regionAttaquante,
                        regionAttaquee);
                    return(soutienOffensif);
                }
            }
            else
            {
                Tenir tenir = new Tenir(unite, belligerant, regionConcernee);
                return(tenir);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Retourne l'ordre d'ajustement associé au contrôle.
        /// </summary>
        /// <returns>Ordre d'ajustement associé au contrôle.</returns>
        public Ajuster RetourneAjustement()
        {
            EUnite       unite;
            EAjustement  ajustement;
            String       nomRegion   = this.region.Text;
            EBelligerant belligerant = Convertisseurs.DepuisEBelligerantAbrege(this.Belligerant.Text);

            if (this.comboBox.Visible == true)
            {
                String recrutement = this.comboBox.Text;
                if (recrutement != "")
                {
                    unite      = Convertisseurs.VersEUnite(recrutement);
                    ajustement = EAjustement.Recrutement;
                }
                else
                {
                    unite      = EUnite.Aucune;
                    ajustement = EAjustement.Aucun;
                }
            }
            else
            {
                unite = Convertisseurs.DepuisEUniteAbrege(this.Unite.Text);
                if (this.Ordre.Text == "*")
                {
                    ajustement = EAjustement.Congédiement;
                }
                else
                {
                    ajustement = EAjustement.Aucun;
                }
            }

            Ajuster ordre = new Ajuster(ajustement, unite, belligerant, nomRegion);

            return(ordre);
        }