C
C#8mo ago
Eren

Need help creating a function

Resolving Moves Round Short description When the two trainers have chosen to have their Pokémon perform a move, it is based on: The speed determines which Pokémon can perform its move first. Implementation • Write a function based on the two trainers, their two Pokémon and two chosen indexes the moves, does not return anything but does print the execution of the moves to the console • When the speed of the first Pokémon is greater than or equal to that of the second Pokémon, then first the first Pokémon performs its move, then the second • If the speed of the first Pokémon is less than that of the second Pokémon, then First the second Pokémon performs its move, then the first • If in both cases, after the first execution of the move, the receiving Pokémon loses its lives (HealthPoints) would be set to 0, the function will be terminated prematurely • Update the battle information after each execution of a move • Also print the execution of all the moves to the console
19 Replies
Eren
Eren8mo ago
i have tried for hours and cant find it
Jimmacle
Jimmacle8mo ago
what code do you currently have? $code
MODiX
MODiX8mo ago
To post C# code type the following: ```cs // code here ``` Get an example by typing $codegif in chat For longer snippets, use: https://paste.mod.gg/
Eren
Eren8mo ago
nothing it was messed up and i removed it got really confused so i worked on the other functions and now i need to finish this one
Jimmacle
Jimmacle8mo ago
we generally need a starting point to help
Eren
Eren8mo ago
yeah makes sense ill try and get some of the code let me look what i can do for starters
Jimmacle
Jimmacle8mo ago
next time don't delete it or use a tool like git so that you still have old versions of your code saved
Eren
Eren8mo ago
yeah my brains just hurting i forgot
cs public void ResolvingMovesRound(Trainer trainer1, int index1, Pokémon pokémon1 , Pokémon pokémon2, Trainer trainer2, int index2)
{
if(pokémon1.Speed >= pokémon2.Speed)
{
pokémon1.DoMove(index1, pokémon2);
}


}
cs public void ResolvingMovesRound(Trainer trainer1, int index1, Pokémon pokémon1 , Pokémon pokémon2, Trainer trainer2, int index2)
{
if(pokémon1.Speed >= pokémon2.Speed)
{
pokémon1.DoMove(index1, pokémon2);
}


}
my issue is when i call my function to usemove the parameters im giving in wont work
Jimmacle
Jimmacle8mo ago
what does the DoMove function look like? and what does "wont work" mean?
Eren
Eren8mo ago
ill send u it one sec
cs public static string DoMove(int Index, Pokémon target,Pokémon user)
{
Move move = user.Moves[Index];



if (move is DamageMove dm)
{
return dm.DoDamage(user, target);
}
else if( move is HealingMove hm)
{
return hm.DoHeal(user);

}


return $"invalid move";

}
cs public static string DoMove(int Index, Pokémon target,Pokémon user)
{
Move move = user.Moves[Index];



if (move is DamageMove dm)
{
return dm.DoDamage(user, target);
}
else if( move is HealingMove hm)
{
return hm.DoHeal(user);

}


return $"invalid move";

}
this is the domove function
Jimmacle
Jimmacle8mo ago
right, so look at the (int Index, Pokémon target,Pokémon user)
Eren
Eren8mo ago
this is the error(the one my mouse is on)
No description
Jimmacle
Jimmacle8mo ago
those are the parameters, you need to provide every one of them to call the function it looks like you're missing one
Eren
Eren8mo ago
so i need to add that
Jimmacle
Jimmacle8mo ago
the error tells you exactly what is wrong yes
Want results from more Discord servers?
Add your server