Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Acció travessa1part(e/s arbre1:Arbre; ent idJugador: nat; participants: CjtJugadors e/s pilaFinalistes: Pila; e/s e: Estadístiques;)
- {Pre: -}
- var s: sala
- s:=arrel(arbre1);
- si no desintegrat(idJugador,participants) -->
- si es_buit(fill_esq(arbre1)) i es_buit(fill_dre(arbre1)) i no s.ocupada -->
- si clausObrenPany(idJugador,s.panyEsq,participants) -->
- s.ocupada:=true;
- pilaFinalistes:=demanar_torn(idJugador,pilaFinalistes)
- desaSalaFinal(idJugador,s.id,e);
- [] desintegra(idJugador,participants);
- fsi
- [] s.contEsq >= s.contDre i s.contEsq != 0
- si clausObrenPany(idJugador,s.panyEsq,participants) -->
- travessa1part(fill_esq,idJugador,participants,pilaFinalistes,e);
- si no desintegrat(idJugador,participants) -->
- s.contEsq := s.contEsq - 1;
- fsi
- [] clausObrenPany(idJugador,s.panyDre,participants) i s.contDre != 0 -->
- travessa1part(fill_dre,idJugador,participants,pilaFinalistes,e);
- si no desintegrat(idJugador,participants) -->
- s.contDre := s.contDre - 1;
- fsi
- [] desintegra(idJugador,participants);
- fsi
- [] s.contDre > s.contEsq -->
- si clausObrenPany(idJugador,s.panyDre,participants) -->
- travessa1part(fill_esq,idJugador,participants,pilaFinalistes,e);
- si no desintegrat(idJugador,participants) -->
- s.contDre := s.contDre -1;
- fsi
- [] clausObrenPany(idJugador,s.panyDre,participants) i s.contEsq != 0 -->
- travessa1part(fill_dre,idJugador,participants,pilaFinalistes,e);
- si no desintegrat(idJugador,participants) -->
- s.contDre := s.contDre - 1;
- fsi
- [] desintegra(idJugador,participants);
- fsi
- fsi
- funció travessa2part(e/s arbre2:Arbre; ent participants: CjtJugadors; e/s e2: Estadístiques) ret idJugador: enter
- var s: sala2
- s:=arrel(arbre2);
- si es_buit(fill_esq(arbre2)) i es_buit(fill_dre(arbre2)) i s.ocupada -->
- si clausObrenPany(s.idJugador,s.pany,participants) -->
- idJugador :=s.idJugador;
- [] idJugador := -1;
- fsi
- fsi
- [] es_buit(fill_dre(arbre2)) -->
- idJugador := travessa2part(fill_esq(arbre1),participants,e2);
- si idJugador != -1 -->
- si no clausObrenPany(idJugador,s.pany,participants) -->
- idJugador :=-1;
- fsi
- fsi
- [] es_buit(fill_esq(arbre2))-->
- idJugador := travessa2part(fill_dre(arbre1),participants,e2);
- si idJugador != -1 -->
- si no clausObrenPany(idJugador,s.pany,participants) -->
- idJugador:=-1;
- fsi
- fsi
- [] -->
- var jugadorDre,jugadorEsq: enter
- jugadorEsq:= travessa2part(fill_esq(arbre2),participants,e2);
- jugadorDre:= travessa2part(fill_dre(arbre2),participants,e2);
- si jugadorEsq != -1 -->
- si jugadorDre != -1 -->
- idJugador = lluita(jugadorDre,jugadorEsq,participants)
- si idJugador = jugadorDre -->
- desaCombat(idJugador,jugadorEsq,e2);
- [] desaCombat(idJugador,jugadorDre,e2);
- fsi
- si no clausObrenPany(idJugador,s.pany,participants) -->
- idJugador:=-1;
- fsi
- [] idJugador:=jugadorEsq;
- si no clausObrenPany(idJugador,s.pany,participants) -->
- idJugador:=-1;
- fsi
- fsi
- [] idJugador:=jugadorDre
- si no clausObrenPany(idJugador,s.pany,participants) -->
- idJugador:=-1;
- fsi
- fsi
- fsi
- acció inicialitzar2part(e/s arbre2:Arbre;jugadors:vector nat de mida[1..J],ent e2:Estadístiques)
- s:=arrel(arbre2)
- si es_buit(fill_esq(arbre2)) i es_buit(fill_dre(arbre2)) -->
- s.ocupada := false;
- var i:nat
- per i=0 fins i=J-1 fer
- si s.id = consultaSalaFinal(jugadors[i],e2) -->
- s.idJugador := jugadors[i]
- s.ocupada := true
- fsi
- fper
- [] es_buit(fill_dre) -->
- inicialitzar2part(fill_esq(arbre1),jugadors,e2)
- [] es_buit(fill_esq) -->
- inicialitzar2part(fill_dre(arbre1),jugadors,e2)
- [] -->
- inicialitzar2part(fill_esq(arbre1),jugadors,e2)
- inicialitzar2part(fill_dre(arbre1),jugadors,e2)
- fsi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement