Browse Source

Aktionen zum ändern von Drop Zuständen implementiert

Kolja Strohm 5 years ago
parent
commit
ed9ca47a17
1 changed files with 178 additions and 1 deletions
  1. 178 1
      StickmanWorldOnline/Aktionen.cpp

+ 178 - 1
StickmanWorldOnline/Aktionen.cpp

@@ -1288,7 +1288,7 @@ DropSetTime::~DropSetTime()
     drop->release();
 }
 
-bool DropSetTime::runNext( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
+bool DropSetTime::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
 {
     zPC->stepIn();
     if( zPC->currentPosition() == 0 )
@@ -1323,3 +1323,180 @@ bool DropSetTime::runNext( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * z
     zPC->stepOut();
     return 0;
 }
+
+
+DropSetMaxTime::DropSetMaxTime( Aktion *time, Aktion *drop )
+    : Aktion( DROP_SET_MAX_TIME )
+{
+    this->time = time;
+    this->drop = drop;
+}
+
+DropSetMaxTime::~DropSetMaxTime()
+{
+    time->release();
+    drop->release();
+}
+
+bool DropSetMaxTime::runNext( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
+{
+    zPC->stepIn();
+    if( zPC->currentPosition() == 0 )
+    {
+        if( time->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != INTEGER )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
+            zPC->count();
+        }
+    }
+    if( zPC->currentPosition() == 1 && waitCount <= 0 )
+    {
+        if( drop->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != DROP )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            ( (Drop *)t )->setMaxTime( ( (Float *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
+            zPC->stepOut();
+            return 1;
+        }
+    }
+    zPC->stepOut();
+    return 0;
+}
+
+
+DropSetArea::DropSetArea( Aktion *minX, Aktion *maxX, Aktion *minY, Aktion *maxY, Aktion *drop )
+    : Aktion( DROP_SET_AREA )
+{
+    this->minX = minX;
+    this->maxX = maxX;
+    this->minY = minY;
+    this->maxY = maxY;
+    this->drop = drop;
+}
+
+DropSetArea::~DropSetArea()
+{
+    minX->release();
+    maxX->release();
+    minY->release();
+    maxY->release();
+    drop->release();
+}
+
+bool DropSetArea::runNext( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
+{
+    zPC->stepIn();
+    if( zPC->currentPosition() == 0 )
+    {
+        if( minX->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != INTEGER )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            zMemory->setVar( zPC->getUniqueString() + "R0__", t->getThis() );
+            zPC->count();
+        }
+    }
+    if( zPC->currentPosition() == 1 && waitCount <= 0 )
+    {
+        if( maxX->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != INTEGER )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            zMemory->setVar( zPC->getUniqueString() + "R1__", t->getThis() );
+            zPC->count();
+        }
+    }
+    if( zPC->currentPosition() == 2 && waitCount <= 0 )
+    {
+        if( minY->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != INTEGER )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            zMemory->setVar( zPC->getUniqueString() + "R2__", t->getThis() );
+            zPC->count();
+        }
+    }
+    if( zPC->currentPosition() == 3 && waitCount <= 0 )
+    {
+        if( maxY->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != INTEGER )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            zMemory->setVar( zPC->getUniqueString() + "R3__", t->getThis() );
+            zPC->count();
+        }
+    }
+    if( zPC->currentPosition() == 4 && waitCount <= 0 )
+    {
+        if( drop->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+        {
+            Variable *t = zMemory->zVariable( "__return__" );
+            if( !t || t->getVariableTyp() != DROP )
+            {
+                zPC->stepOut();
+                return 1;
+            }
+            ( (Drop *)t )->setMinX( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R0__" ) )->getValue() );
+            ( (Drop *)t )->setMaxX( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R1__" ) )->getValue() );
+            ( (Drop *)t )->setMinY( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R2__" ) )->getValue() );
+            ( (Drop *)t )->setMaxY( ( (Integer *)zMemory->zVariable( zPC->getUniqueString() + "R3__" ) )->getValue() );
+            zPC->stepOut();
+            return 1;
+        }
+    }
+    zPC->stepOut();
+    return 0;
+}
+
+
+DropDoDrop::DropDoDrop( Aktion *drop )
+    : Aktion( DROP_DO_DROP )
+{
+    this->drop = drop;
+}
+
+DropDoDrop::~DropDoDrop()
+{}
+
+bool DropDoDrop::runNext( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
+{
+    if( drop->runNext( zSpiel, zEreignis, zMemory, zPC, waitCount ) )
+    {
+        Variable *t = zMemory->zVariable( "__return__" );
+        if( !t || t->getVariableTyp() != DROP )
+        {
+            zPC->stepOut();
+            return 1;
+        }
+        ( (Drop *)t )->doDrop( zSpiel );
+        return 1;
+    }
+    return 0;
+}