Guest User

Untitled

a guest
Jul 16th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. jogar(t:TABULEIRO) is
  2. -- joga
  3. local temp: INTEGER
  4. j: JOGADA
  5. sucesso, posvalidas,jogadaehvalida, corvalida: BOOLEAN
  6. do
  7. from
  8. sucesso:= false
  9. until
  10. sucesso = true
  11. loop
  12. imprimetabuleiro(t)
  13. j:= lejogada
  14. posvalidas := t.isposvalida (j.latual,j.catual) and t.isposvalida (j.lnova, j.cnova)
  15. and j.catual /= j.cnova and j.latual /= j.lnova
  16. and not t.isposvazia (j.latual,j.catual) and not t.isposocupada(j.lnova,j.cnova)
  17. 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) ) )
  18. jogadaehvalida := posvalidas and (t.issaltovalido(j) or t.isarrastovalido (j))
  19.  
  20. if posvalidas then
  21. if corvalida then
  22. if jogadaehvalida then
  23. temp:= t.efetuajogada (j)
  24. if temp = JOGADAINVALIDA then
  25. io.put_string("%NJogada Invalida%NJogue Novamente %N")
  26. digiteenter
  27. elseif temp = JOGADAMULTIPLA then
  28. io.put_string ("%NVoce deve saltar denovo%N")
  29. digiteenter
  30. io.put_string (t.out)
  31. elseif temp = JOGADAVALIDA then
  32. sucesso := true
  33. if t.isdama (j.lnova,j.cnova) then
  34. num_mov_damas := num_mov_damas + 1
  35. else num_mov_damas := 0
  36. end
  37. end
  38. else
  39. io.put_string("%NJogada Invalida%NJogue Novamente %N")
  40. digiteenter
  41. end
  42. else
  43. io.put_string("%NMova a peça que lhe pertence a cor é: " + cor + "%NJogue Novamente %N")
  44. digiteenter
  45. end
  46. else
  47. io.put_string("%NAlguma posicao e Invalida%NJogue Novamente %N")
  48. digiteenter
  49. end
  50.  
  51. end
  52. rescue
  53. retry
  54. end
Add Comment
Please, Sign In to add comment