Peoplemon  0.1.0
Peoplemon 3 game source documentation
Trainer.cpp
Go to the documentation of this file.
2 
3 #include <Core/Properties.hpp>
4 
5 namespace core
6 {
7 namespace component
8 {
9 namespace
10 {
11 std::string convPath(const std::string& src) {
12  return bl::util::FileUtil::joinPath(Properties::ConversationPath(), src);
13 }
14 } // namespace
15 
17 : sourceFile(std::move(data.sourceFile))
18 , _name(std::move(data.name))
19 , loseDialog(std::move(data.lostBattleLine))
20 , visionRange(data.visionRange)
21 , peoplemon(std::move(data.peoplemon))
22 , _items(std::move(data.items))
23 , payout(data.payout)
24 , beat(false) {
25  if (!beforeBattle.load(convPath(data.prebattleConversation))) {
26  BL_LOG_ERROR << "Failed to load trainer before battle conversation: "
27  << data.prebattleConversation;
28 #ifdef PEOPLEMON_DEBUG
29  beforeBattle = file::Conversation::makeLoadError(data.prebattleConversation);
30 #endif
31  }
32  if (!afterBattle.load(convPath(data.postBattleConversation))) {
33  BL_LOG_ERROR << "Failed to load trainer after battle conversation: "
34  << data.postBattleConversation;
35 #ifdef PEOPLEMON_DEBUG
36  afterBattle = file::Conversation::makeLoadError(data.postBattleConversation);
37 #endif
38  }
39 }
40 
41 const std::string& Trainer::file() const { return sourceFile; }
42 
43 const std::string& Trainer::name() const { return _name; }
44 
45 const file::Conversation& Trainer::beforeBattleConversation() const { return beforeBattle; }
46 
47 const file::Conversation& Trainer::afterBattleConversation() const { return afterBattle; }
48 
49 const std::string& Trainer::loseBattleDialog() const { return loseDialog; }
50 
51 std::uint8_t Trainer::range() const { return visionRange; }
52 
53 const std::vector<pplmn::OwnedPeoplemon>& Trainer::team() const { return peoplemon; }
54 
55 const std::vector<item::Id>& Trainer::items() const { return _items; }
56 
57 bool Trainer::defeated() const { return beat; }
58 
59 void Trainer::setDefeated() { beat = true; }
60 
61 std::uint8_t Trainer::basePayout() const { return payout; }
62 
63 } // namespace component
64 } // namespace core
Core classes and functionality for both the editor and game.
Trainer(file::Trainer &&trainer)
Construct a new Trainer component.
Definition: Trainer.cpp:16
const std::string & loseBattleDialog() const
Dialog line said in battle screen when battle is lost.
Definition: Trainer.cpp:49
const std::string & name() const
The name of the NPC.
Definition: Trainer.cpp:43
bool defeated() const
Returns whether or not this trainer was defeated.
Definition: Trainer.cpp:57
const file::Conversation & beforeBattleConversation() const
The conversation before battle is entered.
Definition: Trainer.cpp:45
std::uint8_t range() const
Returns how far the trainer can see in tiles.
Definition: Trainer.cpp:51
const std::vector< item::Id > & items() const
Returns the items the trainer has.
Definition: Trainer.cpp:55
const std::string & file() const
Returns the file the trainer was spawned from.
Definition: Trainer.cpp:41
const file::Conversation & afterBattleConversation() const
The conversation used after battle if interacted again.
Definition: Trainer.cpp:47
const std::vector< pplmn::OwnedPeoplemon > & team() const
Returns the team of peoplemon the trainer has.
Definition: Trainer.cpp:53
void setDefeated()
Marks this trainer as defeated.
Definition: Trainer.cpp:59
std::uint8_t basePayout() const
Returns the base payout of the trainer.
Definition: Trainer.cpp:61
Stores a conversation that an NPC or trainer can have with the player.
bool load(const std::string &file)
Loads the conversation from the given file.
static Conversation makeLoadError(const std::string &filename)
Helper function to create a conversation that reports an error if in debug mode.
Static data for trainers in the world.
Definition: Trainer.hpp:20
static const std::string & ConversationPath()
Definition: Properties.cpp:539