C
C#6mo 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
Eren6mo ago
i have tried for hours and cant find it
Jimmacle
Jimmacle6mo ago
what code do you currently have? $code
MODiX
MODiX6mo 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
Eren6mo 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
Jimmacle6mo ago
we generally need a starting point to help
Eren
Eren6mo ago
yeah makes sense ill try and get some of the code let me look what i can do for starters
Jimmacle
Jimmacle6mo 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
Eren6mo 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
Jimmacle6mo ago
what does the DoMove function look like? and what does "wont work" mean?
Eren
Eren6mo 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
Jimmacle6mo ago
right, so look at the (int Index, Pokémon target,Pokémon user)
Eren
Eren6mo ago
this is the error(the one my mouse is on)
No description
Jimmacle
Jimmacle6mo 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
Eren6mo ago
so i need to add that
Jimmacle
Jimmacle6mo ago
the error tells you exactly what is wrong yes
Eren
Eren6mo 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
Jimmacle6mo 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
Eren6mo 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
Eren6mo ago
now my whole function domove becomes invalid tho
No description