Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Battle View #129

Merged
merged 17 commits into from
Apr 21, 2018
Merged

Battle View #129

merged 17 commits into from
Apr 21, 2018

Conversation

Zonz
Copy link
Contributor

@Zonz Zonz commented Apr 8, 2018

No description provided.

@@ -165,7 +163,7 @@ private bool RepeatAttack()
{
if (ActivePokemon.CurrentHealth > 0 && _client.ActiveBattle.RepeatAttack)
{
_client.UseAttack(_lastAttackId);
_client.UseAttack(1);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure the game client sends 1 to repeat the attack?
I thought it was the previous attack ID.

We can remove _lastAttackId if this is always 1.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I looked at PRO's code and it just sends 1.

@@ -176,6 +176,11 @@ public void Update()
return;
}

if (Game != null && Game.IsInBattle && Game.IsInactive && AI != null && AI.UseMandatoryAction())
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, but this probably belongs to PROProtocol if the player cannot influence it.
PROProtocol should basically be enough to implement a full game client (without any cheat).
PROBot is just calling some PROProtocol methods to simulate the player movements, as if we were clicking.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know where else I can put this while still by-passing the 'bot started' check.

@@ -34,5 +34,29 @@ public PokemonExperience(int currentLevel, int baseExperience, int totalLevelExp
}
TotalLevelExperience = totalLevelExperience;
}

// A value between 0 and 54 that represents how much exp the Pokemon has gained since its last level.
public int RatioToNextLevel
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why between 0 and 54? This seems like an arbitrary choice.
A float between 0 and 1 or between 0 and 100 it probably more generic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just copy-pasted the way PRO does it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you or anyone else can figure out how to get the "experience gained since last level" I would gladly change this

using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using FontAwesome.WPF;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usings are not sorted alphabetically!!1 😢
(This is just nitpicking, I know.)

evs.Add($"{type}: {ev}");
}

OpponentEVs.ToolTip = string.Join("
", evs);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this working by any chance? It's a bit weird to have an hexadecimal constant in the code.

string.Join(Environment.NewLine, evs);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure enough, thanks

break;
}
}
if (hasPP)
Copy link
Owner

@Silv3rPRO Silv3rPRO Apr 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bool hasPP = active.Moves.Any(move => !string.IsNullOrEmpty(move?.Name) && move.CurrentPoints > 0);

This should work too if you want to LINQ-ify the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, I forget about that sometimes.

{
FloatingTip.IsOpen = true;
_selectedRectangle.Visibility = Visibility.Visible;
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure this was already merged in a previous pull request.
Make sure you merge or rebase my changes before opening a pull request to prevent duplicates like this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry,

@PreciousTrainer
Copy link
Contributor

I think there is one problem left. When a player gets disconnected from the server while battling, I think then the battle viewer should get reset. It should get reset like when it gets reset after a battle. I think that is the one thing missed. It can be crashed that time if the battle view doesn't get reset.

if (move.CurrentPoints > 0)
{
menuItem.Click += Attack_Click;
hasPP = true;
Copy link
Contributor Author

@Zonz Zonz Apr 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed the hasPP behavior so that it'll still show the other moves even if none of them have PP. (They'll still all be disabled of course)

@Silv3rPRO Silv3rPRO merged commit e653034 into Silv3rPRO:master Apr 21, 2018
@Zonz Zonz deleted the BattleView branch April 24, 2018 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants