Aktionen.cpp 52 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814
  1. #include "Aktionen.h"
  2. #include "Trigger.h"
  3. #include "Spiel.h"
  4. Aktion::Aktion( AktionTyp typ )
  5. : Variable( AKTION )
  6. {
  7. this->typ = typ;
  8. }
  9. Aktion::~Aktion()
  10. {}
  11. KonstantNichts::KonstantNichts()
  12. : Aktion( KONSTANT_NICHTS )
  13. {}
  14. bool KonstantNichts::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  15. {
  16. zMemory->setVar( "__return__", new Variable( NICHTS ) );
  17. return 1;
  18. }
  19. KonstantInteger::KonstantInteger( int val )
  20. : Aktion( KONSTANT_INTEGER )
  21. {
  22. this->value = val;
  23. }
  24. bool KonstantInteger::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  25. {
  26. zMemory->setVar( "__return__", new Integer( value ) );
  27. return 1;
  28. }
  29. KonstantBoolean::KonstantBoolean( bool val )
  30. : Aktion( KONSTANT_BOOLEAN )
  31. {
  32. value = val;
  33. }
  34. bool KonstantBoolean::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  35. {
  36. zMemory->setVar( "__return__", new Boolean( value ) );
  37. return 1;
  38. }
  39. KonstantString::KonstantString( Text val )
  40. : Aktion( KONSTANT_STRING )
  41. {
  42. value = val;
  43. }
  44. bool KonstantString::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  45. {
  46. zMemory->setVar( "__return__", new String( value ) );
  47. return 1;
  48. }
  49. KonstantFloat::KonstantFloat( float val )
  50. : Aktion( KONSTANT_FLOAT )
  51. {
  52. value = val;
  53. }
  54. bool KonstantFloat::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  55. {
  56. zMemory->setVar( "__return__", new Float( value ) );
  57. return 1;
  58. }
  59. KonstantVariable::KonstantVariable( Text name )
  60. : Aktion( KONSTANT_VARIABLE )
  61. {
  62. this->name = name;
  63. }
  64. bool KonstantVariable::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  65. {
  66. if( zMemory->zVariable( name ) )
  67. zMemory->setVar( "__return__", zMemory->getVariable( name ) );
  68. else if( zEreignis->zParameter( name ) )
  69. zMemory->setVar( "__return__", zEreignis->zParameter( name ) );
  70. else if( zSpiel->zVariable( name ) )
  71. zMemory->setVar( "__return__", zSpiel->getVariable( name ) );
  72. else
  73. zMemory->setVar( "__return__", new Variable( NICHTS ) );
  74. return 1;
  75. }
  76. Warten::Warten( Aktion *seconds )
  77. : Aktion( WARTEN )
  78. {
  79. this->seconds = seconds;
  80. }
  81. Warten::~Warten()
  82. {
  83. seconds->release();
  84. }
  85. bool Warten::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  86. {
  87. bool finished = seconds->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount );
  88. if( finished )
  89. {
  90. Variable *t = zMemory->zVariable( "__return__" );
  91. if( !t || t->getVariableTyp() != FLOAT )
  92. {
  93. zPC->stepOut();
  94. return 1;
  95. }
  96. waitCount += ( (Float *)t )->getValue();
  97. }
  98. return finished;
  99. }
  100. WennDannSonst::WennDannSonst( Aktion *wenn, Aktion *dann, Aktion *sonst )
  101. : Aktion( WENN_DANN_SONST )
  102. {
  103. this->wenn = wenn;
  104. this->dann = dann;
  105. this->sonst = sonst;
  106. }
  107. WennDannSonst::~WennDannSonst()
  108. {
  109. wenn->release();
  110. if( dann )
  111. dann->release();
  112. if( sonst )
  113. sonst->release();
  114. }
  115. bool WennDannSonst::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  116. {
  117. zPC->stepIn();
  118. if( zPC->currentPosition() == 0 )
  119. {
  120. bool finished = wenn->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount );
  121. if( finished )
  122. {
  123. Variable *ret = zMemory->zVariable( "__return__" );
  124. zPC->count();
  125. if( !isTrue( ret ) )
  126. {
  127. zPC->count();
  128. if( !sonst )
  129. {
  130. zPC->stepOut();
  131. return 1;
  132. }
  133. }
  134. else
  135. {
  136. if( !dann )
  137. {
  138. zPC->stepOut();
  139. return 1;
  140. }
  141. }
  142. }
  143. }
  144. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  145. {
  146. bool finished = dann->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount );
  147. if( finished )
  148. {
  149. zPC->stepOut();
  150. return 1;
  151. }
  152. }
  153. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  154. {
  155. bool finished = sonst->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount );
  156. if( finished )
  157. {
  158. zPC->stepOut();
  159. return 1;
  160. }
  161. }
  162. zPC->stepOut();
  163. return 0;
  164. }
  165. SetVariable::SetVariable( Text name, Aktion *value )
  166. : Aktion( SET_VARIABLE )
  167. {
  168. this->name = name;
  169. this->value = value;
  170. }
  171. SetVariable::~SetVariable()
  172. {
  173. value->release();
  174. }
  175. bool SetVariable::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  176. {
  177. bool finished = value->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount );
  178. if( finished )
  179. {
  180. if( zMemory->zVariable( name ) || zEreignis->zParameter( name ) || !zSpiel->zVariable( name ) )
  181. zMemory->setVar( name, zMemory->getVariable( "__return__" ) );
  182. else
  183. zSpiel->setVariable( name, zMemory->getVariable( "__return__" ) );
  184. }
  185. return finished;
  186. }
  187. TriggerAktion::TriggerAktion( Aktion *number, Aktion *triggerName )
  188. : Aktion( TRIGGER_AKTION )
  189. {
  190. this->number = number;
  191. trigger = triggerName;
  192. }
  193. TriggerAktion::~TriggerAktion()
  194. {
  195. number->release();
  196. trigger->release();
  197. }
  198. bool TriggerAktion::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  199. {
  200. zPC->stepIn();
  201. if( zPC->currentPosition() == 0 )
  202. {
  203. if( number->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  204. {
  205. Variable *t = zMemory->zVariable( "__return__" );
  206. if( !t || t->getVariableTyp() != INTEGER )
  207. {
  208. zPC->stepOut();
  209. return 1;
  210. }
  211. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  212. zPC->count();
  213. }
  214. }
  215. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  216. {
  217. if( trigger->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  218. {
  219. Variable *t = zMemory->zVariable( "__return__" );
  220. if( !t || t->getVariableTyp() != TRIGGER )
  221. {
  222. zPC->stepOut();
  223. return 1;
  224. }
  225. int id = ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue();
  226. if( id >= ( (Trigger *)t )->getAktionAnzahl() )
  227. {
  228. zPC->stepOut();
  229. return 1;
  230. }
  231. zMemory->setVar( zPC->getUniqueString() + "R0__", ( (Trigger *)t )->getAktion( id ) );
  232. zPC->count();
  233. }
  234. }
  235. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  236. {
  237. if( ( (Aktion *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  238. {
  239. zPC->stepOut();
  240. return 1;
  241. }
  242. }
  243. zPC->stepOut();
  244. return 0;
  245. }
  246. SpielerNachricht::SpielerNachricht( Aktion *spieler, Aktion *nachricht )
  247. : Aktion( SPIELER_NACHRICHT )
  248. {
  249. this->spieler = spieler;
  250. this->nachricht = nachricht;
  251. }
  252. SpielerNachricht::~SpielerNachricht()
  253. {
  254. spieler->release();
  255. nachricht->release();
  256. }
  257. bool SpielerNachricht::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  258. {
  259. zPC->stepIn();
  260. if( zPC->currentPosition() == 0 )
  261. {
  262. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  263. {
  264. Variable *t = zMemory->zVariable( "__return__" );
  265. if( !t || t->getVariableTyp() != SPIELER )
  266. {
  267. zPC->stepOut();
  268. return 1;
  269. }
  270. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  271. zPC->count();
  272. }
  273. }
  274. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  275. {
  276. if( nachricht->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  277. {
  278. Variable *t = zMemory->zVariable( "__return__" );
  279. if( t->getVariableTyp() != STRING )
  280. {
  281. zPC->stepOut();
  282. return 1;
  283. }
  284. // this is handeld on client side directly (no need to send the message to the player)
  285. zPC->stepOut();
  286. return 1;
  287. }
  288. }
  289. zPC->stepOut();
  290. return 0;
  291. }
  292. DisplayText::DisplayText( Aktion *x, Aktion *y, Aktion *f, Aktion *dauer, Aktion *nachricht )
  293. : Aktion( DISPLAY_TEXT )
  294. {
  295. this->x = x;
  296. this->y = y;
  297. this->color = f;
  298. this->dauer = dauer;
  299. this->nachricht = nachricht;
  300. }
  301. DisplayText::~DisplayText()
  302. {
  303. x->release();
  304. y->release();
  305. color->release();
  306. dauer->release();
  307. nachricht->release();
  308. }
  309. bool DisplayText::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  310. {
  311. zPC->stepIn();
  312. if( zPC->currentPosition() == 0 )
  313. {
  314. if( x->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  315. {
  316. Variable *t = zMemory->zVariable( "__return__" );
  317. if( !t || t->getVariableTyp() != FLOAT )
  318. {
  319. zPC->stepOut();
  320. return 1;
  321. }
  322. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  323. zPC->count();
  324. }
  325. }
  326. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  327. {
  328. if( y->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  329. {
  330. Variable *t = zMemory->zVariable( "__return__" );
  331. if( !t || t->getVariableTyp() != FLOAT )
  332. {
  333. zPC->stepOut();
  334. return 1;
  335. }
  336. zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
  337. zPC->count();
  338. }
  339. }
  340. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  341. {
  342. if( dauer->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  343. {
  344. Variable *t = zMemory->zVariable( "__return__" );
  345. if( !t || t->getVariableTyp() != FLOAT )
  346. {
  347. zPC->stepOut();
  348. return 1;
  349. }
  350. zMemory->setVar( zPC->getUniqueString() + "R2__", t->getThis() );
  351. zPC->count();
  352. }
  353. }
  354. if( zPC->currentPosition() == 3 && waitCount <= 0 )
  355. {
  356. if( color->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  357. {
  358. Variable *t = zMemory->zVariable( "__return__" );
  359. if( !t || ( t->getVariableTyp() != INTEGER ) )
  360. {
  361. zPC->stepOut();
  362. return 1;
  363. }
  364. zMemory->setVar( zPC->getUniqueString() + "R3__", t->getThis() );
  365. zPC->count();
  366. }
  367. }
  368. if( zPC->currentPosition() == 4 && waitCount <= 0 )
  369. {
  370. if( color->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  371. {
  372. Variable *t = zMemory->zVariable( "__return__" );
  373. if( !t || ( t->getVariableTyp() != STRING ) )
  374. {
  375. zPC->stepOut();
  376. return 1;
  377. }
  378. Float *xv = (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" );
  379. Float *yv = (Float *)zMemory->zVariable( zPC->getUniqueString() + "R1__" );
  380. Float *dauerv = (Float *)zMemory->zVariable( zPC->getUniqueString() + "R2__" );
  381. Integer *farbev = (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R3__" );
  382. // do nothing because the server does not need to show text
  383. zPC->stepOut();
  384. return 1;
  385. }
  386. }
  387. zPC->stepOut();
  388. return 0;
  389. }
  390. SpielPause::SpielPause( Aktion *paused )
  391. : Aktion( SPIEL_PAUSE )
  392. {
  393. this->paused = paused;
  394. }
  395. SpielPause::~SpielPause()
  396. {
  397. paused->release();
  398. }
  399. bool SpielPause::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  400. {
  401. if( paused->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  402. {
  403. Variable *t = zMemory->zVariable( "__return__" );
  404. if( !t || ( t->getVariableTyp() != BOOLEAN ) )
  405. return 1;
  406. zSpiel->setPausiert( ( (Boolean *)t )->getValue() );
  407. return 1;
  408. }
  409. }
  410. SpielEnde::SpielEnde( Aktion *gewinnerTeam )
  411. : Aktion( SPIEL_ENDE )
  412. {
  413. this->gewinnerTeam = gewinnerTeam;
  414. }
  415. SpielEnde::~SpielEnde()
  416. {
  417. gewinnerTeam->release();
  418. }
  419. bool SpielEnde::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  420. {
  421. if( gewinnerTeam->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  422. {
  423. Variable *t = zMemory->zVariable( "__return__" );
  424. if( !t || ( t->getVariableTyp() != TEAM && t->getVariableTyp() != NICHTS ) )
  425. return 1;
  426. zSpiel->setEnde( t->getVariableTyp() == NICHTS ? 0 : (Team *)t );
  427. return 1;
  428. }
  429. }
  430. SpielerSetLevel::SpielerSetLevel( Aktion *level, Aktion *spieler )
  431. : Aktion( SPIELER_SET_LEVEL )
  432. {
  433. this->level = level;
  434. this->spieler = spieler;
  435. }
  436. SpielerSetLevel::~SpielerSetLevel()
  437. {
  438. level->release();
  439. spieler->release();
  440. }
  441. bool SpielerSetLevel::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  442. {
  443. zPC->stepIn();
  444. if( zPC->currentPosition() == 0 )
  445. {
  446. if( level->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  447. {
  448. Variable *t = zMemory->zVariable( "__return__" );
  449. if( !t || t->getVariableTyp() != INTEGER )
  450. {
  451. zPC->stepOut();
  452. return 1;
  453. }
  454. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  455. zPC->count();
  456. }
  457. }
  458. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  459. {
  460. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  461. {
  462. Variable *t = zMemory->zVariable( "__return__" );
  463. if( !t || t->getVariableTyp() != SPIELER )
  464. {
  465. zPC->stepOut();
  466. return 1;
  467. }
  468. ( (Spieler *)t )->setLevel( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  469. zPC->stepOut();
  470. return 1;
  471. }
  472. }
  473. zPC->stepOut();
  474. return 0;
  475. }
  476. SpielerGiveItem::SpielerGiveItem( Aktion *item, Aktion *anzahl, Aktion *spieler )
  477. : Aktion( SPIELER_GIVE_ITEM )
  478. {
  479. this->item = item;
  480. this->anzahl = anzahl;
  481. this->spieler = spieler;
  482. }
  483. SpielerGiveItem::~SpielerGiveItem()
  484. {}
  485. bool SpielerGiveItem::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  486. {
  487. zPC->stepIn();
  488. if( zPC->currentPosition() == 0 )
  489. {
  490. if( item->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  491. {
  492. Variable *t = zMemory->zVariable( "__return__" );
  493. if( !t || t->getVariableTyp() != GEGENSTAND_TYP )
  494. {
  495. zPC->stepOut();
  496. return 1;
  497. }
  498. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  499. zPC->count();
  500. }
  501. }
  502. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  503. {
  504. if( anzahl->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  505. {
  506. Variable *t = zMemory->zVariable( "__return__" );
  507. if( !t || t->getVariableTyp() != INTEGER )
  508. {
  509. zPC->stepOut();
  510. return 1;
  511. }
  512. zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
  513. zPC->count();
  514. }
  515. }
  516. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  517. {
  518. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  519. {
  520. Variable *t = zMemory->zVariable( "__return__" );
  521. if( !t || t->getVariableTyp() != SPIELER )
  522. {
  523. zPC->stepOut();
  524. return 1;
  525. }
  526. ( (Spieler *)t )->addItem( ( (GegenstandTypVar *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue(),
  527. ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R1__" ) )->getValue(), zSpiel );
  528. zPC->stepOut();
  529. return 1;
  530. }
  531. }
  532. zPC->stepOut();
  533. return 0;
  534. }
  535. SpielerRemoveItem::SpielerRemoveItem( Aktion *item, Aktion *anzahl, Aktion *spieler )
  536. : Aktion( SPIELER_REMOVE_ITEM )
  537. {
  538. this->item = item;
  539. this->anzahl = anzahl;
  540. this->spieler = spieler;
  541. }
  542. SpielerRemoveItem::~SpielerRemoveItem()
  543. {
  544. item->release();
  545. anzahl->release();
  546. spieler->release();
  547. }
  548. bool SpielerRemoveItem::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  549. {
  550. zPC->stepIn();
  551. if( zPC->currentPosition() == 0 )
  552. {
  553. if( item->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  554. {
  555. Variable *t = zMemory->zVariable( "__return__" );
  556. if( !t || t->getVariableTyp() != GEGENSTAND_TYP )
  557. {
  558. zPC->stepOut();
  559. return 1;
  560. }
  561. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  562. zPC->count();
  563. }
  564. }
  565. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  566. {
  567. if( anzahl->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  568. {
  569. Variable *t = zMemory->zVariable( "__return__" );
  570. if( !t || t->getVariableTyp() != INTEGER )
  571. {
  572. zPC->stepOut();
  573. return 1;
  574. }
  575. zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
  576. zPC->count();
  577. }
  578. }
  579. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  580. {
  581. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  582. {
  583. Variable *t = zMemory->zVariable( "__return__" );
  584. if( !t || t->getVariableTyp() != SPIELER )
  585. {
  586. zPC->stepOut();
  587. return 1;
  588. }
  589. ( (Spieler *)t )->removeItem( ( (GegenstandTypVar *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue(),
  590. ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R1__" ) )->getValue() );
  591. zPC->stepOut();
  592. return 1;
  593. }
  594. }
  595. zPC->stepOut();
  596. return 0;
  597. }
  598. SpielerSetPosition::SpielerSetPosition( Aktion *x, Aktion *y, Aktion *spieler )
  599. : Aktion( SPIELER_SET_POSITION )
  600. {
  601. this->x = x;
  602. this->y = y;
  603. this->spieler = spieler;
  604. }
  605. SpielerSetPosition::~SpielerSetPosition()
  606. {
  607. x->release();
  608. y->release();
  609. spieler->release();
  610. }
  611. bool SpielerSetPosition::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  612. {
  613. zPC->stepIn();
  614. if( zPC->currentPosition() == 0 )
  615. {
  616. if( x->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  617. {
  618. Variable *t = zMemory->zVariable( "__return__" );
  619. if( !t || t->getVariableTyp() != FLOAT )
  620. {
  621. zPC->stepOut();
  622. return 1;
  623. }
  624. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  625. zPC->count();
  626. }
  627. }
  628. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  629. {
  630. if( y->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  631. {
  632. Variable *t = zMemory->zVariable( "__return__" );
  633. if( !t || t->getVariableTyp() != FLOAT )
  634. {
  635. zPC->stepOut();
  636. return 1;
  637. }
  638. zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
  639. zPC->count();
  640. }
  641. }
  642. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  643. {
  644. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  645. {
  646. Variable *t = zMemory->zVariable( "__return__" );
  647. if( !t || t->getVariableTyp() != SPIELER )
  648. {
  649. zPC->stepOut();
  650. return 1;
  651. }
  652. ( (Spieler *)t )->setX( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  653. ( (Spieler *)t )->setY( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R1__" ) )->getValue() );
  654. zPC->stepOut();
  655. return 1;
  656. }
  657. }
  658. zPC->stepOut();
  659. return 0;
  660. }
  661. SpielerSetLeben::SpielerSetLeben( Aktion *leben, Aktion *spieler )
  662. : Aktion( SPIELER_SET_LEBEN )
  663. {
  664. this->leben = leben;
  665. this->spieler = spieler;
  666. }
  667. SpielerSetLeben::~SpielerSetLeben()
  668. {
  669. leben->release();
  670. spieler->release();
  671. }
  672. bool SpielerSetLeben::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  673. {
  674. zPC->stepIn();
  675. if( zPC->currentPosition() == 0 )
  676. {
  677. if( leben->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  678. {
  679. Variable *t = zMemory->zVariable( "__return__" );
  680. if( !t || t->getVariableTyp() != FLOAT )
  681. {
  682. zPC->stepOut();
  683. return 1;
  684. }
  685. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  686. zPC->count();
  687. }
  688. }
  689. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  690. {
  691. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  692. {
  693. Variable *t = zMemory->zVariable( "__return__" );
  694. if( !t || t->getVariableTyp() != SPIELER )
  695. {
  696. zPC->stepOut();
  697. return 1;
  698. }
  699. ( (Spieler *)t )->setLeben( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  700. zPC->stepOut();
  701. return 1;
  702. }
  703. }
  704. zPC->stepOut();
  705. return 0;
  706. }
  707. SpielerSetMaxLeben::SpielerSetMaxLeben( Aktion *leben, Aktion *spieler )
  708. : Aktion( SPIELER_SET_LEBEN )
  709. {
  710. this->leben = leben;
  711. this->spieler = spieler;
  712. }
  713. SpielerSetMaxLeben::~SpielerSetMaxLeben()
  714. {
  715. leben->release();
  716. spieler->release();
  717. }
  718. bool SpielerSetMaxLeben::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  719. {
  720. zPC->stepIn();
  721. if( zPC->currentPosition() == 0 )
  722. {
  723. if( leben->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  724. {
  725. Variable *t = zMemory->zVariable( "__return__" );
  726. if( !t || t->getVariableTyp() != INTEGER )
  727. {
  728. zPC->stepOut();
  729. return 1;
  730. }
  731. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  732. zPC->count();
  733. }
  734. }
  735. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  736. {
  737. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  738. {
  739. Variable *t = zMemory->zVariable( "__return__" );
  740. if( !t || t->getVariableTyp() != SPIELER )
  741. {
  742. zPC->stepOut();
  743. return 1;
  744. }
  745. ( (Spieler *)t )->setMaxLeben( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  746. zPC->stepOut();
  747. return 1;
  748. }
  749. }
  750. zPC->stepOut();
  751. return 0;
  752. }
  753. SpielerSetErfahrung::SpielerSetErfahrung( Aktion *erfahrung, Aktion *spieler )
  754. : Aktion( SPIELER_SET_ERFAHRUNG )
  755. {
  756. this->erfahrung = erfahrung;
  757. this->spieler = spieler;
  758. }
  759. SpielerSetErfahrung::~SpielerSetErfahrung()
  760. {}
  761. bool SpielerSetErfahrung::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  762. {
  763. zPC->stepIn();
  764. if( zPC->currentPosition() == 0 )
  765. {
  766. if( erfahrung->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  767. {
  768. Variable *t = zMemory->zVariable( "__return__" );
  769. if( !t || t->getVariableTyp() != FLOAT )
  770. {
  771. zPC->stepOut();
  772. return 1;
  773. }
  774. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  775. zPC->count();
  776. }
  777. }
  778. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  779. {
  780. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  781. {
  782. Variable *t = zMemory->zVariable( "__return__" );
  783. if( !t || t->getVariableTyp() != SPIELER )
  784. {
  785. zPC->stepOut();
  786. return 1;
  787. }
  788. ( (Spieler *)t )->setErfahrung( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  789. zPC->stepOut();
  790. return 1;
  791. }
  792. }
  793. zPC->stepOut();
  794. return 0;
  795. }
  796. SpielerSetMaxErfahrung::SpielerSetMaxErfahrung( Aktion *erfahrung, Aktion *spieler )
  797. : Aktion( SPIELER_SET_MAX_ERFAHRUNG )
  798. {
  799. this->erfahrung = erfahrung;
  800. this->spieler = spieler;
  801. }
  802. SpielerSetMaxErfahrung::~SpielerSetMaxErfahrung()
  803. {
  804. erfahrung->release();
  805. spieler->release();
  806. }
  807. bool SpielerSetMaxErfahrung::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  808. {
  809. zPC->stepIn();
  810. if( zPC->currentPosition() == 0 )
  811. {
  812. if( erfahrung->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  813. {
  814. Variable *t = zMemory->zVariable( "__return__" );
  815. if( !t || t->getVariableTyp() != INTEGER )
  816. {
  817. zPC->stepOut();
  818. return 1;
  819. }
  820. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  821. zPC->count();
  822. }
  823. }
  824. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  825. {
  826. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  827. {
  828. Variable *t = zMemory->zVariable( "__return__" );
  829. if( !t || t->getVariableTyp() != SPIELER )
  830. {
  831. zPC->stepOut();
  832. return 1;
  833. }
  834. ( (Spieler *)t )->setMaxErfahrung( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  835. zPC->stepOut();
  836. return 1;
  837. }
  838. }
  839. zPC->stepOut();
  840. return 0;
  841. }
  842. SpielerSetTempo::SpielerSetTempo( Aktion *tempo, Aktion *spieler )
  843. : Aktion( SPIELER_SET_TEMPO )
  844. {
  845. this->tempo = tempo;
  846. this->spieler = spieler;
  847. }
  848. SpielerSetTempo::~SpielerSetTempo()
  849. {
  850. tempo->release();
  851. spieler->release();
  852. }
  853. bool SpielerSetTempo::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  854. {
  855. zPC->stepIn();
  856. if( zPC->currentPosition() == 0 )
  857. {
  858. if( tempo->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  859. {
  860. Variable *t = zMemory->zVariable( "__return__" );
  861. if( !t || t->getVariableTyp() != FLOAT )
  862. {
  863. zPC->stepOut();
  864. return 1;
  865. }
  866. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  867. zPC->count();
  868. }
  869. }
  870. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  871. {
  872. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  873. {
  874. Variable *t = zMemory->zVariable( "__return__" );
  875. if( !t || t->getVariableTyp() != SPIELER )
  876. {
  877. zPC->stepOut();
  878. return 1;
  879. }
  880. ( (Spieler *)t )->setLaufTempo( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  881. zPC->stepOut();
  882. return 1;
  883. }
  884. }
  885. zPC->stepOut();
  886. return 0;
  887. }
  888. SpielerSetWaffenTempo::SpielerSetWaffenTempo( Aktion *tempo, Aktion *spieler )
  889. : Aktion( SPIELER_SET_GESCHOSS_TEMPO )
  890. {
  891. this->tempo = tempo;
  892. this->spieler = spieler;
  893. }
  894. SpielerSetWaffenTempo::~SpielerSetWaffenTempo()
  895. {
  896. tempo->release();
  897. spieler->release();
  898. }
  899. bool SpielerSetWaffenTempo::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  900. {
  901. zPC->stepIn();
  902. if( zPC->currentPosition() == 0 )
  903. {
  904. if( tempo->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  905. {
  906. Variable *t = zMemory->zVariable( "__return__" );
  907. if( !t || t->getVariableTyp() != FLOAT )
  908. {
  909. zPC->stepOut();
  910. return 1;
  911. }
  912. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  913. zPC->count();
  914. }
  915. }
  916. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  917. {
  918. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  919. {
  920. Variable *t = zMemory->zVariable( "__return__" );
  921. if( !t || t->getVariableTyp() != SPIELER )
  922. {
  923. zPC->stepOut();
  924. return 1;
  925. }
  926. ( (Spieler *)t )->setGeschossTempo( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  927. zPC->stepOut();
  928. return 1;
  929. }
  930. }
  931. zPC->stepOut();
  932. return 0;
  933. }
  934. SpielerSetArmor::SpielerSetArmor( Aktion *armor, Aktion *spieler )
  935. : Aktion( SPIELER_SET_ARMOR )
  936. {
  937. this->armor = armor;
  938. this->spieler = spieler;
  939. }
  940. SpielerSetArmor::~SpielerSetArmor()
  941. {
  942. armor->release();
  943. spieler->release();
  944. }
  945. bool SpielerSetArmor::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  946. {
  947. zPC->stepIn();
  948. if( zPC->currentPosition() == 0 )
  949. {
  950. if( armor->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  951. {
  952. Variable *t = zMemory->zVariable( "__return__" );
  953. if( !t || t->getVariableTyp() != FLOAT )
  954. {
  955. zPC->stepOut();
  956. return 1;
  957. }
  958. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  959. zPC->count();
  960. }
  961. }
  962. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  963. {
  964. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  965. {
  966. Variable *t = zMemory->zVariable( "__return__" );
  967. if( !t || t->getVariableTyp() != SPIELER )
  968. {
  969. zPC->stepOut();
  970. return 1;
  971. }
  972. ( (Spieler *)t )->setArmor( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  973. zPC->stepOut();
  974. return 1;
  975. }
  976. }
  977. zPC->stepOut();
  978. return 0;
  979. }
  980. SpielerSetSchadenBonus::SpielerSetSchadenBonus( Aktion *bonus, Aktion *spieler )
  981. : Aktion( SPIELER_SET_SCHADEN_BONUS )
  982. {
  983. this->bonus = bonus;
  984. this->spieler = spieler;
  985. }
  986. SpielerSetSchadenBonus::~SpielerSetSchadenBonus()
  987. {
  988. bonus->release();
  989. spieler->release();
  990. }
  991. bool SpielerSetSchadenBonus::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  992. {
  993. zPC->stepIn();
  994. if( zPC->currentPosition() == 0 )
  995. {
  996. if( bonus->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  997. {
  998. Variable *t = zMemory->zVariable( "__return__" );
  999. if( !t || t->getVariableTyp() != FLOAT )
  1000. {
  1001. zPC->stepOut();
  1002. return 1;
  1003. }
  1004. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1005. zPC->count();
  1006. }
  1007. }
  1008. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1009. {
  1010. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1011. {
  1012. Variable *t = zMemory->zVariable( "__return__" );
  1013. if( !t || t->getVariableTyp() != SPIELER )
  1014. {
  1015. zPC->stepOut();
  1016. return 1;
  1017. }
  1018. ( (Spieler *)t )->setSchadenBonus( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1019. zPC->stepOut();
  1020. return 1;
  1021. }
  1022. }
  1023. zPC->stepOut();
  1024. return 0;
  1025. }
  1026. SpielerSetLebensraub::SpielerSetLebensraub( Aktion *lebensraub, Aktion *spieler )
  1027. : Aktion( SPIELER_SET_LEBENSRAUB )
  1028. {
  1029. this->lebensraub = lebensraub;
  1030. this->spieler = spieler;
  1031. }
  1032. SpielerSetLebensraub::~SpielerSetLebensraub()
  1033. {
  1034. lebensraub->release();
  1035. spieler->release();
  1036. }
  1037. bool SpielerSetLebensraub::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1038. {
  1039. zPC->stepIn();
  1040. if( zPC->currentPosition() == 0 )
  1041. {
  1042. if( lebensraub->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1043. {
  1044. Variable *t = zMemory->zVariable( "__return__" );
  1045. if( !t || t->getVariableTyp() != FLOAT )
  1046. {
  1047. zPC->stepOut();
  1048. return 1;
  1049. }
  1050. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1051. zPC->count();
  1052. }
  1053. }
  1054. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1055. {
  1056. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1057. {
  1058. Variable *t = zMemory->zVariable( "__return__" );
  1059. if( !t || t->getVariableTyp() != SPIELER )
  1060. {
  1061. zPC->stepOut();
  1062. return 1;
  1063. }
  1064. ( (Spieler *)t )->setLebensRaub( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1065. zPC->stepOut();
  1066. return 1;
  1067. }
  1068. }
  1069. zPC->stepOut();
  1070. return 0;
  1071. }
  1072. SpielerSetLebensregeneration::SpielerSetLebensregeneration( Aktion *regeneration, Aktion *spieler )
  1073. : Aktion( SPIELER_SET_LEBENSRAUB )
  1074. {
  1075. this->regeneration = regeneration;
  1076. this->spieler = spieler;
  1077. }
  1078. SpielerSetLebensregeneration::~SpielerSetLebensregeneration()
  1079. {
  1080. regeneration->release();
  1081. spieler->release();
  1082. }
  1083. bool SpielerSetLebensregeneration::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1084. {
  1085. zPC->stepIn();
  1086. if( zPC->currentPosition() == 0 )
  1087. {
  1088. if( regeneration->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1089. {
  1090. Variable *t = zMemory->zVariable( "__return__" );
  1091. if( !t || t->getVariableTyp() != FLOAT )
  1092. {
  1093. zPC->stepOut();
  1094. return 1;
  1095. }
  1096. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1097. zPC->count();
  1098. }
  1099. }
  1100. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1101. {
  1102. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1103. {
  1104. Variable *t = zMemory->zVariable( "__return__" );
  1105. if( !t || t->getVariableTyp() != SPIELER )
  1106. {
  1107. zPC->stepOut();
  1108. return 1;
  1109. }
  1110. ( (Spieler *)t )->setLebensRegeneration( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1111. zPC->stepOut();
  1112. return 1;
  1113. }
  1114. }
  1115. zPC->stepOut();
  1116. return 0;
  1117. }
  1118. SpielerSetAbklingzeitverringerung::SpielerSetAbklingzeitverringerung( Aktion *verringerung, Aktion *spieler )
  1119. : Aktion( SPIELER_SET_ABKLINGZEITVERRINGERUNG )
  1120. {
  1121. this->verringerung = verringerung;
  1122. this->spieler = spieler;
  1123. }
  1124. SpielerSetAbklingzeitverringerung::~SpielerSetAbklingzeitverringerung()
  1125. {
  1126. verringerung->release();
  1127. spieler->release();
  1128. }
  1129. bool SpielerSetAbklingzeitverringerung::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1130. {
  1131. zPC->stepIn();
  1132. if( zPC->currentPosition() == 0 )
  1133. {
  1134. if( verringerung->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1135. {
  1136. Variable *t = zMemory->zVariable( "__return__" );
  1137. if( !t || t->getVariableTyp() != FLOAT )
  1138. {
  1139. zPC->stepOut();
  1140. return 1;
  1141. }
  1142. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1143. zPC->count();
  1144. }
  1145. }
  1146. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1147. {
  1148. if( spieler->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1149. {
  1150. Variable *t = zMemory->zVariable( "__return__" );
  1151. if( !t || t->getVariableTyp() != SPIELER )
  1152. {
  1153. zPC->stepOut();
  1154. return 1;
  1155. }
  1156. ( (Spieler *)t )->setAbklingZeitVerringerung( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1157. zPC->stepOut();
  1158. return 1;
  1159. }
  1160. }
  1161. zPC->stepOut();
  1162. return 0;
  1163. }
  1164. DropSetTime::DropSetTime( Aktion *time, Aktion *drop )
  1165. : Aktion( DROP_SET_TIME )
  1166. {
  1167. this->time = time;
  1168. this->drop = drop;
  1169. }
  1170. DropSetTime::~DropSetTime()
  1171. {
  1172. time->release();
  1173. drop->release();
  1174. }
  1175. bool DropSetTime::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1176. {
  1177. zPC->stepIn();
  1178. if( zPC->currentPosition() == 0 )
  1179. {
  1180. if( time->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1181. {
  1182. Variable *t = zMemory->zVariable( "__return__" );
  1183. if( !t || t->getVariableTyp() != FLOAT )
  1184. {
  1185. zPC->stepOut();
  1186. return 1;
  1187. }
  1188. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1189. zPC->count();
  1190. }
  1191. }
  1192. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1193. {
  1194. if( drop->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1195. {
  1196. Variable *t = zMemory->zVariable( "__return__" );
  1197. if( !t || t->getVariableTyp() != DROP )
  1198. {
  1199. zPC->stepOut();
  1200. return 1;
  1201. }
  1202. ( (Drop *)t )->setTime( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1203. zPC->stepOut();
  1204. return 1;
  1205. }
  1206. }
  1207. zPC->stepOut();
  1208. return 0;
  1209. }
  1210. DropSetMaxTime::DropSetMaxTime( Aktion *time, Aktion *drop )
  1211. : Aktion( DROP_SET_MAX_TIME )
  1212. {
  1213. this->time = time;
  1214. this->drop = drop;
  1215. }
  1216. DropSetMaxTime::~DropSetMaxTime()
  1217. {
  1218. time->release();
  1219. drop->release();
  1220. }
  1221. bool DropSetMaxTime::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1222. {
  1223. zPC->stepIn();
  1224. if( zPC->currentPosition() == 0 )
  1225. {
  1226. if( time->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1227. {
  1228. Variable *t = zMemory->zVariable( "__return__" );
  1229. if( !t || t->getVariableTyp() != INTEGER )
  1230. {
  1231. zPC->stepOut();
  1232. return 1;
  1233. }
  1234. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1235. zPC->count();
  1236. }
  1237. }
  1238. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1239. {
  1240. if( drop->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1241. {
  1242. Variable *t = zMemory->zVariable( "__return__" );
  1243. if( !t || t->getVariableTyp() != DROP )
  1244. {
  1245. zPC->stepOut();
  1246. return 1;
  1247. }
  1248. ( (Drop *)t )->setMaxTime( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1249. zPC->stepOut();
  1250. return 1;
  1251. }
  1252. }
  1253. zPC->stepOut();
  1254. return 0;
  1255. }
  1256. DropSetArea::DropSetArea( Aktion *minX, Aktion *maxX, Aktion *minY, Aktion *maxY, Aktion *drop )
  1257. : Aktion( DROP_SET_AREA )
  1258. {
  1259. this->minX = minX;
  1260. this->maxX = maxX;
  1261. this->minY = minY;
  1262. this->maxY = maxY;
  1263. this->drop = drop;
  1264. }
  1265. DropSetArea::~DropSetArea()
  1266. {
  1267. minX->release();
  1268. maxX->release();
  1269. minY->release();
  1270. maxY->release();
  1271. drop->release();
  1272. }
  1273. bool DropSetArea::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1274. {
  1275. zPC->stepIn();
  1276. if( zPC->currentPosition() == 0 )
  1277. {
  1278. if( minX->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1279. {
  1280. Variable *t = zMemory->zVariable( "__return__" );
  1281. if( !t || t->getVariableTyp() != INTEGER )
  1282. {
  1283. zPC->stepOut();
  1284. return 1;
  1285. }
  1286. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1287. zPC->count();
  1288. }
  1289. }
  1290. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1291. {
  1292. if( maxX->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1293. {
  1294. Variable *t = zMemory->zVariable( "__return__" );
  1295. if( !t || t->getVariableTyp() != INTEGER )
  1296. {
  1297. zPC->stepOut();
  1298. return 1;
  1299. }
  1300. zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
  1301. zPC->count();
  1302. }
  1303. }
  1304. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  1305. {
  1306. if( minY->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1307. {
  1308. Variable *t = zMemory->zVariable( "__return__" );
  1309. if( !t || t->getVariableTyp() != INTEGER )
  1310. {
  1311. zPC->stepOut();
  1312. return 1;
  1313. }
  1314. zMemory->setVar( zPC->getUniqueString() + "R2__", t->getThis() );
  1315. zPC->count();
  1316. }
  1317. }
  1318. if( zPC->currentPosition() == 3 && waitCount <= 0 )
  1319. {
  1320. if( maxY->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1321. {
  1322. Variable *t = zMemory->zVariable( "__return__" );
  1323. if( !t || t->getVariableTyp() != INTEGER )
  1324. {
  1325. zPC->stepOut();
  1326. return 1;
  1327. }
  1328. zMemory->setVar( zPC->getUniqueString() + "R3__", t->getThis() );
  1329. zPC->count();
  1330. }
  1331. }
  1332. if( zPC->currentPosition() == 4 && waitCount <= 0 )
  1333. {
  1334. if( drop->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1335. {
  1336. Variable *t = zMemory->zVariable( "__return__" );
  1337. if( !t || t->getVariableTyp() != DROP )
  1338. {
  1339. zPC->stepOut();
  1340. return 1;
  1341. }
  1342. ( (Drop *)t )->setMinX( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1343. ( (Drop *)t )->setMaxX( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R1__" ) )->getValue() );
  1344. ( (Drop *)t )->setMinY( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R2__" ) )->getValue() );
  1345. ( (Drop *)t )->setMaxY( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R3__" ) )->getValue() );
  1346. zPC->stepOut();
  1347. return 1;
  1348. }
  1349. }
  1350. zPC->stepOut();
  1351. return 0;
  1352. }
  1353. DropDoDrop::DropDoDrop( Aktion *drop )
  1354. : Aktion( DROP_DO_DROP )
  1355. {
  1356. this->drop = drop;
  1357. }
  1358. DropDoDrop::~DropDoDrop()
  1359. {}
  1360. bool DropDoDrop::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1361. {
  1362. if( drop->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1363. {
  1364. Variable *t = zMemory->zVariable( "__return__" );
  1365. if( !t || t->getVariableTyp() != DROP )
  1366. {
  1367. zPC->stepOut();
  1368. return 1;
  1369. }
  1370. ( (Drop *)t )->doDrop( zSpiel );
  1371. return 1;
  1372. }
  1373. return 0;
  1374. }
  1375. BariereSetEingeschaltet::BariereSetEingeschaltet( Aktion *eingeschaltet, Aktion *bariere )
  1376. : Aktion( BARIERE_SET_EINGESCHALTET )
  1377. {
  1378. this->eingeschaltet = eingeschaltet;
  1379. this->bariere = bariere;
  1380. }
  1381. BariereSetEingeschaltet::~BariereSetEingeschaltet()
  1382. {
  1383. eingeschaltet->release();
  1384. bariere->release();
  1385. }
  1386. bool BariereSetEingeschaltet::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1387. {
  1388. zPC->stepIn();
  1389. if( zPC->currentPosition() == 0 )
  1390. {
  1391. if( eingeschaltet->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1392. {
  1393. Variable *t = zMemory->zVariable( "__return__" );
  1394. if( !t || t->getVariableTyp() != BOOLEAN )
  1395. {
  1396. zPC->stepOut();
  1397. return 1;
  1398. }
  1399. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1400. zPC->count();
  1401. }
  1402. }
  1403. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1404. {
  1405. if( bariere->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1406. {
  1407. Variable *t = zMemory->zVariable( "__return__" );
  1408. if( !t || t->getVariableTyp() != BARIERE )
  1409. {
  1410. zPC->stepOut();
  1411. return 1;
  1412. }
  1413. ( (Bariere *)t )->setEingeschaltet( ( (Boolean *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1414. zPC->stepOut();
  1415. return 1;
  1416. }
  1417. }
  1418. zPC->stepOut();
  1419. return 0;
  1420. }
  1421. BariereSetPosition::BariereSetPosition( Aktion *x, Aktion *y, Aktion *bariere )
  1422. : Aktion( BARIERE_SET_POSITION )
  1423. {
  1424. this->x = x;
  1425. this->y = y;
  1426. this->bariere = bariere;
  1427. }
  1428. BariereSetPosition::~BariereSetPosition()
  1429. {
  1430. x->release();
  1431. y->release();
  1432. bariere->release();
  1433. }
  1434. bool BariereSetPosition::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1435. {
  1436. zPC->stepIn();
  1437. if( zPC->currentPosition() == 0 )
  1438. {
  1439. if( x->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1440. {
  1441. Variable *t = zMemory->zVariable( "__return__" );
  1442. if( !t || t->getVariableTyp() != FLOAT )
  1443. {
  1444. zPC->stepOut();
  1445. return 1;
  1446. }
  1447. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1448. zPC->count();
  1449. }
  1450. }
  1451. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1452. {
  1453. if( y->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1454. {
  1455. Variable *t = zMemory->zVariable( "__return__" );
  1456. if( !t || t->getVariableTyp() != FLOAT )
  1457. {
  1458. zPC->stepOut();
  1459. return 1;
  1460. }
  1461. zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
  1462. zPC->count();
  1463. }
  1464. }
  1465. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  1466. {
  1467. if( bariere->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1468. {
  1469. Variable *t = zMemory->zVariable( "__return__" );
  1470. if( !t || t->getVariableTyp() != BARIERE )
  1471. {
  1472. zPC->stepOut();
  1473. return 1;
  1474. }
  1475. ( (Bariere *)t )->setX( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1476. ( (Bariere *)t )->setY( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R1__" ) )->getValue() );
  1477. zPC->stepOut();
  1478. return 1;
  1479. }
  1480. }
  1481. zPC->stepOut();
  1482. return 0;
  1483. }
  1484. BariereSetTeam::BariereSetTeam( Aktion *team, Aktion *bariere )
  1485. : Aktion( BARIERE_SET_TEAM )
  1486. {
  1487. this->team = team;
  1488. this->bariere = bariere;
  1489. }
  1490. BariereSetTeam::~BariereSetTeam()
  1491. {
  1492. team->release();
  1493. bariere->release();
  1494. }
  1495. bool BariereSetTeam::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1496. {
  1497. zPC->stepIn();
  1498. if( zPC->currentPosition() == 0 )
  1499. {
  1500. if( team->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1501. {
  1502. Variable *t = zMemory->zVariable( "__return__" );
  1503. if( !t || t->getVariableTyp() != TEAM )
  1504. {
  1505. zPC->stepOut();
  1506. return 1;
  1507. }
  1508. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1509. zPC->count();
  1510. }
  1511. }
  1512. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1513. {
  1514. if( bariere->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1515. {
  1516. Variable *t = zMemory->zVariable( "__return__" );
  1517. if( !t || t->getVariableTyp() != BARIERE )
  1518. {
  1519. zPC->stepOut();
  1520. return 1;
  1521. }
  1522. ( (Bariere *)t )->setTeam( ( (Team *)zMemory->getVariable( zPC->getUniqueString() + "R0__" ) ) );
  1523. zPC->stepOut();
  1524. return 1;
  1525. }
  1526. }
  1527. zPC->stepOut();
  1528. return 0;
  1529. }
  1530. SchalterSetPosition::SchalterSetPosition( Aktion *x, Aktion *y, Aktion *schalter )
  1531. : Aktion( SCHALTER_SET_POSITION )
  1532. {
  1533. this->x = x;
  1534. this->y = y;
  1535. this->schalter = schalter;
  1536. }
  1537. SchalterSetPosition::~SchalterSetPosition()
  1538. {
  1539. x->release();
  1540. y->release();
  1541. schalter->release();
  1542. }
  1543. bool SchalterSetPosition::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1544. {
  1545. zPC->stepIn();
  1546. if( zPC->currentPosition() == 0 )
  1547. {
  1548. if( x->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1549. {
  1550. Variable *t = zMemory->zVariable( "__return__" );
  1551. if( !t || t->getVariableTyp() != FLOAT )
  1552. {
  1553. zPC->stepOut();
  1554. return 1;
  1555. }
  1556. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1557. zPC->count();
  1558. }
  1559. }
  1560. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1561. {
  1562. if( y->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1563. {
  1564. Variable *t = zMemory->zVariable( "__return__" );
  1565. if( !t || t->getVariableTyp() != FLOAT )
  1566. {
  1567. zPC->stepOut();
  1568. return 1;
  1569. }
  1570. zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
  1571. zPC->count();
  1572. }
  1573. }
  1574. if( zPC->currentPosition() == 2 && waitCount <= 0 )
  1575. {
  1576. if( schalter->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1577. {
  1578. Variable *t = zMemory->zVariable( "__return__" );
  1579. if( !t || t->getVariableTyp() != SCHALTER )
  1580. {
  1581. zPC->stepOut();
  1582. return 1;
  1583. }
  1584. ( (Schalter *)t )->setX( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1585. ( (Schalter *)t )->setY( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R1__" ) )->getValue() );
  1586. zPC->stepOut();
  1587. return 1;
  1588. }
  1589. }
  1590. zPC->stepOut();
  1591. return 0;
  1592. }
  1593. SchalterSetErlaubt::SchalterSetErlaubt( Aktion *erlaubt, Aktion *schalter )
  1594. : Aktion( SCHALTER_SET_ERLAUBT )
  1595. {
  1596. this->erlaubt = erlaubt;
  1597. this->schalter = schalter;
  1598. }
  1599. SchalterSetErlaubt::~SchalterSetErlaubt()
  1600. {
  1601. erlaubt->release();
  1602. schalter->release();
  1603. }
  1604. bool SchalterSetErlaubt::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
  1605. {
  1606. zPC->stepIn();
  1607. if( zPC->currentPosition() == 0 )
  1608. {
  1609. if( erlaubt->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1610. {
  1611. Variable *t = zMemory->zVariable( "__return__" );
  1612. if( !t || t->getVariableTyp() != BOOLEAN )
  1613. {
  1614. zPC->stepOut();
  1615. return 1;
  1616. }
  1617. zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
  1618. zPC->count();
  1619. }
  1620. }
  1621. if( zPC->currentPosition() == 1 && waitCount <= 0 )
  1622. {
  1623. if( schalter->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1624. {
  1625. Variable *t = zMemory->zVariable( "__return__" );
  1626. if( !t || t->getVariableTyp() != SCHALTER )
  1627. {
  1628. zPC->stepOut();
  1629. return 1;
  1630. }
  1631. ( (Schalter *)t )->setAktive( ( (Boolean *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
  1632. zPC->stepOut();
  1633. return 1;
  1634. }
  1635. }
  1636. zPC->stepOut();
  1637. return 0;
  1638. }
  1639. SchalterAktivieren::SchalterAktivieren( Aktion *schalter )
  1640. : Aktion( SCHALTER_AKTIVIEREN )
  1641. {
  1642. this->schalter = schalter;
  1643. }
  1644. SchalterAktivieren::~SchalterAktivieren()
  1645. {
  1646. schalter->release();
  1647. }
  1648. bool SchalterAktivieren::runNext( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
  1649. {
  1650. if( schalter->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
  1651. {
  1652. Variable *t = zMemory->zVariable( "__return__" );
  1653. if( !t || t->getVariableTyp() != SCHALTER )
  1654. {
  1655. zPC->stepOut();
  1656. return 1;
  1657. }
  1658. zSpiel->activateShalter( ( (Schalter *)t )->getId() );
  1659. return 1;
  1660. }
  1661. return 0;
  1662. }