Guest User

Untitled

a guest
May 24th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.73 KB | None | 0 0
  1. public void teeSiirto(Pelimoottori moottori) {
  2. if (this.annaMaasto() == Maasto.VIIDAKKO) { //Jos sektorin maasto on viidakko..
  3. if (Math.random() < 0.2) { //...20% luodaan hedelma.
  4. Hedelma h = Hedelma.luoHedelma();
  5. this.sijoitaEsine(h);
  6. System.out.println("Sektori loi hedelman.");
  7. }
  8. else { //Jos hedelmaa ei luoda...
  9. if (Math.random() < 0.05) { //...5% luodaan toteemi.
  10. Toteemi t = new Toteemi();
  11. this.sijoitaEsine(t);
  12. System.out.println("Sektori loi toteemin");
  13. }
  14. else { //Jos toteemia ei luoda...
  15. if (Math.random() < 0.05) { //...5% luodaan kurpitsa,
  16. if (Math.random() < 0.5) { //joka on 50% myrkyllinen.
  17. Kurpitsa k1 = new Kurpitsa(true, this);
  18. this.sijoitaEsine(k1);
  19. }
  20. else {
  21. Kurpitsa k2 = new Kurpitsa(false, this);
  22. this.sijoitaEsine(k2);
  23. }
  24. } System.out.println("Sektori loi kurpitsan.");
  25. }
  26. }
  27. }
  28. else if (this.annaMaasto() == Maasto.KAUPUNKI) { //Jos sektorin maasto on kaupunki...
  29. if (Math.random() < 0.01) { //...1% luodaan konkistadori.
  30. Konkistadori s = new Konkistadori("konkistadori " + luoNimi());
  31. this.sijoitaOlento(s);
  32. System.out.println("Sektori loi konkistadorin.");
  33. moottori.lisaaVuorollinen(s);
  34. }
  35. else {
  36. if (Math.random() < 0.1) {// muuten 10% luodaan heittoase.
  37. this.sijoitaEsine(Heittoase.luoHeittoase());
  38. System.out.println("Sektori loi heittoaseen.");
  39. }
  40. }
  41. }
  42. else if (this.annaMaasto() == Maasto.VUORISTO) { //Jos sektorin maasto on vuoristo,..
  43. boolean voiSiirtya = false;
  44. Ilmansuunta[] suunnat = Ilmansuunta.values(); //..taulukoidaan kaikki ilmansuunnat..
  45. Poppamies p = new Poppamies("poppamies " + luoNimi());
  46. for (int i = 0; i < 4; i++) { //...ja käydään läpi yksitellen.
  47.  
  48. if (p.voiSiirtya(this.annaMaasto(), this.annaNaapuri(suunnat[i]).annaMaasto()) == true) {
  49. voiSiirtya = true; //Jos sektorista voi siirtya naapurisektoriin...
  50. return;
  51. }
  52. }
  53. if (voiSiirtya == true) {
  54. if (Math.random() < 0.03) { //...3% luodaan poppamies.
  55. this.sijoitaOlento(p);
  56. System.out.println("Sektori loi poppamiehen.");
  57. moottori.lisaaVuorollinen(p);
  58. }
  59. }
  60.  
  61. }
  62. else if (Maailma.loytyySulkakaarme == false) {
  63. Ilmansuunta[] suuntia = Ilmansuunta.values();//Taulukoidaan ilmansuunnat.
  64. for (int n = 0; n < 4; n++) {
  65. if (this.annaNaapuri(suuntia[n]) == null) {
  66. //Jos sektori sijaitsee maailman reunalla...
  67. if (Math.random() < 0.003) {
  68. Sulkakaarme s = new Sulkakaarme();//3 promillen todennäköisyydellä luodaan sulkakäärme.
  69. this.sijoitaOlento(s);
  70. moottori.lisaaVuorollinen(s);
  71. Maailma.loytyySulkakaarme = true;
  72. }
  73. }
  74. }
  75. }
  76.  
  77. }
Add Comment
Please, Sign In to add comment