-
Notifications
You must be signed in to change notification settings - Fork 0
/
InterviewCommand.cpp
42 lines (34 loc) · 1.18 KB
/
InterviewCommand.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#include "InterviewCommand.h"
#include "MasterState.h"
#include "Person.h"
#include "Trait.h"
#include <stdlib.h>
InterviewCommand::InterviewCommand(MasterState *masterState) : CommandFunctor(masterState, "interview", "You're looking at it.") {
}
void InterviewCommand::executeCommand(const char *line) {
while (true) {
Person *toInterview = this->personChoiceMenu("Applicants");
if (toInterview == NULL)
return;
bool learnedAnything = false;
list<Trait *> *believedTraits = toInterview->getBelievedTraits();
for (list<Trait *>::iterator it = believedTraits->begin(); it != believedTraits->end(); ++it) {
Trait *t = *it;
if (rand() % 2 == 0) {
if (t->discoverMore()) {
learnedAnything = true;
char message[100];
sprintf(message, "Learned more about %s %s's %s", toInterview->getFirstName().c_str(), toInterview->getLastName().c_str(), t->getName().c_str());
this->_masterState->addMessage(message);
}
}
}
if (!learnedAnything) {
this->_masterState->addMessage("That was a thoroughly disappointing interview, in which you learned nothing.");
}
this->_masterState->advanceTime(1);
return;
}
}
InterviewCommand::~InterviewCommand() {
}