Note 2: It's the way I would do it, maybe you like to it do it different.
Note 3: It's all pseudo.
Let's say you have your main attack handler.
Code:
public static void Attack(Client client)
{
}
Code:
public static void Attack(Client client)
{
// Main attack handler here.
switch (client.AttackType)
{
case Physical:
PhysicalAttack.Process(client);
break;
case Magic:
MagicAttack.Process(client);
break;
case Bow:
BowAttack.Process(client);
break;
}
}
Example:
Code:
public class PhysicalAttack
{
public static void Process(Client client)
{
}
}
Instead having a bunch of codes in your attackhandler, then you can easy edit current things or add new things.
Don't make it harder for yourself, that's important.
I would do an integer for every function that should be parsed before the actual attack handler. It could be arena, tournaments or something other.
Then if it returns 0, then it should continue to the main attackhandler. If it returns above 0, then it should not continue to the main attackhandler.
All the calculations etc. should be done before the attackhandler.
Example on how to add a function.
Let's use the current code we have.
Code:
public static int Safe(Client client)
{
if (client.Map != client.Opponent.Map)
return 1;//Instead returning true at the start, then do it after the handler.
return 0;
}
public static void Attack(Client client)
{
if (Safe(client) > 0)
return;
// Main attack handler here.
switch (client.AttackType)
{
case Physical:
PhysicalAttack.Process(client);
break;
case Magic:
MagicAttack.Process(client);
break;
case Bow:
BowlAttack.Process(client);
break;
}
}
Remember I would have the functions in a seperate fil!






