public void talkToPlayer(PlayerChar p) {
if(isTrainer()) {
if(canBattle()) {
String speech = this.getSpeech();
if(!speech.equalsIgnoreCase("")) {
TcpProtocolHandler.writeMessage(p.getTcpSession(), new NpcSpeechMessage(speech));
}
setLastBattleTime(System.currentTimeMillis());
p.setBattling(true);
p.setBattleField(new NpcBattleField(DataService.getBattleMechanics(), p, this));
return;
} else {
p.setTalking(false);
return;
}
} else {
/* If this NPC wasn't a trainer, handle other possibilities */
String speech = this.getSpeech();
if(!speech.equalsIgnoreCase("")) {
if(!p.isShopping()) {
//Dont send if player is shopping!
TcpProtocolHandler.writeMessage(p.getTcpSession(), new NpcSpeechMessage(speech));
}
}
/* If this NPC is a sprite selection npc */
if(m_name.equalsIgnoreCase("Spriter")) {
p.setSpriting(true);