-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #120 from benjamg/feature/npc
Can't really be any more broken, right? Feature/npc
- Loading branch information
Showing
18 changed files
with
374 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <algorithm> | ||
#include <sstream> | ||
|
||
#include "basecamp.h" | ||
|
||
basecamp::basecamp() | ||
: name() | ||
, posx(0), posy(0) | ||
{ | ||
|
||
} | ||
|
||
basecamp::basecamp(std::string const& name_, int const posx_, int const posy_) | ||
: name(name_) | ||
, posx(posx_), posy(posy_) | ||
{ | ||
|
||
} | ||
|
||
std::string basecamp::board_name() const | ||
{ | ||
return name + " Board"; | ||
} | ||
|
||
std::string basecamp::save_data() const | ||
{ | ||
std::stringstream data; | ||
|
||
// TODO: This will lose underscores, is that a problem? | ||
// strip spaces from name | ||
std::string savename = name; | ||
replace(savename.begin(), savename.end(), ' ', '_'); | ||
|
||
data << savename << " " << posx << " " << posy; | ||
return data.str(); | ||
} | ||
|
||
void basecamp::load_data(std::string const& data) | ||
{ | ||
std::stringstream stream(data); | ||
stream >> name >> posx >> posy; | ||
|
||
// add space to name | ||
replace(name.begin(), name.end(), '_', ' '); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef _BASECAMP_H_ | ||
#define _BASECAMP_H_ | ||
|
||
#include <string> | ||
|
||
class basecamp | ||
{ | ||
public: | ||
basecamp(); | ||
basecamp(std::string const& name_, int const posx_, int const posy_); | ||
|
||
inline bool is_valid() const { return !name.empty(); } | ||
inline int board_x() const { return posx; } | ||
inline int board_y() const { return posy; } | ||
inline std::string const& camp_name() const { return name; } | ||
|
||
std::string board_name() const; | ||
|
||
// Save/load | ||
std::string save_data() const; | ||
void load_data(std::string const& data); | ||
|
||
private: | ||
std::string name; | ||
int posx, posy; // location of associated bulletin board | ||
}; | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.