Advertisement
Guest User

zizi furtif

a guest
Jan 25th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ada 5.82 KB | None | 0 0
  1. with p_fenbase ; use p_fenbase ;
  2. with Forms ; use Forms;
  3. with ada.calendar; use ada.calendar;
  4. with p_twist; use p_twist;
  5. with ada.io_exceptions; use ada.io_exceptions;
  6. with p_vue_graph; use p_vue_graph;
  7. with text_io; use text_io;
  8. use p_twist.p_int_io;
  9. use p_twist.p_piece_io;
  10.  
  11. procedure twist_graph2 is
  12.   Facc, FJeu,Freg,Fwin : TR_Fenetre;
  13.   V : TV_Grille;
  14.   f : text_io.file_type;
  15.   VP : TV_Piece;
  16.   g : p_piece_io.file_type;
  17.   matRotD,matRetH,matRotG,matRetV : TV_Matrice;
  18.   possible : boolean;
  19.   n : level;
  20.   nump,m : T_NumPiece;
  21.   EX_FinJeu,EX_WIN,EX_Restart : exception;
  22.   NewLine    : constant Character  := Character'Val (10);
  23.   tromper : boolean := false;
  24.   BoutonDebut : string(1..7);
  25. begin
  26.   loop
  27.     begin
  28.       open(f,in_file,"defis.txt");
  29.       open(g,in_file,"fpieces");
  30.       InitialiserFenetres;
  31.       InitFenetreAccueil(Facc);
  32.       InitFenetreWin(Fwin);
  33.       InitFenetreJeu(FJeu);
  34.       InitRegle(Freg);
  35.       if tromper then
  36.         ChangerTexte(FAcc,"Erreur","Erreur les niveaux vont");
  37.         ChangerTexte(FAcc,"Erreur2","de 1 a 101");
  38.       end if;
  39.       MontrerFenetre(Facc);
  40.       tromper := true;
  41.       CreeVectPiece(g,VP);
  42.       BoutonDebut := "       ";
  43.       while BoutonDebut /= "BoutonV" and BoutonDebut /= "BoutonQ" loop
  44.          declare
  45.            Bouton : string := (AttendreBouton(Facc));
  46.          begin
  47.            if (Bouton'last-Bouton'first) = (BoutonDebut'last-BoutonDebut'first) then
  48.          BoutonDebut := Bouton;
  49.            end if;
  50.            if Bouton = "BoutonR" then
  51.              MontrerFenetre(Freg);
  52.          tromper := false;
  53.            declare
  54.              Bouton1 : string := (AttendreBouton(Freg));
  55.            begin
  56.              if Bouton1 = "BoutonQuitter" then
  57.                raise EX_Restart;
  58.              end if;
  59.            end;
  60.            elsif Bouton = "BoutonQ" then
  61.              raise EX_FinJeu;
  62.            elsif Bouton = "BoutonV" then
  63.              n := integer'value(ConsulterContenu(Facc,"niveau"));
  64.              CacherFenetre(Facc);
  65.              InitJeu(f,n,V);
  66.              MontrerFenetre(Fjeu);
  67.              InitNiveau(Fjeu,f,n,V);
  68.              ReinitTransfo(Fjeu);
  69.              AfficheGrille(Fjeu,V,VP);
  70.              AffichePiecesNonPlacees(Fjeu,VP);
  71.            end if;
  72.          end;
  73.        end loop;
  74.        while not PartieGagne(VP) loop
  75.          declare
  76.            Bouton2 : String := (AttendreBouton(Fjeu));
  77.          begin
  78.            ChangerContenu(Fjeu,"Messageerreur","");
  79.            ReinitTransfo(Fjeu);
  80.            AfficheGrille(Fjeu,V,VP);
  81.            AffichePiecesNonPlacees(Fjeu,VP);
  82.            if Bouton2 = "BoutonQuitter" then
  83.              raise EX_FinJeu;
  84.            end if;
  85.            if Bouton2 = "BoutonRegle" then
  86.              MontrerFenetre(Freg);
  87.              declare
  88.                Bouton3 : string := (AttendreBouton(Freg));
  89.              begin
  90.                if Bouton3 = "BoutonQuitter" then
  91.                  CacherFenetre(Freg);
  92.                end if;
  93.              end;
  94.            end if;
  95.            if Bouton2(Bouton2'first) = 'P' or Bouton2(Bouton2'first) = 'N' then
  96.              nump := integer'value(Bouton2(Bouton2'first+1..Bouton2'first+2));
  97.              AffichePieceTourner(Fjeu,VP,nump,matRotD,matRotG,matRetV,matRetH);
  98.              declare
  99.                Bouton4 : String := (AttendreBouton(Fjeu));
  100.              begin
  101.                if Bouton4(Bouton4'first) = 'R' or Bouton4(Bouton4'first) = 'T'  then
  102.                  if integer'value(Bouton4(Bouton4'first+1..Bouton4'first+2)) = 1 then
  103.                    rotG(VP,nump);
  104.                  elsif integer'value(Bouton4(Bouton4'first+1..Bouton4'first+2)) = 2 then
  105.                    rotD(VP,nump);
  106.                  elsif integer'value(Bouton4(Bouton4'first+1..Bouton4'first+2)) = 3 then
  107.                    retH(VP,nump);
  108.                  else
  109.                    retV(VP,nump);
  110.                  end if;
  111.                elsif Bouton4(Bouton4'first) = 'C' or Bouton4(Bouton4'first) = 'D'  then
  112.                  placer(V,VP,nump,integer'value(Bouton4(Bouton4'first+3..Bouton4'first+3)),Bouton4(Bouton4'first+1),possible);
  113.                  if not possible then
  114.                    ChangerContenu(Fjeu,"Messageerreur",NewLine&"               Impossible de placer la piece");
  115.                  end if;
  116.                  ReinitTransfo(Fjeu);
  117.                  AfficheGrille(Fjeu,V,VP);
  118.                  AffichePiecesNonPlacees(Fjeu,VP);
  119.                end if;
  120.              end;
  121.            elsif Bouton2(Bouton2'first) = 'C' or Bouton2(Bouton2'first) = 'D' then
  122.              m := V(integer'value(Bouton2(Bouton2'first+2..Bouton2'first+3)),Bouton2(Bouton2'first+1)).piece;
  123.              if m /= 0 then
  124.                retirer(V,VP,m);
  125.              end if;
  126.            end if;
  127.          end;
  128.        end loop;
  129.        if PartieGagne(VP) then
  130.          raise EX_WIN;
  131.        end if;
  132.        exit;
  133.      exception
  134.        when EX_FinJeu => exit;
  135.        when EX_Restart => CacherFenetre(Facc);
  136.                           CacherFenetre(Freg);
  137.                           close(f);
  138.                           close(g);
  139.        when constraint_error => CacherFenetre(Facc);
  140.        when ADA.IO_EXCEPTIONS.STATUS_ERROR => close(f);
  141.                                               close(g);
  142.        when EX_WIN => CacherFenetre(Fjeu);
  143.                       MontrerFenetre(Fwin);
  144.                       declare
  145.                         Bouton5 : string := AttendreBouton(Fwin);
  146.                       begin
  147.                         if Bouton5 = "BoutonQuitter" then
  148.                           exit;
  149.                         elsif Bouton5 = "BoutonNewGame" then
  150.                           CacherFenetre(Fwin);
  151.                           tromper := false;
  152.                           BoutonDebut := "       ";
  153.                         end if;
  154.                       end;
  155.     end;
  156.     end loop;
  157.  end twist_graph2;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement