]> jfr.im git - irc/gameservirc.git/blobdiff - gameserv/do_attack.cpp
Refactored playerGO a bit
[irc/gameservirc.git] / gameserv / do_attack.cpp
index 1f6b9c6736ef92304a93d4523fa7b2f3c7ad4700..e123d276bbcffa7f8c3b87ef54b186c27d9087fa 100644 (file)
@@ -1,5 +1,6 @@
 #include "aClient.h"
 #include "extern.h"
+#include "options.h"
 #include "flags.h"
 #include "level.h"
 #include "player.h"
@@ -14,7 +15,7 @@ void do_attack(char *u)
   
   if (!(ni = find(u)))
     {
-      notice(s_GameServ, u, "Fatal error in do_attack. Contact a(n) %S admin for help.");
+      notice(s_GameServ, u, "Fatal error in do_attack. Contact a(n) <S admin for help.");
       return;
     }
   else if (isIgnore(ni))
@@ -36,11 +37,8 @@ void do_attack(char *u)
     }
   else
     {
-      if (!ni->stats->getMaster()) // This is not a master fight
-               fight = ni->stats->getMonster();       // Monster      Could be NULL
-      else                    // This IS a master fight
-               fight = ni->stats->getMaster();      // Master       Could be NULL
-         
+
+         fight = ni->stats->getMonster();       // Monster      Could be NULL
       battle = ni->stats->getBattle();             // Player       Could be NULL
          
       // One has to be !NULL based on the previous else if
@@ -113,7 +111,7 @@ void do_attack(char *u)
                                          " %s is now watching over the Dragon's lair!",
                                          ni->stats->getName().c_str(), ni->stats->getName().c_str(),
                                          ni->stats->getMonster()->name.c_str(), ni->stats->getName().c_str());
-                         dragon.name = "DRAGON-" + ni->stats->getName();
+                         dragon.name = "Dragon " + ni->stats->getName();
                          dragon.weapon = "Breath of Fire";
                          dragon.strength = ni->stats->getStrength();
                          dragon.defense = ni->stats->getDefense();
@@ -122,6 +120,8 @@ void do_attack(char *u)
                          save_dragon();
                          clearDragonFight(ni->stats);
                          reset(ni->stats);
+                         ni->stats->delMonster();
+                         return;
                        }
                  
                  ni->stats->addExp(fight->exp);
@@ -211,13 +211,18 @@ void do_attack(char *u)
     {
       if (is_playing(battle))
                {
-                 if (!isYourTurn(ni->stats))
+                 if (!isYourTurn(ni->stats) && isYourTurn(battle->stats))
                        {
                          notice(s_GameServ, u, "Please wait until %s decides what to do!",
                                         battle->stats->getName().c_str());
                          return;
                        }
-                 if (hit > 0)
+                 else if (!isYourTurn(ni->stats) && !isYourTurn(battle->stats))
+                       {
+                         // If somehow the player vs. player fight hangs, give the turn to the first attacker
+                         setYourTurn(ni->stats);
+                       }
+                if (hit > 0)
                        {
                          notice(s_GameServ, u, "You attack \1f%s\1f for \ 2%d\ 2 points!", battle->stats->getName().c_str(), hit);
                          
@@ -236,7 +241,7 @@ void do_attack(char *u)
                          notice(s_GameServ, u, "You have killed \ 2%s\ 2!", battle->stats->getName().c_str());
                          notice(s_GameServ, u, "You recieve \ 2%d\ 2 experience and \ 2%ld\ 2 gold!",
                                         (long int)(battle->stats->getExp() * .10), battle->stats->getGold());
-                         addNews(todaysnews, "%s has defeated %s, leaving %s in a pool of blood", ni->stats->getName().c_str(), battle->stats->getName().c_str()); /* DrLnet - Modified by kain for news instead of just a message */ 
+                         addNews(todaysnews, "%s has defeated %s, leaving %s in a pool of blood", ni->stats->getName().c_str(), battle->stats->getName().c_str(), battle->stats->getName().c_str()); /* DrLnet - Modified by kain for news instead of just a message */ 
                          notice(s_GameServ, battle->getNick(), "You have been killed by \ 2%s\ 2!",
                                         ni->stats->getName().c_str());
                          battle->stats->setHP(0);
@@ -262,6 +267,7 @@ void do_attack(char *u)
                        {
                          if (hit > 0)
                                battle->stats->subtractHP(hit);
+
                          clearYourTurn(ni->stats);
                          setYourTurn(battle->stats);
                          display_players(battle);