Skip to content

Commit

Permalink
Update 1.0.2.4
Browse files Browse the repository at this point in the history
Ability Point algorithm improvement.
Adding explainment to colours.
Optimise average info.
  • Loading branch information
HenryQuan committed Apr 1, 2018
1 parent 6710fae commit 523cbb0
Show file tree
Hide file tree
Showing 8 changed files with 68 additions and 20 deletions.
10 changes: 9 additions & 1 deletion WRInfo/WRInfo/Core/PersonalRating.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@ public static void CalPersonalRating(PlayerInfo info, string shipID, dynamic jso
var nWins = Math.Max(0, (rWins - 0.7) / (1 - 0.7));

int PR = (int)(700 * nDmg + 300 * nFrags + 150 * nWins);
info.AddPrAblityPoint((int)(PR * info.Battle / 100), GetRatingColour(PR));
info.AddPrAblityPoint(CalAbilityPoint(PR, info.Battle), GetRatingColour(PR));
}

private static int CalAbilityPoint(double pr, double battle)
{
if (battle == 0) return 1;
var adjustment = Math.Sqrt(battle) / 7;
if (adjustment < 1) adjustment = 1;
return (int)(Math.Round(adjustment * pr));
}

private static Color GetRatingColour(int pr)
Expand Down
56 changes: 39 additions & 17 deletions WRInfo/WRInfo/PlayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using WRInfo.Resouces;
using Console = Colorful.Console;

namespace WRInfo
Expand Down Expand Up @@ -97,28 +98,47 @@ public static void ShowTeamOverview(List<PlayerInfo> team0, List<PlayerInfo> tea
return (prev.ability < next.ability) ? 1 : -1;
});

// Show what colour means
Console.WriteLine("\nPersonal Rating\n" + strings.colour_meaning + "\n");

// Calculate team 0 and team 1 average win rate and ability point
int team0Count = team0.Count;
int team1Count = team1.Count;
int team0Count = team0.Count - 2;
int team1Count = team1.Count - 2;
double team0Win = 0, team1Win = 0, team0AP = 0, team1AP = 0;
if (team0Count == team1Count)
{
Console.WriteAscii("Team 0 Team 1", Colour.WBlue);
// This is normal mode
for (var i = 0; i < team0.Count; i++)
// Ignore the best player and get average of other players
for (var i = 1; i < team0.Count; i++)
{
var player0 = team0[i];
var player1 = team1[i];

// This player hides stat
if (player0.ability == 0) team0Count--;
else if (player1.ability == 0) team1Count--;
else
{
team0Win += player0.Winrate;
team1Win += player1.Winrate;
team0AP += player0.Ability;
team1AP += player1.Ability;
// Ignore last player
if (i != team0.Count)
{
if (player0.ability == 0)
{
// Ignore player 0
team1Win += player1.Winrate;
team1AP += player1.Ability;
team0Count--;
}
else if (player1.ability == 0)
{
// Ignore player 1
team0Win += player0.Winrate;
team0AP += player0.Ability;
team1Count--;
}
else
{
// Add both players
team0Win += player0.Winrate;
team0AP += player0.Ability;
team1Win += player1.Winrate;
team1AP += player1.Ability;
}
}

player0.ShowPlayer(true);
Expand All @@ -127,10 +147,12 @@ public static void ShowTeamOverview(List<PlayerInfo> team0, List<PlayerInfo> tea
Console.WriteLine("\n");
}
// Print extra information
Console.WriteLine("Team 0 - {0, 4}% - {1}",
GetRoundValue(team0Win, team0Count), GetRoundValue(team0AP, team0Count), Colour.WYellow);
Console.WriteLine("Team 1 - {0, 4}% - {1}",
GetRoundValue(team1Win, team0Count), GetRoundValue(team1AP, team0Count), Colour.WYellow);
Console.WriteLine("Team 0 - {0, 4}% - {1} - {2}",
GetRoundValue(team0Win, team0Count),
GetRoundValue(team0AP, team0Count), team0Count, Colour.WYellow);
Console.WriteLine("Team 1 - {0, 4}% - {1} - {2}",
GetRoundValue(team1Win, team0Count),
GetRoundValue(team1AP, team0Count), team1Count, Colour.WYellow);
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion WRInfo/WRInfo/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ private static void StartWRInfo()
// Checking date difference in seconds if it is less than 5 mins consider a battle
var difference = (DateTime.Now - lastBattledDate).TotalSeconds;

if (difference < 600)
if (difference < 300)
{
CheckPlayerInfo(python_log);
}
Expand Down
9 changes: 9 additions & 0 deletions WRInfo/WRInfo/Resouces/strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions WRInfo/WRInfo/Resouces/strings.ja.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<data name="api" xml:space="preserve">
<value>API</value>
</data>
<data name="colour_meaning" xml:space="preserve">
<value>紫色 &gt; 青色 &gt; 緑色 &gt; 黄色 &gt; オレンジ色 &gt; 赤色</value>
</data>
<data name="complete" xml:space="preserve">
<value>完了しました。。</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions WRInfo/WRInfo/Resouces/strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<data name="api" xml:space="preserve">
<value>API</value>
</data>
<data name="colour_meaning" xml:space="preserve">
<value>Purple &gt; Cyan &gt; Green &gt; Yellow &gt; Orange &gt; Red</value>
</data>
<data name="complete" xml:space="preserve">
<value>Completed...</value>
</data>
Expand Down
3 changes: 3 additions & 0 deletions WRInfo/WRInfo/Resouces/strings.zh.resx
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@
<data name="api" xml:space="preserve">
<value>API</value>
</data>
<data name="colour_meaning" xml:space="preserve">
<value>紫色 &gt; 青色 &gt; 绿色 &gt; 黄色 &gt; 橘色 &gt; 红色</value>
</data>
<data name="complete" xml:space="preserve">
<value>完成。。</value>
</data>
Expand Down
2 changes: 1 addition & 1 deletion WRInfo/WRInfo/Value.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace WRInfo
{
class Value
{
static public string VERSION = "1.0.2.2";
static public string VERSION = "1.0.2.4";
static public string ApplicationID = "e8b46cbc33f242c78725bd6a7562788a";

static public string PlayerSearch = "https://api.worldofwarships.{0}/wows/account/list/?application_id=" + ApplicationID + "&search={1}&type=exact&language=en&fields=account_id";
Expand Down

0 comments on commit 523cbb0

Please sign in to comment.