]>
jfr.im git - irc/gameservirc.git/blob - gameserv/do_fight.cpp
12 char *nick
= strtok(NULL
, " ");
16 notice(s_GameServ
, u
, "SYNTAX: /msg <S FIGHT PLAYER");
19 else if (!(ni
= find(u
)))
21 notice(s_GameServ
, u
, "Fatal error. Contact a(n) <S admin. buf: %s", strtok(NULL
, ""));
24 else if (isIgnore(ni
))
27 log("Ignoring %s.", ni
->getNick());
31 else if (!is_playing(ni
))
33 notice(s_GameServ
, u
, "You are not playing!");
39 if (ni
->stats
->getPlayerFights() <= 0)
41 ni
->stats
->setPlayerFights(0); // just to be safe
42 notice(s_GameServ
, u
, "You are out of player fights for the "\
43 "day. You have to wait until tomorrow!");
45 else if (!(battle
= findplayer(nick
)))
47 notice(s_GameServ
, u
, "Player %s not found!", nick
);
49 else if (!isAlive(ni
->stats
))
51 notice(s_GameServ
, u
, "You are dead. Wait until tomorrow to fight others!");
53 else if (!is_playing(battle
->getClient()))
55 notice(s_GameServ
, u
, "You can't attack %s while they aren't playing!", nick
);
58 /* offline fighting not available yet
59 else if (!(fight = finduser(nick)))
61 ni->stats->battle = battle;
63 setYourTurn(ni->stats);
64 clearYourTurn(battle->stats);
66 notice(s_GameServ, u, "You decide to fight %s while they're "\
68 battle->stats->name.c_str());
72 else if (stricmp(ni
->stats
->getName().c_str(), battle
->getName().c_str()) == 0)
74 notice(s_GameServ
, u
, "Are you trying to commit suicide!?");
76 else if (!isAlive(battle
))
78 notice(s_GameServ
, u
, "They are dead. Cannot fight dead players!");
80 else if (player_fight(battle
->getClient()))
82 notice(s_GameServ
, u
, "%s is fighting %s already!", battle
->getName().c_str(), battle
->getBattle()->stats
->getName().c_str());
84 else if (master_fight(battle
->getClient()))
86 notice(s_GameServ
, u
, "%s is fighting their master!", battle
->getName().c_str());
88 else if (is_fighting(battle
->getClient()))
90 notice(s_GameServ
, u
, "%s is fighting %s already!", battle
->getName().c_str(), battle
->getMonster()->name
.c_str());
92 else if (!isAdmin(ni
) && isFairFights() && (ni
->stats
->getStrength()/2 - battle
->getDefense()) > battle
->getHP())
94 notice(s_GameServ
, u
, "Fair fighting is enabled, and you're too strong for %s!", battle
->getName().c_str());
96 else if (ni
->stats
->getLevel() - battle
->getLevel() > maxbfightdistance
)
98 // You can't fight someone below you by more than X level(s)
99 // level 12 can fight level (12 - X) but not < (12 - X)
100 notice(s_GameServ
, u
, "You may not fight %s. You're too strong!",
101 battle
->getName().c_str());
103 else if (battle
->getLevel() - ni
->stats
->getLevel() > maxafightdistance
)
105 // You can't fight someone above you by more than X level(S)
106 // level 1 can fight level (1 + X), but not > (1 + X)
107 notice(s_GameServ
, u
, "%s, do you really have a death wish? Try the forest you "\
108 "weakling!", ni
->stats
->getName().c_str());
112 // Set your battle pointer to the other player
113 ni
->stats
->setBattle(battle
->getClient());
115 // Set the other player's battle pointer to you
116 battle
->setBattle(ni
);
118 // The initiator gets the first move (perhaps this should be 50/50)
119 setYourTurn(ni
->stats
);
120 clearYourTurn(battle
);
122 // Initiate Battle sequence!
123 ni
->stats
->subtractPlayerFights(1);
125 notice(s_GameServ
, u
, "You challenge %s to an online duel!", battle
->getName().c_str());
126 notice(s_GameServ
, c_Forest
, "%s walks up and hits %s in the face! Let's see who will bite the dust.",
127 ni
->stats
->getName().c_str(), battle
->getName().c_str()); /* DrLnet - Modified by Kain*/
129 notice(s_GameServ
, battle
->getClient()->getNick(), "%s has challenged you to an online duel!", ni
->stats
->getName().c_str());
130 notice(s_GameServ
, battle
->getClient()->getNick(), "%s gets to go first "\
131 "because they initiated!", ni
->stats
->getName().c_str());
132 notice(s_GameServ
, battle
->getClient()->getNick(), "Please wait while %s decides what to do.", ni
->stats
->getName().c_str());