Skip to content

Commit

Permalink
Update to 2.0.0.6
Browse files Browse the repository at this point in the history
Fix a bug
Support global version
  • Loading branch information
flier268 committed Oct 25, 2017
1 parent 7020065 commit f306ae7
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 33 deletions.
41 changes: 24 additions & 17 deletions Poe整理倉庫v2/Async.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ void POE_GetItemInfo(int x, int y)
}
private string reg = @":\s(.*?)\r\n(.*?)\r\n(.*?)--------\r\n(.*)";

string GetStringAfterSomething(string s, string beforeWhat)
{
string temp = s.Substring(s.IndexOf(beforeWhat) + 1, s.Length - s.IndexOf(beforeWhat) - 1);
return temp;
}


/// <summary>
/// 取得並分析POE倉庫頁面中所有物品的資訊
/// </summary>
Expand All @@ -49,18 +46,23 @@ public async void GetWarehouse(int length = 12)
Items.Clear();
used.Clear();
resoult.Clear();

//可能需要英文化
string reg_itemlevel = @"物品等級:\s(\d+)";
string reg_quality = @"品質:\s\+(\d+)";
string reg_level = @"(?<!需求:)\r\n^等級:\s(\d+)";
string reg_maplevel = @"地圖階級:\s(\d+)";
string reg_itemlevel = @"物品等級:\s(\d+)", reg_itemlevel_eng = @"Item Level:\s(\d+)";
string reg_quality = @"品質:\s\+(\d+)", reg_quality_eng= @"Quality:\s\+(\d+)";
string reg_level = @"(?<!需求:)\r\n^等級:\s(\d+)", reg_level_eng = @"(?<!Requirements:)\r\n^Level:\s(\d+)";
string reg_maplevel = @"地圖階級:\s(\d+)", reg_maplevel_eng = @"Map Tier:\s(\d+)";


Regex r_itemlevel = new Regex(reg_itemlevel, RegexOptions.IgnoreCase | RegexOptions.Multiline),
r_itemlevel_eng = new Regex(reg_itemlevel_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex r_quality = new Regex(reg_quality, RegexOptions.IgnoreCase | RegexOptions.Multiline),
r_quality_eng = new Regex(reg_quality_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex r_level = new Regex(reg_level, RegexOptions.IgnoreCase | RegexOptions.Multiline),
r_level_eng = new Regex(reg_level_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex r_maplevel = new Regex(reg_maplevel, RegexOptions.IgnoreCase | RegexOptions.Multiline),
r_maplevel_eng = new Regex(reg_maplevel_eng, RegexOptions.IgnoreCase | RegexOptions.Multiline);

Regex r_itemlevel = new Regex(reg_itemlevel, RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex r_quality = new Regex(reg_quality, RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex r_level = new Regex(reg_level, RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex r_maplevel = new Regex(reg_maplevel, RegexOptions.IgnoreCase | RegexOptions.Multiline);
Regex r = new Regex(reg, RegexOptions.IgnoreCase | RegexOptions.Singleline);
Match m, m_itemlevel, m_quality, m_level, m_maplevel;
int id = 0;
Expand Down Expand Up @@ -92,7 +94,7 @@ public async void GetWarehouse(int length = 12)
Item temp = new Item();
if (m.Groups[3].ToString() == "")
{
temp.Name = GetStringAfterSomething(m.Groups[2].ToString().Trim(), "」");
temp.Name = PrivateFunction.GetStringAfterSomething(m.Groups[2].ToString().Trim(), "」");
}
else
{
Expand All @@ -104,9 +106,13 @@ public async void GetWarehouse(int length = 12)

temp.Rarity = m.Groups[1].ToString().Trim();
m_itemlevel = r_itemlevel.Match(m.Groups[4].ToString());
m_itemlevel = m_itemlevel.Groups.Count == 1 ? r_itemlevel_eng.Match(m.Groups[4].ToString()) : m_itemlevel;
m_level = r_level.Match(m.Groups[4].ToString());
m_level = m_level.Groups.Count == 1 ? r_level_eng.Match(m.Groups[4].ToString()) : m_level;
m_maplevel = r_maplevel.Match(m.Groups[4].ToString());
m_maplevel = m_maplevel.Groups.Count==1?r_maplevel_eng.Match(m.Groups[4].ToString()):m_maplevel;
m_quality = r_quality.Match(m.Groups[4].ToString());
m_quality =m_quality.Groups.Count==1? r_quality_eng.Match(m.Groups[4].ToString()):m_quality;
temp.itemlevel = m_itemlevel.Groups.Count == 1 ? 0 : int.Parse(m_itemlevel.Groups[1].ToString());
temp.level = m_level.Groups.Count == 1 ? 0 : int.Parse(m_level.Groups[1].ToString());
temp.quality = m_quality.Groups.Count == 1 ? 0 : int.Parse(m_quality.Groups[1].ToString());
Expand All @@ -115,7 +121,7 @@ public async void GetWarehouse(int length = 12)
JsonClass.RootObject t;
if (m.Groups[1].ToString() == "傳奇" || m.Groups[1].ToString() == "Unique")
{
t = ItemList_Unique.Where(a => a.c.EndsWith(GetStringAfterSomething(temp.Name, "」")) || a.e.EndsWith(GetStringAfterSomething(temp.Name, "」"))).FirstOrDefault();
t = ItemList_Unique.Where(a => a.c.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」")) || a.e.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」"))).FirstOrDefault();
}
else
{
Expand All @@ -126,12 +132,13 @@ public async void GetWarehouse(int length = 12)
t = ItemList.Where(a => temp.Name.Contains(a.e)).FirstOrDefault();
}
if (t == null)
t = ItemList_Adden.Where(a => a.c.EndsWith(GetStringAfterSomething(temp.Name, "」")) || a.e.EndsWith(GetStringAfterSomething(temp.Name, "」"))).FirstOrDefault();
t = ItemList_Adden.Where(a => a.c.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」")) || a.e.EndsWith(PrivateFunction.GetStringAfterSomething(temp.Name, "」"))).FirstOrDefault();

while (t == null)
{
Form2 f = new Form2(clip, temp.Name);
f.ShowDialog();
if(File.Exists(Path.Combine(Application.StartupPath, "ItemList_Adden.txt")))
using (StreamReader rr = new StreamReader(Path.Combine(Application.StartupPath, "ItemList_Adden.txt"), Encoding.UTF8))
{
ItemList_Adden = JsonConvert.DeserializeObject<List<JsonClass.RootObject>>(rr.ReadToEnd());
Expand Down
7 changes: 4 additions & 3 deletions Poe整理倉庫v2/Form1.Designer.cs

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

2 changes: 1 addition & 1 deletion Poe整理倉庫v2/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private async void ItemList_Load()
await Task.Delay(0);
if (!File.Exists(Path.Combine(Application.StartupPath, "ItemList.txt")) || !File.Exists(Path.Combine(Application.StartupPath, "ItemList_Unique.txt")))
{
MessageBox.Show("找不到ItemList.txt和ItemList_Unique.txt");
MessageBox.Show("找不到ItemList.txt或ItemList_Unique.txt,請確認是否解壓縮完整");
return;
}
int stats = 0;
Expand Down
12 changes: 2 additions & 10 deletions Poe整理倉庫v2/Form2.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Form2(string clip,string Name)
InitializeComponent();
ApplicationHelper.SetForegroundWindow(this.Handle);
richTextBox1.Text = clip;
if (IsChineseContain(Name))
if (PrivateFunction.IsChineseContain(Name))
textBox1.Text = Name;
else
textBox2.Text = Name;
Expand All @@ -46,15 +46,7 @@ public Form2(string clip,string Name)
textBox4.Text = "question-mark.png";

}
private bool IsChineseContain(string s)
{
foreach(char c in s)
{
if ((int)c > 127)
return true;
}
return false;
}

private void Form2_Load(object sender, EventArgs e)
{

Expand Down
1 change: 1 addition & 0 deletions Poe整理倉庫v2/Poe整理倉庫v2.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Compile Include="Form2.Designer.cs">
<DependentUpon>Form2.cs</DependentUpon>
</Compile>
<Compile Include="PrivateFunction.cs" />
<Compile Include="Sort.cs">
<DependentUpon>Form1.cs</DependentUpon>
<SubType>Form</SubType>
Expand Down
26 changes: 26 additions & 0 deletions Poe整理倉庫v2/PrivateFunction.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Poe整理倉庫v2
{
public class PrivateFunction
{
public static bool IsChineseContain(string s)
{
foreach (char c in s)
{
if ((int)c > 127)
return true;
}
return false;
}
public static string GetStringAfterSomething(string s, string beforeWhat)
{
string temp = s.Substring(s.IndexOf(beforeWhat) + 1, s.Length - s.IndexOf(beforeWhat) - 1);
return temp;
}
}
}
4 changes: 2 additions & 2 deletions Poe整理倉庫v2/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// 您可以指定所有的值,或將組建編號或修訂編號設為預設值
// 指定為預設值:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("2.0.0.5")]
[assembly: AssemblyFileVersion("2.0.0.5")]
[assembly: AssemblyVersion("2.0.0.6")]
[assembly: AssemblyFileVersion("2.0.0.6")]

0 comments on commit f306ae7

Please sign in to comment.