magic8ball.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00029 #include "magic8ball.h"
00030
00034 Magic8Ball::Magic8Ball(BotKernel*b)
00035 {
00036 this->author = "eponyme";
00037 this->description = "magic 8 ball game";
00038 this->version = VERSION;
00039 this->name = "magic8ball";
00040 this->bindFunction("8ball",IN_COMMAND_HANDLER,"ball",0,10);
00041
00042 this->answers[0] = "As I see it, yes" ;
00043 this->answers[1] = "Ask again later" ;
00044 this->answers[2] = "Better not tell you now" ;
00045 this->answers[3] = "Cannot predict now" ;
00046 this->answers[4] = "Concentrate and ask again" ;
00047 this->answers[5] = "Don't count on it" ;
00048 this->answers[6] = "It is certain" ;
00049 this->answers[7] = "It is decidedly so" ;
00050 this->answers[8] = "Most likely" ;
00051 this->answers[9] = "My reply is no" ;
00052 this->answers[10] = "My sources say no" ;
00053 this->answers[11] = "Outlook good" ;
00054 this->answers[12] = "Outlook not so good" ;
00055 this->answers[13] = "Reply hazy, try again" ;
00056 this->answers[14] = "Signs point to yes" ;
00057 this->answers[15] = "Very doubtful" ;
00058 this->answers[16] = "Without a doubt" ;
00059 this->answers[17] = "Yes" ;
00060 this->answers[18] = "Yes - definitely" ;
00061 this->answers[19] = "You may rely on it" ;
00062 }
00063
00068 string Magic8Ball::getRandomAnswer() {
00069 return this->answers[Tools::random(0,19)];
00070 }
00071
00072 extern "C"
00073 {
00074 Plugin *contruct_magic8ball(BotKernel*b)
00075 {
00076 return new Magic8Ball(b);
00077 }
00078 void destroy_magic8ball(Plugin*p)
00079 {
00080 delete p;
00081 }
00082 bool ball (Message*m,Plugin*p,BotKernel*b)
00083 {
00084 Magic8Ball* mb = (Magic8Ball*) p;
00085 if (m->isPublic()&&(m->nbParts() >= 5)) {
00086 b->send( IRCProtocol::sendMsg(m->getSource(),mb->getRandomAnswer() ) );
00087 }
00088 return true;
00089 }
00090 }