فهرست منبع

Bestenlisten hinzugefügt
Base eroberungs Timer hinzugefügt

Kolja Strohm 4 سال پیش
والد
کامیت
53358cb6d2

+ 68 - 19
StickmanWorldOnline/Aktionen.cpp

@@ -1,6 +1,7 @@
 #include "Aktionen.h"
 #include "Trigger.h"
 #include "Spiel.h"
+#include "Bestenliste.h"
 
 
 #define zParam( x )    zEvaluatedParam( x, zMemory, zPC )
@@ -2650,31 +2651,14 @@ void BooleanRechnung::run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMem
         case TASTE:
             setReturn( new Boolean( ( op == GLEICH ) == ( ( (Integer *)zParam( 0 ) )->getValue() == ( (Integer *)zParam( 1 ) )->getValue() ) ) );
             break;
-        case TIMER:
-        case TEAM:
-        case BARIERE:
-        case SCHALTER:
-        case BASE:
-        case DROP:
-        case GEGENSTAND:
-        case GESCHOSS:
-        case SCHIENE:
-        case TUNNEL:
-        case UMLENKUNG:
-        case TRIGGER:
-        case FEUERBALL_TREFFER:
-        case AKTION:
-        case GAME_OBJEKT:
-        case ALLE:
-        case SPIELER:
-            setReturn( new Boolean( ( op == GLEICH ) == ( zParam( 0 ) == zParam( 1 ) ) ) );
-            break;
         case GEGENSTAND_TYP:
             setReturn( new Boolean( ( op == GLEICH ) == ( ( (GegenstandTypVar *)zParam( 0 ) )->getValue() == ( (GegenstandTypVar *)zParam( 1 ) )->getValue() ) ) );
             break;
         case GESCHOSS_TYP:
             setReturn( new Boolean( ( op == GLEICH ) == ( ( (String *)zParam( 0 ) )->getValue().istGleich( ( (String *)zParam( 1 ) )->getValue() ) ) ) );
             break;
+        default:
+            setReturn( new Boolean( ( op == GLEICH ) == ( zParam( 0 ) == zParam( 1 ) ) ) );
         }
     }
     if( op == GREATER || op == SMALLER || op == GREATER_OR_EQUAL || op == SMALLER_OR_EQUAL )
@@ -2843,4 +2827,69 @@ IntegerAusFloat::IntegerAusFloat( RCArray< Aktion > *subActions )
 void IntegerAusFloat::run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount )
 {
     setReturn( new Integer( (int)( (Float *)zParam( 0 ) )->getValue() ) );
+}
+
+
+BestenlisteNeu::BestenlisteNeu( RCArray<Aktion> *subActions )
+    : Aktion( BESTENLISTE_NEU, subActions )
+{}
+
+void BestenlisteNeu::run( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
+{
+    setReturn( new Bestenliste( zSpiel->getNextId() ) );
+}
+
+
+BestenlisteAddZeile::BestenlisteAddZeile( RCArray<Aktion> *subActions )
+    : Aktion( BESTENLISTE_ADD_ZEILE, subActions )
+{
+    erlaubteTypen.add( STRING );
+    erlaubteTypen.add( BESTENLISTE );
+}
+
+void BestenlisteAddZeile::run( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
+{
+    ( (Bestenliste *)zParam( 1 ) )->addZeile( ( (String *)zParam( 0 ) )->getValue() );
+}
+
+
+BestenlisteAddSpalte::BestenlisteAddSpalte( RCArray<Aktion> *subActions )
+    : Aktion( BESTENLISTE_ADD_SPALTE, subActions )
+{
+    erlaubteTypen.add( STRING );
+    erlaubteTypen.add( BESTENLISTE );
+}
+
+void BestenlisteAddSpalte::run( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
+{
+    ( (Bestenliste *)zParam( 1 ) )->addSpalte( ( (String *)zParam( 0 ) )->getValue() );
+}
+
+
+BestenlisteSetWert::BestenlisteSetWert( RCArray<Aktion> *subActions )
+    : Aktion( BESTENLISTE_SET_WERT, subActions )
+{
+    erlaubteTypen.add( STRING );
+    erlaubteTypen.add( STRING );
+    erlaubteTypen.add( STRING );
+    erlaubteTypen.add( BESTENLISTE );
+}
+
+void BestenlisteSetWert::run( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
+{
+    ( (Bestenliste *)zParam( 3 ) )->setWert( ( (String *)zParam( 0 ) )->getValue(), ( (String *)zParam( 1 ) )->getValue(), ( (String *)zParam( 3 ) )->getValue() );
+}
+
+
+BestenlisteGetWert::BestenlisteGetWert( RCArray<Aktion> *subActions )
+    : Aktion( BESTENLISTE_GET_WERT, subActions )
+{
+    erlaubteTypen.add( STRING );
+    erlaubteTypen.add( STRING );
+    erlaubteTypen.add( BESTENLISTE );
+}
+
+void BestenlisteGetWert::run( Spiel * zSpiel, Ereignis * zEreignis, LocalMemory * zMemory, ProgramCounter * zPC, double &waitCount )
+{
+    setReturn( new String( ( (Bestenliste *)zParam( 2 ) )->getWert( ( (String *)zParam( 0 ) )->getValue(), ( (String *)zParam( 1 ) )->getValue() ) ) );
 }

+ 46 - 1
StickmanWorldOnline/Aktionen.h

@@ -208,7 +208,12 @@ enum AktionTyp
     FLOAT_ZUFALL,
     INTEGER_AUS_FLOAT,
     KONSTANT_TASTE,
-    KONSTANT_GEGENSTAND_TYP
+    KONSTANT_GEGENSTAND_TYP,
+    BESTENLISTE_NEU,
+    BESTENLISTE_ADD_SPALTE,
+    BESTENLISTE_ADD_ZEILE,
+    BESTENLISTE_SET_WERT,
+    BESTENLISTE_GET_WERT
 };
 
 enum Operator
@@ -1836,3 +1841,43 @@ public:
     IntegerAusFloat( RCArray< Aktion > *subActions );
     void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
 };
+
+class BestenlisteNeu : public Aktion
+{
+public:
+    // f
+    BestenlisteNeu( RCArray< Aktion > *subActions );
+    void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
+};
+
+class BestenlisteAddZeile : public Aktion
+{
+public:
+    // f
+    BestenlisteAddZeile( RCArray< Aktion > *subActions );
+    void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
+};
+
+class BestenlisteAddSpalte : public Aktion
+{
+public:
+    // f
+    BestenlisteAddSpalte( RCArray< Aktion > *subActions );
+    void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
+};
+
+class BestenlisteSetWert : public Aktion
+{
+public:
+    // f
+    BestenlisteSetWert( RCArray< Aktion > *subActions );
+    void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
+};
+
+class BestenlisteGetWert : public Aktion
+{
+public:
+    // f
+    BestenlisteGetWert( RCArray< Aktion > *subActions );
+    void run( Spiel *zSpiel, Ereignis *zEreignis, LocalMemory *zMemory, ProgramCounter *zPC, double &waitCount ) override;
+};

+ 4 - 1
StickmanWorldOnline/Base.cpp

@@ -3,9 +3,12 @@
 #include "Ereignis.h"
 
 
-Base::Base( int id, int x, int y, int width, int height, int maxTime, Team *team )
+Base::Base( int id, int x, int y, int width, int height, bool showTimer, Punkt timerPosition, int timerFarbe, int maxTime, Team *team )
     : GameObject( BASE, x, y, width, height )
 {
+    this->showTimer = showTimer;
+    this->timerPosition = timerPosition;
+    this->timerFarbe = timerFarbe;
     this->id = id;
     this->maxTime = maxTime;
     this->team = team;

+ 5 - 1
StickmanWorldOnline/Base.h

@@ -1,5 +1,6 @@
 #pragma once
 
+#include <Punkt.h>
 #include "GameObject.h"
 #include "Team.h"
 
@@ -14,9 +15,12 @@ private:
     bool inChange;
     Team *nextTeam;
     float leftTime;
+    bool showTimer;
+    Punkt timerPosition;
+    int timerFarbe;
 
 public:
-    Base( int id, int x, int y, int width, int height, int maxTime = 10, Team *team = 0 );
+    Base( int id, int x, int y, int width, int height, bool showTimer, Punkt timerPosition, int timerFarbe, int maxTime = 10, Team *team = 0 );
     ~Base();
     void setTeam( Team *team, Spiel *zSpiel );
     void startChange( Team *team );

+ 62 - 0
StickmanWorldOnline/Bestenliste.cpp

@@ -0,0 +1,62 @@
+#include "Bestenliste.h"
+
+
+Bestenliste::Bestenliste( int id )
+    : Variable( BESTENLISTE )
+{
+    this->id = id;
+    sichtbar = 1;
+}
+
+void Bestenliste::setSichtbar( bool sichtbar )
+{
+    this->sichtbar = sichtbar;
+}
+
+void Bestenliste::addSpalte( const char *name )
+{
+    spalten.add( new Text( name ) );
+}
+
+void Bestenliste::addZeile( const char *name )
+{
+    zeilen.add( new Text( name ) );
+}
+
+void Bestenliste::setWert( const char *spalte, const char *zeile, const char *wert )
+{
+    int spalteI = 0;
+    for( auto s = spalten.getIterator(); s; s++, spalteI++ )
+    {
+        if( s->istGleich( spalte ) )
+            break;
+    }
+    int zeileI = 0;
+    for( auto z = zeilen.getIterator(); z; z++, spalteI++ )
+    {
+        if( z->istGleich( zeile ) )
+            break;
+    }
+    if( !werte.z( zeileI ) )
+        werte.set( new RCArray< Text >(), zeileI );
+    werte.z( zeileI )->set( new Text( wert ), spalteI );
+}
+
+const char *Bestenliste::getWert( const char *spalte, const char *zeile )
+{
+    int spalteI = 0;
+    for( auto s = spalten.getIterator(); s; s++, spalteI++ )
+    {
+        if( s->istGleich( spalte ) )
+            break;
+    }
+    int zeileI = 0;
+    for( auto z = zeilen.getIterator(); z; z++, spalteI++ )
+    {
+        if( z->istGleich( zeile ) )
+            break;
+    }
+    if( !werte.z( zeileI ) || !werte.z( zeileI )->hat( spalteI ) )
+        return "";
+    return werte.z( zeileI )->z( spalteI )->getText();
+}

+ 24 - 0
StickmanWorldOnline/Bestenliste.h

@@ -0,0 +1,24 @@
+#pragma once
+
+
+#include "Variablen.h"
+#include "Array.h"
+
+
+class Bestenliste : public Variable
+{
+private:
+    RCArray< Text > spalten;
+    RCArray< Text > zeilen;
+    RCArray< RCArray< Text > > werte;
+    int id;
+    bool sichtbar;
+
+public:
+    Bestenliste( int id );
+    void setSichtbar( bool sichtbar );
+    void addSpalte( const char *name );
+    void addZeile( const char *name );
+    void setWert( const char *spalte, const char *zeile, const char *wert );
+    const char *getWert( const char *spalte, const char *zeile );
+};

+ 4 - 2
StickmanWorldOnline/Editor.cpp

@@ -27,6 +27,7 @@ void Editor::open()
 
 bool Editor::nachricht( SKlient *k )
 {
+    /*
     err = "";
     char n = 0;
     k->getNachrichtEncrypted( &n, 1 );
@@ -440,7 +441,7 @@ bool Editor::nachricht( SKlient *k )
         err = "Unbekannte Nachricht. Error Code: " __FILE__ ":";
         err += __LINE__;
         return 0;
-    }
+    }*/
     return 0;
 }
 
@@ -930,7 +931,7 @@ bool Editor::createSitzung()
 }
 
 bool Editor::saveSitzung()
-{
+{/*
     Text pf = pfad.getText();
     pf.remove( pf.getLength() - 6, pf.getLength() );
     pf += "map/server/data_tmp.map";
@@ -1168,5 +1169,6 @@ bool Editor::saveSitzung()
         return 0;
     }
     DateiRemove( pfad.getText() );
+    */
     return 1;
 }

+ 21 - 1
StickmanWorldOnline/Reader.cpp

@@ -550,6 +550,16 @@ Aktion *MapReader::readAktion( Datei &dat )
         return new FloatZufall( params );
     case INTEGER_AUS_FLOAT:
         return new IntegerAusFloat( params );
+    case BESTENLISTE_NEU:
+        return new BestenlisteNeu( params );
+    case BESTENLISTE_ADD_SPALTE:
+        return new BestenlisteAddSpalte( params );
+    case BESTENLISTE_ADD_ZEILE:
+        return new BestenlisteAddZeile( params );
+    case BESTENLISTE_SET_WERT:
+        return new BestenlisteSetWert( params );
+    case BESTENLISTE_GET_WERT:
+        return new BestenlisteGetWert( params );
     }
     params->release();
     return new KonstantNichts();
@@ -679,6 +689,10 @@ void MapReader::ladeKarte( Spiel *zSpiel )
         int maxTime;
         int team;
         int id;
+        bool showTimer;
+        int timerX;
+        int timerY;
+        int timerFarbe;
         mapFile.lese( (char *)& id, 4 );
         mapFile.lese( (char *)& x, 4 );
         mapFile.lese( (char *)& y, 4 );
@@ -686,7 +700,11 @@ void MapReader::ladeKarte( Spiel *zSpiel )
         mapFile.lese( (char *)& height, 4 );
         mapFile.lese( (char *)& maxTime, 4 );
         mapFile.lese( (char *)& team, 4 );
-        zSpiel->addBase( new Base( id, x, y, breite, height, maxTime, zSpiel->getTeam( team ) ) );
+        mapFile.lese( (char *)& showTimer, 1 );
+        mapFile.lese( (char *)& timerX, 4 );
+        mapFile.lese( (char *)& timerY, 4 );
+        mapFile.lese( (char *)& timerFarbe, 4 );
+        zSpiel->addBase( new Base( id, x, y, breite, height, showTimer, Punkt( timerX, timerY ), timerFarbe, maxTime, zSpiel->getTeam( team ) ) );
     }
     // Drops
     mapFile.lese( (char *)& anz, 4 );
@@ -1004,6 +1022,8 @@ void MapReader::ladeKarte( Spiel *zSpiel )
                 var = zSpiel->getTrigger( id );
                 break;
             }
+            default:
+                var = new Variable( NICHTS );
             }
         }
         zSpiel->addVariable( name, var );

+ 2 - 0
StickmanWorldOnline/StickmanWorldOnline.vcxproj

@@ -86,6 +86,7 @@
     <ClCompile Include="Aktionen.cpp" />
     <ClCompile Include="Bariere.cpp" />
     <ClCompile Include="Base.cpp" />
+    <ClCompile Include="Bestenliste.cpp" />
     <ClCompile Include="BosheitRune.cpp" />
     <ClCompile Include="Brand.cpp" />
     <ClCompile Include="DllStart.cpp" />
@@ -123,6 +124,7 @@
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Aktionen.h" />
+    <ClInclude Include="Bestenliste.h" />
     <ClInclude Include="BosheitRune.h" />
     <ClInclude Include="Brand.h" />
     <ClInclude Include="DrachenAuge.h" />

+ 6 - 0
StickmanWorldOnline/StickmanWorldOnline.vcxproj.filters

@@ -144,6 +144,9 @@
     <ClCompile Include="Editor.cpp">
       <Filter>Editor</Filter>
     </ClCompile>
+    <ClCompile Include="Bestenliste.cpp">
+      <Filter>Spiel\Objekte</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="SpielKlasse.h">
@@ -269,5 +272,8 @@
     <ClInclude Include="DrachenAuge.h">
       <Filter>Spiel\Effekte</Filter>
     </ClInclude>
+    <ClInclude Include="Bestenliste.h">
+      <Filter>Spiel\Objekte</Filter>
+    </ClInclude>
   </ItemGroup>
 </Project>

+ 1 - 0
StickmanWorldOnline/Variablen.h

@@ -31,6 +31,7 @@ enum VariableTyp
     FEUERBALL_TREFFER,
     AKTION,
     GAME_OBJEKT,
+    BESTENLISTE,
     ALLE
 };