Note: There is no calculations or codes really, but more a good way to structure your attack handler, so it's easy to edit in the future or add new things.
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.
Then I would do a main attack handling & split it up to the different attack types. Physical, Magic & Bow.
Then I would do a class for every attack type & it should contains a void called Process, which is handling the process for that type.
Example:
Now you already have a good structure for your main attack handler, but how can this be useful?
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.
I know there is not much info, but I hope you find it useful.
Remember I would have the functions in a seperate fil!
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!