Browse Source

Neue Aktion: KONSTANT_TASTE

Kolja Strohm 4 years ago
parent
commit
97d295f767
3 changed files with 31 additions and 1 deletions
  1. 12 0
      StickmanWorldOnline/Aktionen.cpp
  2. 12 1
      StickmanWorldOnline/Aktionen.h
  3. 7 0
      StickmanWorldOnline/Reader.cpp

+ 12 - 0
StickmanWorldOnline/Aktionen.cpp

@@ -99,6 +99,18 @@ void KonstantInteger::run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMem
 }
 
 
+KonstantTaste::KonstantTaste( unsigned char val )
+    : Aktion( KONSTANT_TASTE, new RCArray< Aktion >() )
+{
+    this->value = val;
+}
+
+void KonstantTaste::run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
+{
+    setReturn( new Integer( (int)value, 1 ) );
+}
+
+
 KonstantBoolean::KonstantBoolean( bool val )
     : Aktion( KONSTANT_BOOLEAN, new RCArray< Aktion >() )
 {

+ 12 - 1
StickmanWorldOnline/Aktionen.h

@@ -206,7 +206,8 @@ enum AktionTyp
     FLOAT_AUS_TEXT,
     TEXT_AUS_FLOAT,
     FLOAT_ZUFALL,
-    INTEGER_AUS_FLOAT
+    INTEGER_AUS_FLOAT,
+    KONSTANT_TASTE
 };
 
 enum Operator
@@ -277,6 +278,16 @@ public:
     void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
 };
 
+class KonstantTaste : public Aktion
+{
+private:
+    unsigned char value;
+
+public:
+    KonstantTaste( unsigned char taste );
+    void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
+};
+
 class KonstantBoolean : public Aktion
 {
 private:

+ 7 - 0
StickmanWorldOnline/Reader.cpp

@@ -366,6 +366,13 @@ Aktion *MapReader::readAktion( Datei &dat )
         dat.lese( (char *)& i, 4 );
         return new KonstantInteger( i );
     }
+    case KONSTANT_TASTE:
+    {
+        params->release();
+        unsigned char i;
+        dat.lese( (char *)& i, 1 );
+        return new KonstantTaste( i );
+    }
     case KONSTANT_NICHTS:
         params->release();
         return new KonstantNichts();