summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/interfacegats.cpp37
-rw-r--r--src/situation.h4
2 files changed, 38 insertions, 3 deletions
diff --git a/src/interfacegats.cpp b/src/interfacegats.cpp
index 9f6cf8d..2e33aee 100644
--- a/src/interfacegats.cpp
+++ b/src/interfacegats.cpp
@@ -3,6 +3,8 @@
3#include "smlnode.h" 3#include "smlnode.h"
4#include "gamestate.h" 4#include "gamestate.h"
5#include "options.h" 5#include "options.h"
6#include "situation.h"
7#include "command.h"
6 8
7#include "smlrendererhtml.h" 9#include "smlrendererhtml.h"
8 10
@@ -11,6 +13,7 @@
11#include <bu/file.h> 13#include <bu/file.h>
12#include <gats/gatsstream.h> 14#include <gats/gatsstream.h>
13#include <gats/types.h> 15#include <gats/types.h>
16#include <stdlib.h>
14 17
15using namespace Bu; 18using namespace Bu;
16 19
@@ -40,7 +43,17 @@ void InterfaceGats::run( class Game *pGame )
40 43
41 delete pObj; 44 delete pObj;
42 45
43 gs.execCommand( Options::getInstance().sCommand ); 46 Situation *pSit = gs.getCurSituation();
47 switch( pSit->getInputType() )
48 {
49 case Situation::inputCommand:
50 gs.execCommand( Options::getInstance().sCommand );
51 break;
52
53 case Situation::inputOption:
54 gs.execOption( strtol( Options::getInstance().sCommand.getStr(), NULL, 10 ) );
55 break;
56 }
44 } 57 }
45 else 58 else
46 { 59 {
@@ -60,6 +73,28 @@ void InterfaceGats::run( class Game *pGame )
60 pDict = new Gats::Dictionary(); 73 pDict = new Gats::Dictionary();
61 pDict->insertBool("running", false ); 74 pDict->insertBool("running", false );
62 } 75 }
76
77 Situation *pSit = gs.getCurSituation();
78 pDict->insert("input", (int)pSit->getInputType() );
79 switch( pSit->getInputType() )
80 {
81 case Situation::inputCommand:
82 break;
83
84 case Situation::inputOption:
85 {
86 Gats::List *pLst = pDict->insertList("options");
87 const CommandSet::CommandList &cl =
88 pSit->getCommandSet().getCommandList();
89 for( CommandSet::CommandList::const_iterator i = cl.begin();
90 i; i++ )
91 {
92 pLst->append( (*i)->getRoot() );
93 }
94 }
95 break;
96 }
97
63 pDict->insert("result", mbResult.getString() ); 98 pDict->insert("result", mbResult.getString() );
64 gsIn.writeObject( pDict ); 99 gsIn.writeObject( pDict );
65 delete pDict; 100 delete pDict;
diff --git a/src/situation.h b/src/situation.h
index 794b308..b859c0f 100644
--- a/src/situation.h
+++ b/src/situation.h
@@ -11,8 +11,8 @@ friend class GameBuilder;
11public: 11public:
12 enum InputType 12 enum InputType
13 { 13 {
14 inputCommand, 14 inputCommand = 1,
15 inputOption, 15 inputOption = 2,
16 }; 16 };
17 17
18 Situation( const Bu::String &sName, InputType tInput ); 18 Situation( const Bu::String &sName, InputType tInput );