Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jogar(t:TABULEIRO) is
- -- joga
- local temp: INTEGER
- j: JOGADA
- sucesso, posvalidas,jogadaehvalida, corvalida: BOOLEAN
- do
- from
- sucesso:= false
- until
- sucesso = true
- loop
- imprimetabuleiro(t)
- j:= lejogada
- posvalidas := t.isposvalida (j.latual,j.catual) and t.isposvalida (j.lnova, j.cnova)
- and j.catual /= j.cnova and j.latual /= j.lnova
- and not t.isposvazia (j.latual,j.catual) and not t.isposocupada(j.lnova,j.cnova)
- corvalida := posvalidas and ((t.isbranca (j.latual,j.catual) and cor.is_equal(BRANCA) ) or (t.ispreta (j.latual,j.catual) and cor.is_equal(PRETA) ) )
- jogadaehvalida := posvalidas and (t.issaltovalido(j) or t.isarrastovalido (j))
- if posvalidas then
- if corvalida then
- if jogadaehvalida then
- temp:= t.efetuajogada (j)
- if temp = JOGADAINVALIDA then
- io.put_string("%NJogada Invalida%NJogue Novamente %N")
- digiteenter
- elseif temp = JOGADAMULTIPLA then
- io.put_string ("%NVoce deve saltar denovo%N")
- digiteenter
- io.put_string (t.out)
- elseif temp = JOGADAVALIDA then
- sucesso := true
- if t.isdama (j.lnova,j.cnova) then
- num_mov_damas := num_mov_damas + 1
- else num_mov_damas := 0
- end
- end
- else
- io.put_string("%NJogada Invalida%NJogue Novamente %N")
- digiteenter
- end
- else
- io.put_string("%NMova a peça que lhe pertence a cor é: " + cor + "%NJogue Novamente %N")
- digiteenter
- end
- else
- io.put_string("%NAlguma posicao e Invalida%NJogue Novamente %N")
- digiteenter
- end
- end
- rescue
- retry
- end
Add Comment
Please, Sign In to add comment