pouch.cpp \
player.cpp \
script.cpp \
- sockhelp.cpp
+ sockhelp.cpp \
+ toplist.cpp
CONSOLESRCS = $(TSRCS) $(CONSOLEDRIVER)
SRCS = $(TSRCS) $(DRIVER)
X = Finished
C = Cancelled
-* Output player list in an includable PHP file - TDC
-
* Add a top player list - thelizno
* Make GameServ tell the channel when two players are in a duel and who wins - DjSlash
C Put some limits on what players can gain per level - Steve
X Make config file accept hostnames not just ips
+
+X Output player list in an includable PHP file - TDC
+
{
if (hit > 0)
battle->stats->subtractHP(hit);
+
clearYourTurn(ni->stats);
setYourTurn(battle->stats);
display_players(battle);
"sit there!", p->getBattle()->stats->getName().c_str());
logout(p->getBattle());
logout(p->getClient());
+ clearYourTurn(p);
+ clearYourTurn(p->getBattle()->stats);
return;
}
}
battle = NULL;
}
+bool Player::operator <(Player &right)
+{
+ if (getLevel() < right.getLevel())
+ {
+ return true;
+ }
+ else if (getExp() < right.getExp())
+ {
+ return true;
+ }
+ else if (getStrength() < right.getStrength() && getDefense() < right.getDefense())
+ {
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+}
#define PLAYER_H
#include <string>
+#include "script.h"
using namespace std;
long int lastcommand; // timestamp for the last command typed
long int lastlogin; // timestamp for the last login
+ bool operator <(Player &right);
private:
string name; // Player's Name
--- /dev/null
+#include "toplist.h"
+#include "player.h"
+#include <list>
+
+using namespace std;
+
+toplist::toplist()
+{
+ myList.clear();
+ count = 10;
+}
+
+toplist::toplist(int c)
+{
+ myList.clear();
+ count = c;
+}
+
+toplist::~toplist()
+{
+ myList.clear();
+ count = 10;
+}
+
+void toplist::insertPlayer(Player *p)
+{
+ myList.push_front(*p);
+ sort();
+ prune();
+}
+
+void toplist::setCount(int c)
+{
+ count = c;
+}
+
+void toplist::sort()
+{
+ myList.sort();
+}
+
+void toplist::prune()
+{
+ list<Player>::iterator it;
+ it = myList.begin();
+
+ for (int x = 0; it != myList.end(); x++, it++)
+ {
+ if (x > count)
+ {
+ // Delete this player from the top list, because they're over the count
+ myList.erase(it);
+ }
+ }
+}
+
+list<Player>::iterator toplist::top()
+{
+ return myList.begin();
+}
--- /dev/null
+#ifndef TOPLIST_H
+#define TOPLIST_H
+
+#include <list>
+
+using namespace std;
+
+// Forward declaration
+class Player;
+
+class toplist {
+public:
+ // Default Constructor
+ toplist();
+
+ // Constructor with a parameter for the count
+ toplist(int);
+
+ // Destructor
+ ~toplist();
+
+ // Insert the player into the top list if they make it
+ void insertPlayer(Player *);
+
+ // Set how many players should be in the toplist
+ void setCount(int);
+ int getCount() { return count; };
+
+ // Sort the list
+ void sort();
+
+ // Prune the list so it's not larger than the count
+ void prune();
+
+ list<Player>::iterator top();
+
+private:
+
+ // The actual list of players
+ list<Player> myList;
+
+ // The number of players to keep in the list
+ int count;
+};
+#endif