-
Notifications
You must be signed in to change notification settings - Fork 0
/
TileOccupant.cpp
873 lines (727 loc) · 21.1 KB
/
TileOccupant.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
/*
FileName: TileOccupant.cpp
Author: Drew McKinney
Group: 9
Description:
TileOccupant and derived classes implementation
*/
#include "TileOccupant.h"
#include <cmath>
using namespace std;
int charToChoiceIndex(char c) {
if (c >= '0' && c <= '9')
return c - '0';
if (c >= 'a' && c <= 'z')
return c - 'a' + 10;
if (c >= 'A' && c <= 'Z')
return c - 'A' + 36;
return -1; /* if ( (c < '0' && c > '9') || (c < 'a' && c > 'z') ||
(c < 'A' && c > 'Z') )
*/
}
char choiceIndexToChar(int ind) {
char i = static_cast<char>(ind);
if (i >= 0 && i < 10)
return '0' + i;
if (i >= 10 && i < 36)
return 'a' + i;
if (i >= 36 && i < 62)
return 'A' + i;
return -1; // if (i < 0 || i >= 62)
}
/*
TileOccupant abstract base class
*/
TileOccupant::TileOccupant() {}
TileOccupant::~TileOccupant() {}
/* Interact is a virtual function. For all classes that override it, returning
* "true" indicates a valid "promptResponse." If interact returns "false", then
* the caller must prompt the user for a new reponse and call interact again.
*/
bool TileOccupant::interact(char promptResponse, Hero &theHero) {
// This serves as a default case: only allow response of y/n
if (promptResponse != 'y' &&
(promptResponse != 'Y' &&
(promptResponse != 'n' && promptResponse != 'N'))) {
return false;
}
return true;
}
/*
/////////////////////////////////////////////////////////////////
Treasure class derived from TileOccupant
/////////////////////////////////////////////////////////////////
*/
Treasure::Treasure() : worth_(0) {}
Treasure::Treasure(int worth) : worth_(worth) {}
bool Treasure::permanent() { return false; }
/*
Function: color
Description: return appropriate color for derived class,
black? Not sure
Arguments: none
Return: int - color for this class, treasure
*/
int Treasure::color() { return COLOR_BLACK; }
/*
Function: marker
Description: return appropriate marker for derived class
Arguments: none
Return: char - marker for this class, treasure
*/
char Treasure::marker() { return '$'; }
/*
Function: getDetails
Description: returns data in the form of strings to pass to ui
Arguments:
Return: vector<string> - object data to pass to ui
*/
vector<string> Treasure::getDetails() {
vector<string> data;
data.push_back("");
data.push_back(to_string(worth_));
data.push_back("Treasure");
data.push_back("Worth");
return data;
}
/*
Function: promptMsg
Description: returns message specific to this class, treasure
Arguments: none
Return: string - message to display to player
*/
string Treasure::promptMsg(Hero &theHero) {
string msg = string("A treasure chest has been found ") +
"containing: " + to_string(worth_) + " Whiffles!";
return msg;
}
/*
Function: interact
Description: occupant interacts with player according to
promptResponse
Arguments: char - player response to prompt
Hero& - player
Return: none
*/
bool Treasure::interact(char promptResponse, Hero &theHero) {
theHero.addWhiffles(worth_);
// Treasure does not use promptResponse, so the value is always valid.
return true;
}
string Treasure::typeStr() const { return "Treasure"; }
string Treasure::dataAsCsv() const { return to_string(worth_); }
/*
/////////////////////////////////////////////////////////////////
Ship class derived from TileOccupant
/////////////////////////////////////////////////////////////////
*/
Ship::Ship() : whiffleCost_(0), bought_(false), toRemove_(false) {}
Ship::Ship(int whiffleCost, bool bought)
: whiffleCost_(whiffleCost), bought_(bought), toRemove_(false) {}
/*
Function: permanent
Description: returns if occupant is permanent or not?
Arguments: none
Return: none
*/
bool Ship::permanent() { return !toRemove_; }
/*
Function: color
Description: return appropriate color for derived class
Arguments: none
Return: int - color for this class, ship
*/
int Ship::color() { return COLOR_BLACK; }
/*
Function: marker
Description: return appropriate marker for derived class
Arguments: none
Return: char - marker for this class, ship
*/
char Ship::marker() { return 'S'; }
/*
Function: getDetails
Description: returns data in the form of strings to pass to ui
Arguments:
Return: vector<string> - object data to pass to ui
*/
vector<string> Ship::getDetails() {
vector<string> data;
data.push_back("");
data.push_back(to_string(whiffleCost_));
if (bought_)
data.push_back("True");
else
data.push_back("False");
data.push_back("Ship");
data.push_back("Price");
data.push_back("Bought");
return data;
}
/*
Function: promptMsg
Description: returns message specific to this class, treasure
Arguments: none
Return: string - message to display to player
*/
string Ship::promptMsg(Hero &theHero) {
if (theHero.hasShip()) {
return string("You can't board this ship since you are already") +
"riding one! ";
}
if (bought_) {
return string("Welcome back! Sail in ship? (Y/N)");
}
string msg = "A ship has been found! ";
if (theHero.whiffles() < whiffleCost_) {
msg = msg + "But you don't have enough Whiffles!" + "Sorry!";
} else {
msg = msg + "Purchase? (Y/N)"; // ship for "
// + to_string(whiffleCost_)
// + " Whiffles?(Y/N):";
}
return msg;
}
/*
Function: interact
Description: occupant interacts with player according to
promptResponse
Arguments: char - player response to prompt
Hero& - player
Return: none
*/
bool Ship::interact(char promptResponse, Hero &theHero) {
/* If the hero is already riding a ship, or cannot afford the ship and
* the ship is new ...
*/
if ((theHero.whiffles() < whiffleCost_ && !bought_) || theHero.hasShip()) {
// ... do nothing. Any input is valid, so return true.
return true;
}
// The user chose to purchase or use the ship
if (promptResponse == 'y' || promptResponse == 'Y') {
// Price is paid only once.
if (!bought_) {
theHero.addWhiffles(-whiffleCost_);
bought_ = true;
}
toRemove_ = true;
theHero.setHasShip(true);
return true;
}
// Verify that the user chose to not purchase the ship.
return TileOccupant::interact(promptResponse, theHero);
}
string Ship::typeStr() const { return "Ship"; }
string Ship::dataAsCsv() const { return to_string(whiffleCost_); }
/*
/////////////////////////////////////////////////////////////////
Tool class derived from TileOccupant
/////////////////////////////////////////////////////////////////
*/
Tool::Tool()
: name_(0), whiffleCost_(0), rating_(0), forObstacles(0), bought_(false) {}
Tool::Tool(const Tool &toCopy)
: name_(toCopy.name_), whiffleCost_(toCopy.whiffleCost_),
rating_(toCopy.rating_), forObstacles(toCopy.forObstacles),
bought_(toCopy.bought_) {}
Tool::Tool(string name, int whiffleCost, int rating, vector<string> usableOn)
: name_(name), whiffleCost_(whiffleCost), rating_(rating),
forObstacles(usableOn), bought_(false) {}
/*
Function: usableOn
Description: determines if tool is usable on given obstacle
Arguments: Obstacle& - obstacle to check against
Return: bool - true if usable on obstacle,
false if not
*/
bool Tool::usableOn(const Obstacle &onObstacle) const {
// vector<string>::iterator i;
for (auto i = forObstacles.cbegin(); i < forObstacles.cend(); i++) {
if (*i == onObstacle.name())
return true;
}
return false;
}
/*
Function: rating
Description: returns rating of tool
Arguments: none
Return: int - rating of tool
*/
int Tool::rating() { return rating_; }
/*
Function: permanent
Description: determines if tool is permanent
Arguments: none
Return: bool - true if permanent,
false if not
*/
bool Tool::permanent() { return !bought_; }
/*
Function: color
Description: gets color of occupant depending on derived class
Arguments: none
Return: int - color value for ncurses
*/
int Tool::color() { return COLOR_BLACK; }
/*
Function: marker
Description: gets marker for occupant
Arguments: none
Return: char - marker for specific occupant class
*/
char Tool::marker() { return 'T'; }
/*
Function: getDetails
Description: returns data in the form of strings to pass to ui
Arguments:
Return: vector<string> - object data to pass to ui
*/
vector<string> Tool::getDetails() {
vector<string> data;
// push name of tool to vector
data.push_back(name_);
// push all strings from forObstacles
string obstacleList;
for (vector<string>::iterator it = forObstacles.begin();
it != forObstacles.end(); ++it) {
obstacleList = obstacleList + *it;
}
data.push_back(obstacleList);
// push values for cost and rating
data.push_back(to_string(whiffleCost_));
data.push_back(to_string(rating_));
// push labels
data.push_back("Tool");
data.push_back("Obstacle");
data.push_back("Price");
data.push_back("Rating");
return data;
}
/*
Function: promptMsg
Description: gets correct prompt for player for class
Arguments: Hero& - player
Return: string - message to prompt player
*/
string Tool::promptMsg(Hero &theHero) {
string msg;
msg = "Tool found! ";
if (theHero.whiffles() >= whiffleCost_) {
/* msg = msg + name_ + "\n";
// get all obstacles tool works for
for (auto it = forObstacles.begin()
; it != forObstacles.end(); ++it)
{
msg = msg + (*it) + " : Obstacle\n";
}
// get tool cost and rating
msg = msg + to_string(whiffleCost_) + " : Cost\n";
msg = msg + "X" + to_string(rating_)
+ " : Rating\n"; */
msg = msg + "Would you like to purchase? (Y/N)";
} else {
msg = msg + "But you don't have enough Whiffles! " + "Sorry!";
}
return msg;
}
/*
Function: interact
Description: interacts with player according to player response
Arguments: char - player response to prompt
Hero& - player
Return: none
*/
bool Tool::interact(char promptResponse, Hero &theHero) {
if (theHero.whiffles() < whiffleCost_) {
return true;
}
if (!TileOccupant::interact(promptResponse, theHero)) {
return false;
}
switch (promptResponse) {
case 'y':
case 'Y':
bought_ = true;
theHero.addWhiffles(-whiffleCost_);
theHero.addInventory(new Tool(*this));
break;
default:
return true;
}
return true;
}
string Tool::typeStr() const { return "Tool"; }
string Tool::dataAsCsv() const {
string ret = name_ + "," + to_string(whiffleCost_) + "," +
to_string(rating_) + "," + to_string(forObstacles.size());
for (unsigned int i = 0; i < forObstacles.size(); ++i) {
ret += "," + forObstacles.at(i);
}
return ret;
}
/*
/////////////////////////////////////////////////////////////////
Food class derived from TileOccupant
/////////////////////////////////////////////////////////////////
*/
Food::Food()
: name_(0), whiffleCost_(0), energyProvided_(0), consumed_(false) {}
Food::Food(string name, int whiffleCost, int energyProvided)
: name_(name), whiffleCost_(whiffleCost), energyProvided_(energyProvided),
consumed_(false) {}
/*
Function: permanent
Description: determines if occupant is permanent or not
Arguments: none
Return: bool - true if perm, false if not
*/
bool Food::permanent() { return !consumed_; }
/*
Function: color
Description: gets occupant marker color
Arguments: none
Return: int - marker color
*/
int Food::color() { return COLOR_BLACK; }
/*
Function: marker
Description: gets occupant marker
Arguments: none
Return: char - marker
*/
char Food::marker() { return 'F'; }
/*
Function: getDetails
Description: gets data to send to ui
Arguments: none
Return: vector<string> - data strings for ui
*/
vector<string> Food::getDetails() {
vector<string> data;
data.push_back(name_);
data.push_back(to_string(whiffleCost_));
data.push_back(to_string(energyProvided_));
// labels
data.push_back("Food");
data.push_back("Price");
data.push_back("Energy");
return data;
}
/*
Function: promptMsg
Description: gets message to display to user
Arguments: Hero& - hero to prompt
Return: string - message to display
*/
string Food::promptMsg(Hero &theHero) {
string msg;
msg = string("You found a delicious ") + name_ + "!";
if (theHero.whiffles() >= whiffleCost_) {
msg = msg + " Would you like to purchase (Y/N)?\n";
} else {
msg = msg + " But you don't have enough Whiffles! " + "Sorry!";
}
return msg;
}
/*
Function: interact
Description: interacts with user according to response key
Arguments: char - prompt response key
, Hero& - hero to interact with
Return: string - message to display
*/
bool Food::interact(char promptResponse, Hero &theHero) {
if (theHero.whiffles() < whiffleCost_) {
return true;
}
if (!TileOccupant::interact(promptResponse, theHero)) {
return false;
}
switch (promptResponse) {
case 'y':
case 'Y':
consumed_ = true;
theHero.addWhiffles(-whiffleCost_);
theHero.addEnergy(energyProvided_);
break;
default:
return true;
}
return true;
}
string Food::typeStr() const { return "Food"; }
string Food::dataAsCsv() const {
return name_ + "," + to_string(whiffleCost_) + "," +
to_string(energyProvided_);
}
/*
/////////////////////////////////////////////////////////////////
Binoculars class derived from TileOccupant
/////////////////////////////////////////////////////////////////
*/
Binoculars::Binoculars() : whiffleCost_(0), bought_(false) {}
Binoculars::Binoculars(int whiffleCost)
: whiffleCost_(whiffleCost), bought_(false) {}
/*
Function: permanent
Description: determines if occupant is permanent or not
Arguments: none
Return: bool - true if perm, false if not
*/
bool Binoculars::permanent() { return !bought_; }
/*
Function: color
Description: gets occupant marker color
Arguments: none
Return: int - marker color
*/
int Binoculars::color() { return COLOR_BLACK; }
/*
Function: marker
Description: gets occupant marker
Arguments: none
Return: char - marker
*/
char Binoculars::marker() { return 'B'; }
/*
Function: getDetails
Description: gets data to send to ui
Arguments: none
Return: vector<string> - data strings for ui
*/
std::vector<std::string> Binoculars::getDetails() {
return vector<string>{"", to_string(whiffleCost_), "Binoculars", "Price"};
}
/*
Function: promptMsg
Description: gets message to display to user
Arguments: Hero& - hero to prompt
Return: string - message to display
*/
string Binoculars::promptMsg(Hero &theHero) {
string msg;
msg = "Binoculars found!";
if (theHero.whiffles() >= whiffleCost_) {
msg = msg + " Buy Binoculars and double your " + "vision for " +
to_string(whiffleCost_) + " Whiffles? (Y/N):";
} else {
msg = msg + " But you don't have enough Whiffles! " + "Sorry!";
}
return msg;
}
/*
Function: interact
Description: interacts with user according to response key
Arguments: char - prompt response key
, Hero& - hero to interact with
Return: string - message to display
*/
bool Binoculars::interact(char promptResponse, Hero &theHero) {
if (theHero.whiffles() < whiffleCost_) {
return true;
}
if (!TileOccupant::interact(promptResponse, theHero)) {
return false;
}
switch (promptResponse) {
case 'y':
case 'Y':
bought_ = true;
theHero.addWhiffles(-whiffleCost_);
theHero.setHasBinoculars(true);
break;
default:
return true;
}
return true;
}
string Binoculars::typeStr() const { return "Binoculars"; }
string Binoculars::dataAsCsv() const { return to_string(whiffleCost_); }
/*
/////////////////////////////////////////////////////////////////
clue class derived from TileOccupant
/////////////////////////////////////////////////////////////////
*/
Clue::Clue() : msg_(0) {}
Clue::Clue(string msg) : msg_(msg) {}
/*
Function: permanent
Description: determines if occupant is permanent or not
Arguments: none
Return: bool - true if perm, false if not
*/
bool Clue::permanent() { return true; }
/*
Function: color
Description: gets occupant marker color
Arguments: none
Return: int - marker color
*/
int Clue::color() { return COLOR_BLACK; }
/*
Function: marker
Description: gets occupant marker
Arguments: none
Return: char - marker
*/
char Clue::marker() { return '?'; }
/*
Function: getDetails
Description: gets data to send to ui
Arguments: none
Return: vector<string> - data strings for ui
*/
vector<string> Clue::getDetails() {
vector<string> data;
data.push_back("");
// data.push_back(msg_);
data.push_back("Clue");
// data.push_back("Message");*/
return data;
}
/*
Function: promptMsg
Description: gets message to display to user
Arguments: Hero& - hero to prompt
Return: string - message to display
*/
string Clue::promptMsg(Hero &theHero) {
string msg;
msg = "Clue found!\n";
return msg + msg_;
}
/*
Function: interact
Description: interacts with user according to response key
Arguments: char - prompt response key
, Hero& - hero to interact with
Return:
*/
bool Clue::interact(char promptResponse, Hero &theHero) { return true; }
string Clue::typeStr() const { return "Clue"; }
string Clue::dataAsCsv() const { return msg_; }
/*
/////////////////////////////////////////////////////////////////
Diamond class derived from TileOccupant
/////////////////////////////////////////////////////////////////
*/
Diamond::Diamond() {}
/*
Function: permanent
Description: determines if occupant is permanent or not
Arguments: none
Return: bool - true if perm, false if not
*/
bool Diamond::permanent() { return false; }
/*
Function: color
Description: gets occupant marker color
Arguments: none
Return: int - marker color
*/
int Diamond::color() { return COLOR_WHITE; }
/*
Function: marker
Description: gets occupant marker
Arguments: none
Return: char - marker
*/
char Diamond::marker() { return '$'; }
/*
Function: getDetails
Description: gets data to send to ui
Arguments: none
Return: vector<string> - data strings for ui
*/
vector<string> Diamond::getDetails() {
vector<string> data;
data.push_back("");
data.push_back("Royal Diamonds");
return data;
}
/*
Function: promptMsg
Description: gets message to display to user
Arguments: Hero& - hero to prompt
Return: string - message to display
*/
string Diamond::promptMsg(Hero &theHero) {
string msg = "Congratulations! You've found the Royal Diamonds!";
return msg;
}
/*
Function: interact
Description: interacts with user according to response key
Arguments: char - prompt response key
, Hero& - hero to interact with
Return:
*/
bool Diamond::interact(char promptResponse, Hero &theHero) { return true; }
string Diamond::typeStr() const { return "Diamond"; }
string Diamond::dataAsCsv() const { return ""; }
/*
/////////////////////////////////////////////////////////////////
Obstacle class derived from TileOccupant
/////////////////////////////////////////////////////////////////
*/
Obstacle::Obstacle(std::string name, int energyCost)
: name_(name), energyCost_(energyCost) {}
std::string Obstacle::name() const { return name_; }
std::string Obstacle::promptMsg(Hero &theHero) {
/* The proper operator overloads and implicit constructors are available in
* <string> for the below statement to compile.
*/
vector<Tool *> usableTools = theHero.getUsableTools(*this);
if (usableTools.size() == 0) {
return string("You destroyed a ") + name_ + " with your bare hands! " +
"(You have no appropriate tools.)";
}
return string("You must remove a ") + name_ + " to continue. Select a tool" +
" or press \"space\" for no tool.";
}
bool Obstacle::interact(char promptResponse, Hero &theHero) {
// Get list of all tools that the user can use to break this obstacle
vector<Tool *> usableTools = theHero.getUsableTools(*this);
// Convert the tool choice to an index in the tool array
int toolInd = charToChoiceIndex(promptResponse);
// All input is valid if the user has no applicable tools.
if (usableTools.size() == 0 || promptResponse == ' ') {
theHero.addEnergy(-energyCost_);
return true;
}
// A tool was chosen. Check if the promptResponse is invalid.
if (toolInd < 0 || toolInd >= static_cast<int>(usableTools.size())) {
return false;
}
// Check if the pointer to the chosen tool is null
Tool *chosenTool = usableTools.at(toolInd);
if (!chosenTool)
throw std::runtime_error("missing tool");
// Cost is reduced by a factor of the rating, rounding up.
energyCost_ = ceil(static_cast<float>(energyCost_) / chosenTool->rating());
theHero.addEnergy(-energyCost_);
// Remove the tool from the Hero's inventory.
theHero.consumeTool(chosenTool);
return true;
/* Like for any other TileOccupant, the caller will remove this Obstacle
* from the map after verifying that it is not permanent. Similarly, caller
* should check whether the hero has died.
*/
}
bool Obstacle::permanent() { return false; }
int Obstacle::color() { return COLOR_BLACK; }
char Obstacle::marker() { return '!'; }
std::vector<std::string> Obstacle::getDetails() {
std::vector<std::string> details;
details.push_back(name_);
details.push_back(std::to_string(energyCost_));
details.push_back("Obstacle");
details.push_back("Energy cost");
return details;
}
string Obstacle::typeStr() const { return "Obstacle"; }
string Obstacle::dataAsCsv() const {
return name_ + "," + to_string(energyCost_);
}