C
C#11mo 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
ErenOP11mo ago
i have tried for hours and cant find it
Jimmacle
Jimmacle11mo ago
what code do you currently have? $code
MODiX
MODiX11mo 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
ErenOP11mo 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
Jimmacle11mo ago
we generally need a starting point to help
Eren
ErenOP11mo ago
yeah makes sense ill try and get some of the code let me look what i can do for starters
Jimmacle
Jimmacle11mo 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
ErenOP11mo 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
Jimmacle11mo ago
what does the DoMove function look like? and what does "wont work" mean?
Eren
ErenOP11mo 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
Jimmacle11mo ago
right, so look at the (int Index, Pokémon target,Pokémon user)
Eren
ErenOP11mo ago
this is the error(the one my mouse is on)
No description
Jimmacle
Jimmacle11mo 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
ErenOP11mo ago
so i need to add that
Jimmacle
Jimmacle11mo ago
the error tells you exactly what is wrong yes
Eren
ErenOP11mo ago
but my issue is that they tell us what parameters we need and they tell me for this function i need to use 2 chosen indexes 2 pokemon and 2 trainers that dont return anything which doesnt involve user
Jimmacle
Jimmacle11mo ago
i don't know the details of the whole project, that's just what the problem with the code is as it's written now so you either need to pass more things to DoMove or DoMove is incorrect and has too many parameters
Eren
ErenOP11mo ago
that is possible let me have a look one second it says return a index of a move and a pokemon that returns text i used the wrong paramters then i assume
Eren
ErenOP11mo ago
now my whole function domove becomes invalid tho
No description
Want results from more Discord servers?
Add your server