Spiel.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #pragma once
  2. #include "SpielKlasse.h"
  3. #include "Variablen.h"
  4. #include "Trigger.h"
  5. #include "Bariere.h"
  6. #include "Base.h"
  7. #include "Drop.h"
  8. #include "Geschoss.h"
  9. #include "Umlenkung.h"
  10. #include "Tunnel.h"
  11. #include "Schiene.h"
  12. #include "Schalter.h"
  13. #include "Statistik.h"
  14. #include "Reader.h"
  15. #include <Critical.h>
  16. #include <Datei.h>
  17. #include <Random.h>
  18. #include <Punkt.h>
  19. class Statistik;
  20. class StatistikV;
  21. class Spiel : public SpielKlasse
  22. {
  23. private:
  24. bool isRunning;
  25. RandomGenerator randG;
  26. SSDatenbankV *psqldb;
  27. RCArray< SSKlientV > *zKlients;
  28. RCArray< VarPointer > variablen;
  29. RCArray< Spieler > spieler;
  30. RCArray< Team > teams;
  31. RCArray< Bariere > barieren;
  32. RCArray< Base > basen;
  33. RCArray< Drop > drops;
  34. RCArray< Gegenstand > items;
  35. RCArray< Geschoss > shots;
  36. RCArray< FeuerballTreffer > feuer;
  37. RCArray< Schalter > schalter;
  38. RCArray< Schiene > schienen;
  39. RCArray< Timer > timer;
  40. RCArray< Tunnel > tunnel;
  41. RCArray< Umlenkung > umlenkungen;
  42. RCArray< Trigger > trigger;
  43. RCArray< TriggerRun > triggerRuns;
  44. Array< int > *zAccounts;
  45. Statistik *stat;
  46. Text mapPfad;
  47. Critical c;
  48. Datei *log;
  49. Punkt mapSize;
  50. int nextId;
  51. bool ende;
  52. int spielerAnzahl;
  53. int spielId;
  54. int karteId;
  55. int gameTicks;
  56. bool pause;
  57. int ref;
  58. public:
  59. // Konstruktor
  60. Spiel();
  61. // Destruktor
  62. ~Spiel();
  63. // nicht constant
  64. void setPSQLK( SSDatenbankV *psqldb ) override; // call 1
  65. void setSpielId( int id ) override; // call 2
  66. void setKarteId( int karteId ) override; // call 3
  67. void setTempPfad( char *pfad ) override; // call 3.5
  68. void setAccounts( int anzahl, Array< int > *zAccounts ) override; // call 4
  69. void setKlients( int anzahl, RCArray< SSKlientV > *zKlients ) override; // call 5
  70. void setSpielerNummern( int anzahl, Array< int > *spielerNummern ) override; // call 6
  71. void run() override; // call 7
  72. void klientOffline( int accountId ) override;
  73. void klientOnline( int accountId, SSKlientV *zKlient ) override;
  74. void nachricht( int accountId, int len, char *bytes ) override;
  75. void setMapSize( int width, int height );
  76. void setPausiert( bool pausiert );
  77. void tick( double zeit );
  78. void addVariable( const char *name, Variable *var );
  79. void setVariable( const char *name, Variable *var );
  80. void addTeam( Team *team );
  81. void addSpieler( Spieler *spieler );
  82. void addBariere( Bariere *bariere );
  83. void addBase( Base *base );
  84. void addDrop( Drop *drop );
  85. void addGegenstand( Gegenstand *gegenstand );
  86. void addGeschoss( Geschoss *geschoss );
  87. void addSchalter( Schalter *schalter );
  88. void addSchiene( Schiene *schiene );
  89. void addTimer( Timer *timer );
  90. void addTunnel( Tunnel *tunnel );
  91. void addUmlenkung( Umlenkung *umlenkung );
  92. void addTrigger( Trigger *trigger );
  93. void addTriggerRun( TriggerRun *tRun );
  94. void activateShalter( int id );
  95. void throwEvent( Ereignis *e );
  96. Variable *getVariable( const char *name ) const;
  97. Variable *zVariable( const char *name ) const;
  98. bool istPausiert() const;
  99. bool needEvent( EreignisTyp typ ) const;
  100. Team *getTeam( int id ) const;
  101. Spieler *getSpieler( int id ) const;
  102. Iterator< Spieler * > getSpieler() const;
  103. Iterator< Bariere * > getBarieren() const;
  104. Bariere *getBariere( int id ) const;
  105. Base *getBase( int id ) const;
  106. Drop *getDrop( int id ) const;
  107. Schalter *getSchalter( int id ) const;
  108. Schiene *getSchiene( int id ) const;
  109. Timer *getTimer( int id ) const;
  110. Tunnel *getTunnel( int id ) const;
  111. Umlenkung *getUmlenkung( int id ) const;
  112. Trigger *getTrigger( int id ) const;
  113. int getNextId();
  114. double getRand();
  115. // constant
  116. StatistikV *getStatistik() const override;
  117. // Reference Counting
  118. SpielKlasse *getThis() override;
  119. SpielKlasse *release() override;
  120. };