Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 8, 2017, 2:55:15 PM (6 years ago)
Author:
kuchlert
Message:

eigentlich fertig nur noch altes system entfernen

Location:
code/branches/Dialog_HS17/src/modules/dialog
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Dialog_HS17/src/modules/dialog/Answer.cc

    r11611 r11644  
    2323        }
    2424
    25         void Answer::setAnswerId(std::string answerId){
     25        void Answer::setAnswerId(const std::string& answerId){
    2626                this->answerId_ = answerId;
    2727        }
    2828
    29         std::string Answer::getAnswerId(){
     29        const std::string& Answer::getAnswerId() const
     30        {
    3031                return this->answerId_;
    3132        }
    3233
    33         void Answer::setNextQuestion(std::string nextId)
     34        void Answer::setNextQuestion(const std::string& nextId)
    3435        {
    3536                this->nextQuestionId_ = nextId;
    3637        }
    3738
    38         std::string Answer::getNextQuestion()
     39        const std::string& Answer::getNextQuestion() const
    3940        {
    4041                return this->nextQuestionId_;
    4142        }
    4243
    43         void Answer::setAnswer(std::string answer)
     44        void Answer::setAnswer(const std::string& answer)
    4445        {
    4546                this->answer_ = answer;
    4647        }
    4748
    48         std::string Answer::getAnswer()
     49        const std::string& Answer::getAnswer() const
    4950        {
    5051                return this->answer_;
  • code/branches/Dialog_HS17/src/modules/dialog/Answer.h

    r11611 r11644  
    1818                        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    1919
    20                         void setAnswerId(std::string answerId);
    21                         std::string getAnswerId();
     20                        void setAnswerId(const std::string& answerId); //xmlPort-Funktion, setzt AntwortId
     21                        const std::string& getAnswerId() const; //xmlPort-Funktion,     gibt AntwortId
    2222
    23                         void setNextQuestion(std::string nextId); // "end" um den dialog zu beenden
    24                         std::string getNextQuestion();
     23                        void setNextQuestion(const std::string& nextId); //xmlPort-Funktion, um Dialog zu beenden tag benutzen der von keiner Frage benutzt wird
     24                        const std::string& getNextQuestion() const;     //xmlPort-Funktion, gibt Id der Folgefrage
    2525
    26                         void setAnswer(std::string awns);
    27                         std::string getAnswer();
     26                        void setAnswer(const std::string& awns);        //xmlPort-Funktion, setzt Antworttext
     27                        const std::string& getAnswer() const;   //xmlPort-Funktion,     gibt Antworttext
    2828
    2929                private:
  • code/branches/Dialog_HS17/src/modules/dialog/AnswerId.cc

    r11611 r11644  
    1919        }
    2020
    21         void AnswerId::setId(std::string id)
     21        void AnswerId::setId(const std::string& id)
    2222        {
    2323                this->id_ = id;
    2424        }
    2525       
    26         std::string AnswerId::getId()
     26        const std::string& AnswerId::getId() const
    2727        {
    2828                return this->id_;
  • code/branches/Dialog_HS17/src/modules/dialog/AnswerId.h

    r11611 r11644  
    1616                        virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
    1717
    18             void setId(std::string Id);
    19             std::string getId();
     18            void setId(const std::string& Id);  //allows to set Id, only use in xmlPort for initializing AnswerIds in lvl files
     19            const std::string& getId() const;   //allows to get Id, used in xmlPort
    2020
    2121                private:
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.cc

    r11642 r11644  
    3535    }
    3636
    37         void Dialog::setName(std::string name)
     37        void Dialog::setName(const std::string& name)
    3838        {
    3939                this->name_ = name;
    4040        }
    4141
    42         std::string Dialog::getName()
     42        const std::string& Dialog::getName() const
    4343        {
    4444                return this->name_;
    4545        }
    4646
    47         void Dialog::setCurrentQuestionId(std::string questionId)
     47        void Dialog::setCurrentQuestionId(const std::string& questionId)
    4848        {
    4949                this->currentQuestionId_ = questionId;
    5050        }
    5151
    52         std::string Dialog::getCurrentQuestionId()
     52        const std::string& Dialog::getCurrentQuestionId() const
    5353        {
    5454                return this->currentQuestionId_;
     
    6161        }
    6262
     63        const Question* Dialog::getQuestion() const // returned nichts
     64        {
     65                return nullptr;
     66        }
     67
    6368        void Dialog::addAnswer(Answer* answer) //fuegt Answer der Map hinzu
    6469        {
     
    6671        }
    6772
    68         Question* Dialog::getQuestion(unsigned int index) const // returned nichts
     73        const Answer* Dialog::getAnswer(unsigned int index) const       //returned sting der Antwort zur Id.
    6974        {
    7075                return nullptr;
    71                 // Question question = (questions_.find(this->currentQuestionId_))->second;
    72                 // return question.getQuestion();
    7376        }
    7477
    75         Answer* Dialog::getAnswer(unsigned int index) const     //returned sting der Antwort zur Id.
    76         {
    77                 return nullptr;
    78                 // return (this->answers_.find(answerId))->second.getAnswer();
    79         }
    8078
    81         std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
     79        const std::vector<std::string>* Dialog::getAnswerIds() // returned vector mit allen momentanen AntwortenIds
    8280        {
    8381               
    8482                Question* question = (this->questions_.find(this->currentQuestionId_))->second;
    85                 std::vector<std::string>* answers = question->getAnswerIds();
     83                const std::vector<std::string>* answers = question->getAnswerIds();
    8684                return answers;
    8785               
     
    103101    }
    104102
    105     void Dialog::update(std::string givenAnswer)
     103    void Dialog::update(const std::string& givenAnswerId)
    106104    {
    107         Answer* answer = (answers_.find(givenAnswer))->second;
     105        Answer* answer = (answers_.find(givenAnswerId))->second;
    108106        this->currentQuestionId_ = answer->getNextQuestion();
    109107    }
    110108
    111     bool Dialog::ending() //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
     109    bool Dialog::ending(const std::string& givenAnswerId)
    112110    {
    113         bool end = false;
    114         if ((this->questions_.find(this->currentQuestionId_)->second)->getAnswerIds()->empty()){
    115                 end = true;
    116         }       
    117         return end;
     111        return !this->questions_.count(this->answers_.find(givenAnswerId)->second->getNextQuestion());
    118112    }
    119113
    120         std::string Dialog::getQuestionString()
     114        const std::string& Dialog::getQuestionString()
    121115        {
    122116                return this->questions_.find(this->currentQuestionId_)->second->getQuestion();
    123117        }
    124118
    125         std::string Dialog::getAnswerString(std::string answerId)
     119        const std::string& Dialog::getAnswerString(std::string answerId)
    126120        {
    127121                return this->answers_.find(answerId)->second->getAnswer();
  • code/branches/Dialog_HS17/src/modules/dialog/Dialog.h

    r11642 r11644  
    2424                        virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode);
    2525
    26                         void setName(std::string name);
    27                         std::string getName();
     26                        void setName(const std::string& name);  //xmlPort-Funktion, setzt Namen
     27                        const std::string& getName() const;     //xmlPort-Funktion, returnt Namen
    2828
    29                         void setCurrentQuestionId(std::string questionId);
    30                         std::string getCurrentQuestionId();
     29                        void setCurrentQuestionId(const std::string& questionId);       //xmlPort-Funktion, setzt string Id der momentanen Frage
     30                        const std::string& getCurrentQuestionId() const;        //xmlPort-Funktion, gibt Id der momentanen Frage
    3131
    32                         void addQuestion(Question* question); //fuegt Question der Map hinzu
    33                         void addAnswer(Answer* answer); //fuegt Answer der Map hinzu
     32                        void addQuestion(Question* question); //xmlPort-Funktion, fuegt Question der Map hinzu
     33                        const Question* getQuestion() const; //xmlPort-Funktion, returnt nullptr
    3434
    35                         Question* getQuestion(unsigned int index) const; // // benoetigt fuer xmlPort
    36                         Answer* getAnswer(unsigned int index) const; // benoetigt fuer xmlPort
    37                         std::vector<std::string>* getAnswerIds();       // returned vector mit allen momentanen AntwortenIds
     35                        void addAnswer(Answer* answer); //xmlPort-Funktion, fuegt Answer der Map hinzu
     36                        const Answer* getAnswer(unsigned int index) const; //xmlPort-Funktion, returnt nullptr
    3837
    39                         bool execute(bool bTriggered, BaseObject* trigger);
    4038
    41                         void update(std::string givenAnswer);
     39                        const std::vector<std::string>* getAnswerIds();         // returned Pointer auf Vector mit allen momentanen AntwortenIds
    4240
    43                         bool ending(); //retruned true wenn die Id der Antwort end ist oder keine Antworten auf die frage eingetragen sind
     41                        bool execute(bool bTriggered, BaseObject* trigger); // funktion die aufgerufen wird wenn der im xml verbundene Trigger aktiviert wird
    4442
    45                         std::string getQuestionString(); //gibt string der momentanen Frage
    46                         std::string getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
     43                        void update(const std::string& givenAnswerId);  //setzt die naechste Frage entsprechend der gegebenen antwortId
     44
     45                        bool ending(const std::string& givenAnswerId); //ist true falls fuer die gegebene AntwortId keine Frage zur FragenId der Antwort existiert
     46
     47                        const std::string& getQuestionString(); //gibt string der momentanen Frage
     48                        const std::string& getAnswerString(std::string answerId); //gibt string der zur Id passenden Frage
    4749
    4850                private:
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.cc

    r11642 r11644  
    2929    int DialogManager::getSize()
    3030    {   
    31         return 2; //return this->answerIds_->size();
     31        return this->answerIds_->size();
    3232    }
    3333
     
    4242    }
    4343
    44     bool DialogManager::endtest()
    45     {
    46         return this->currentTalk_->ending();
     44    bool DialogManager::endtest(int index)
     45    {   
     46        if(this->answerIds_->empty())
     47        {
     48            return true;
     49        }
     50        else
     51        {
     52            return this->currentTalk_->ending(this->answerIds_->at(index));
     53        }
     54
    4755    }
    4856
  • code/branches/Dialog_HS17/src/modules/dialog/DialogManager.h

    r11642 r11644  
    2222        DialogManager();
    2323       
    24 
     24        //gibt lua den pointer auf den Manager
    2525        static DialogManager& getInstance() { return Singleton<DialogManager>::getInstance(); } //tolua_export
    2626
     27        //setzt den momentanen Dialog auf den uebergebenen, wird vom Dialog verwendet um bei Trigger event sich selbst zu setzen
    2728        void setDialog(Dialog* dialog);
    2829
    29         //from here on luafunctionality is declared
     30        //von hier an sind lua funktionalitaeten definiert
    3031
     32        //gibt den string der momentanen Frage des Dialogs
    3133        std::string getQuestion(); //tolua_export
     34
     35        //gibt die laenge des Antwort-arrays der momentanen zuruek, 0 falls es leer ist
    3236        int getSize(); //tolua_export
     37
     38        //gibt den sting zu einer Frage im antwortarray der momentanen Frage
    3339        std::string getAnswer(int index); //tolua_export
     40
     41        //gibt den Namen der Person mit der man spricht
    3442        std::string getPerson(); //tolua_export
    35         bool endtest(); //tolua_export
     43
     44        //testet ob der dialog weiter geht, true wenn es keine weitere Frage nach der Antwort kommt oder keine Antwort zur Frage existiert
     45        bool endtest(int index); //tolua_export
     46
     47        //updated den Dialog so dass er auf die Antwort die im Antwortvector am index steht reagiert
    3648        void update(int index); //tolua_export
    3749
     
    4052
    4153    Dialog* currentTalk_;
    42     std::vector<std::string>* answerIds_;
     54    const std::vector<std::string>* answerIds_;
    4355
    4456    };//tolua_export
  • code/branches/Dialog_HS17/src/modules/dialog/Question.cc

    r11642 r11644  
    2222        }
    2323
    24         void Question::setQuestionId(std::string Id)
     24        void Question::setQuestionId(const std::string& Id)
    2525        {
    2626                this->questionId_ = Id;
    2727        }
    2828
    29         std::string Question::getQuestionId()
     29        const std::string& Question::getQuestionId() const
    3030        {
    3131                return this->questionId_;
    3232        }
    3333
    34         void Question::setQuestion(std::string question)
     34        void Question::setQuestion(const std::string& question)
    3535        {
    3636                this->question_ = question;
    3737        }
    3838
    39         std::string Question::getQuestion()
     39        const std::string& Question::getQuestion() const
    4040        {
    4141                return this->question_;
     
    4747        }
    4848
    49         AnswerId* Question::getAnswerId(unsigned int index) const
     49        const AnswerId* Question::getAnswerId() const
    5050        {
    5151                return nullptr;
    5252        }
    5353
    54         std::vector<std::string>* Question::getAnswerIds()
     54        const std::vector<std::string>* Question::getAnswerIds()
    5555        {
    5656                return &(this->answerIds_);
  • code/branches/Dialog_HS17/src/modules/dialog/Question.h

    r11642 r11644  
    2020                        virtual void XMLPort(Element& xmelement, XMLPort::Mode mode);
    2121
    22                         void setQuestionId(std::string Id);
    23                         std::string getQuestionId();
     22                        void setQuestionId(const std::string& Id);      //xmlPort-Funktion, setzt Id
     23                        const std::string& getQuestionId() const;       //xmlPort-Funktion, gibt Id string zuruek
    2424
    25                         void setQuestion(std::string question);
    26                         std::string getQuestion();
     25                        void setQuestion(const std::string& question);  //xmlPort-Funktion, setzt Fragen string
     26                        const std::string& getQuestion() const; //xmlPort-Funktion, gibt Fragen string
    2727
    28                         void addAnswerId(AnswerId* answerId); //leer lassen um Dialog zu beenden
    29                         AnswerId* getAnswerId(unsigned int index) const;
     28                        void addAnswerId(AnswerId* answerId);   //xmlPort-Funktion, nimmt AnswerIds von entsprechenden Objekten und fuegt sie in List ein.
     29                        const AnswerId* getAnswerId() const;    //xmlPort-Funktion, gibt nichts zuruek
    3030
    31                        
    32                         //braucht es getAnswerId oder reicht es andere funktion anzugeben,
    33                         // die sowieso gebraucht wird?
    34 
    35                         std::vector<std::string>* getAnswerIds(); //returnt vektor mit allen Ids
     31                        const std::vector<std::string>* getAnswerIds(); //returnt Pointer auf Vektor mit allen Ids
    3632
    3733
Note: See TracChangeset for help on using the changeset viewer.