MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / getString

Method getString

plugins/dm.objectives/Component.cpp:9–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7namespace objectives {
8
9std::string Component::getString() {
10 // This will hold our return value
11 std::string sentence;
12
13 int componentId = _type.getId();
14
15 if (isInverted()) {
16 sentence += "do NOT ";
17 }
18
19 SpecifierPtr sp1 = getSpecifier(Specifier::FIRST_SPECIFIER);
20 SpecifierPtr sp2 = getSpecifier(Specifier::SECOND_SPECIFIER);
21
22 if (componentId == ComponentType::COMP_KILL().getId()) {
23 // First add the verb
24 sentence += "kill";
25
26 // Add the Specifier details, if any
27 sentence += (sp1) ? (" " + sp1->getSentence(*this)) : "";
28 }
29 else if (componentId == ComponentType::COMP_KO().getId()) {
30 // First add the verb
31 sentence += "knockout";
32
33 // Add the Specifier details, if any
34 sentence += (sp1) ? (" " + sp1->getSentence(*this)) : "";
35 }
36 else if (componentId == ComponentType::COMP_AI_FIND_ITEM().getId()) {
37 // First add the verb
38 sentence += "let AI find item:";
39
40 // Add the Specifier details, if any
41 sentence += (sp1) ? (" " + sp1->getSentence(*this)) : "";
42 }
43 else if (componentId == ComponentType::COMP_AI_FIND_BODY().getId()) {
44 sentence += "let AI find body:";
45
46 // Add the Specifier details, if any
47 sentence += (sp1) ? (" " + sp1->getSentence(*this)) : "";
48
49 sentence += " (amount: " + getArgument(0) + ")";
50 }
51 else if (componentId == ComponentType::COMP_ALERT().getId()) {
52 sentence += "alert";
53
54 // Add the Specifier details, if any
55 sentence += (sp1) ? (" " + sp1->getSentence(*this)) : "";
56
57 // Add the alert level info
58 sentence += " " + getArgument(0) + " times to a minimum alert level of " + getArgument(1);
59 }
60 else if (componentId == ComponentType::COMP_DESTROY().getId()) {
61 sentence += "destroy";
62
63 // Add the Specifier details, if any
64 sentence += (sp1) ? (" " + sp1->getSentence(*this)) : "";
65 }
66 else if (componentId == ComponentType::COMP_ITEM().getId()) {

Callers 6

runScriptFileMethod · 0.45
runScriptCommandMethod · 0.45
populateComponentsMethod · 0.45
updateComponentsMethod · 0.45
handleTypeChangeMethod · 0.45
initialiseModuleMethod · 0.45

Calls 9

to_upper_copyFunction · 0.85
replace_allFunction · 0.85
lengthMethod · 0.80
to_stringFunction · 0.50
getIdMethod · 0.45
getSentenceMethod · 0.45
emptyMethod · 0.45
beginMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected