From 0081e58efe7ae92934004add3f970b0dedf23196 Mon Sep 17 00:00:00 2001 From: eric0210 <77634181+hsheric0210@users.noreply.github.com> Date: Thu, 7 Apr 2022 05:02:48 +0900 Subject: [PATCH] #2 #4 #7 #10 #11 #12 #13 #15 --- .vs/AutoKkutu/v17/.suo | Bin 152064 -> 157696 bytes Config.cs | 36 ++++ ConfigWindow.xaml | 124 +++++++++++ ConfigWindow.xaml.cs | 59 +++++ DatabaseManagement.xaml | 297 +++----------------------- DatabaseManagement.xaml.cs | 143 ++++++++----- DatabaseManager.cs | 70 +++++- Example Database/well-made-2.sqlite | Bin 1421312 -> 1421312 bytes Handlers/CommonHandler.cs | 21 +- MainWindow.xaml | 320 +++------------------------- MainWindow.xaml.cs | 233 +++++++++++++------- PathFinder.cs | 115 +++++----- 12 files changed, 666 insertions(+), 752 deletions(-) create mode 100644 Config.cs create mode 100644 ConfigWindow.xaml create mode 100644 ConfigWindow.xaml.cs diff --git a/.vs/AutoKkutu/v17/.suo b/.vs/AutoKkutu/v17/.suo index 05088aef28f8fd61494d31f15ee9df40e84b42a4..cceffc53e0173fa99f889e28fe9864e6711fe141 100644 GIT binary patch delta 13381 zcmeHO3tZGy_Mh`(W}HEg;f;U@h=R&vc*rY=;UVG+ki|zz=qRWZFL5yQ0pqT2rdBdn zxw`9`qM?)pN{J@rBxdH8udK+dw1?|o%~zPKxw7ZX0|wL5P5XTQ``P>9JLmk)ecyBM zIrrY*5A8;|_ON_;T+jI;kw}KP)!yEYL}Y~sL_{w}S}@+oAQ_`aCtF$+1RU0{0t3sN8UTIEqXRB#@OwxpQKtgV-jCv8!!q^;Qq(pDb{NemiOQ|}C&xuW{6|>D{ZB==Bet?At2rGmb zAwftH-4HT_9Krn7`H3Bg8L`fdIjvK8d*MTGgg3$m;ftU}<%gh&%~q@n%%}Qk%!o#q zXrzfoBaJcfk06aR@sFCQ3TdK=Pd3rPNK;LGnu*@3QaiHf^`#O+N7<|EABiK*M-YkT zW0DF)B|?k%uj{GX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g4xs`k&QYzHKy@JeZ{1D>A1R*k8Rs{pg=$VK;t>doJhV9&~_eZ%o0) z%cN=4D{5JFg$7CG2rc~E&aM3cisB^;+AG(7%s4dV1t|&-#vkdrkJwk(*}NBTPrc<^LzD=4%%X(LJr<==-ZfMiL~jeq zy)L&6Rr<)WLzF^wc}c~+V(FPQ4e#TYeoc--e3fk)qU@*1a`I3mUGCXMLA)PkD{|Rz z1w&#{0&pXb4;DS-w?mcTf9n@4_pT_6YzOcYTu`)L*`+QOHu|yhE$R&GQ6RrvoduzTj7NwDoHCXbUBD Wa9Yd%D=FrFdQO^$DgFN$D)K)gy5tc6 diff --git a/Config.cs b/Config.cs new file mode 100644 index 0000000..8e13cde --- /dev/null +++ b/Config.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace AutoKkutu +{ + public class Config + { + public const string DBAUTOUPDATE_GAME_END = "게임이 끝났을 때"; + public const int DBAUTOUPDATE_GAME_END_INDEX = 0; + public const string DBAUTOUPDATE_ROUND_END = "라운드가 끝났을 때"; + public const int DBAUTOUPDATE_GAME_ROUND_INDEX = 1; + + public const string WORDPREFERENCE_BY_DAMAGE = "단어의 공격력 우선"; + public const int WORDPREFERENCE_BY_DAMAGE_INDEX = 0; + public const string WORDPREFERENCE_BY_LENGTH = "단어의 길이 우선"; + public const int WORDPREFERENCE_BY_LENGTH_INDEX = 1; + + public bool AutoEnter = true; + public bool AutoDBUpdate = true; + public int AutoDBUpdateMode = DBAUTOUPDATE_GAME_END_INDEX; + public int WordPreference = WORDPREFERENCE_BY_DAMAGE_INDEX; + public bool UseEndWord = false; + public bool ReturnMode = false; + public bool AutoFix = true; + public bool MissionDetection = true; + + public Config() + { + } + } +} diff --git a/ConfigWindow.xaml b/ConfigWindow.xaml new file mode 100644 index 0000000..48376a9 --- /dev/null +++ b/ConfigWindow.xaml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - + + + - + - diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 7bca184..07d18d8 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -31,15 +31,25 @@ public partial class MainWindow : Window private static bool _pathSelected; + private int WordIndex = 0; + public CommonHandler GameHandler; + public static Config CurrentConfig; + private enum CurrentStatus { Normal, - Warning, + Searching, + AutoEntered, + NotFound, Error, - NoPath, - Wait + EndWord, + Wait, + DB_Job, + DB_Job_Done, + Adding_Words, + Adding_Words_Done } public MainWindow() @@ -58,6 +68,9 @@ public MainWindow() CachePath = Environment.CurrentDirectory + "\\Cache" }, true, (IApp)null); + // Load default config + PathFinder.UpdateConfig(CurrentConfig = new Config()); + // TODO: Improve this string url = "https://kkutu.org"; if (new FileInfo("targetserver.txt").Exists) @@ -74,6 +87,7 @@ public MainWindow() ConsoleManager.Log(ConsoleManager.LogType.Info, "Starting Load Page...", MAINTHREAD_NAME); LoadOverlay.Visibility = Visibility.Visible; TextInput.Text = INPUT_TEXT_PLACEHOLDER; + TextInput.FontStyle = FontStyles.Italic; ChangeStatusBar(CurrentStatus.Wait); SetSearchState(null, false); browser.FrameLoadEnd += Browser_FrameLoadEnd; @@ -83,6 +97,13 @@ public MainWindow() PathFinder.Init(); } + public static void UpdateConfig(Config newConfig) + { + ConsoleManager.Log(ConsoleManager.LogType.Info, "Updated config.", MAINTHREAD_NAME); + CurrentConfig = newConfig; + PathFinder.UpdateConfig(newConfig); + } + private void DatabaseManager_DBError(object sender, EventArgs e) => ChangeStatusBar(CurrentStatus.Error); private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e) @@ -97,13 +118,40 @@ private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e) }); browser.FrameLoadEnd -= Browser_FrameLoadEnd; GameHandler = new KkutuOrgHandler(browser); - GameHandler.GameStartedEvent += new EventHandler(KkutuHandler_GameStart); - GameHandler.GameEndedEvent += new EventHandler(KkutuHandler_GameEnd); - GameHandler.MyTurnEvent += new EventHandler(KkutuHandler_MyTurnEvent); - GameHandler.MyTurnEndedEvent += new EventHandler(KkutuHandler_MyTurnEndEvent); - GameHandler.MyPathIsWrongEvent += new EventHandler(KkutuHandler_MyPathIsWrong); + GameHandler.GameStartedEvent += new EventHandler(CommonHandler_GameStart); + GameHandler.GameEndedEvent += new EventHandler(CommonHandler_GameEnd); + GameHandler.MyTurnEvent += new EventHandler(CommonHandler_MyTurnEvent); + GameHandler.MyTurnEndedEvent += new EventHandler(CommonHandler_MyTurnEndEvent); + GameHandler.WrongWordEvent += new EventHandler(CommonHandler_WrongPathEvent); + GameHandler.MyPathIsWrongEvent += new EventHandler(CommonHandler_MyPathIsWrong); + GameHandler.RoundChangeEvent += new EventHandler(CommonHandler_RoundChangeEvent); GameHandler.StartWatchdog(); - PathFinder.UpdatedPath = (EventHandler)Delegate.Combine(PathFinder.UpdatedPath, new EventHandler(PathFinder_UpdatedPath)); + PathFinder.UpdatedPath += new EventHandler(PathFinder_UpdatedPath); + DatabaseManager.DBJobStart += new EventHandler(DatabaseManager_DBJobStart); + DatabaseManager.DBJobDone += new EventHandler(DatabaseManager_DBJobDone); + DatabaseManagement.AddWordStart += new EventHandler(DatabaseManagement_AddWordStart); + DatabaseManagement.AddWordDone += new EventHandler(DatabaseManagement_AddWordDone); + } + + private void DatabaseManager_DBJobStart(object sender, EventArgs e) + { + ChangeStatusBar(CurrentStatus.DB_Job, ((DatabaseManager.DBJobArgs)e).JobName); + } + + private void DatabaseManager_DBJobDone(object sender, EventArgs e) + { + var args = ((DatabaseManager.DBJobArgs)e); + ChangeStatusBar(CurrentStatus.DB_Job, args.JobName, args.Result); + } + + private void DatabaseManagement_AddWordStart(object sender, EventArgs e) + { + ChangeStatusBar(CurrentStatus.Adding_Words); + } + + private void DatabaseManagement_AddWordDone(object sender, EventArgs e) + { + ChangeStatusBar(CurrentStatus.Adding_Words_Done); } private void SetSearchState(PathFinder.UpdatedPathEventArgs arg, bool IsEnd = false) @@ -139,47 +187,45 @@ private void SetSearchState(PathFinder.UpdatedPathEventArgs arg, bool IsEnd = fa Dispatcher.Invoke(() => SearchResult.Text = Result); } - private async void UpdateUI(PathFinder.UpdatedPathEventArgs arg) - { - if (arg.Result == PathFinder.FindResult.Normal) - ChangeStatusBar(CurrentStatus.Normal); - else if (arg.Result == PathFinder.FindResult.None) - ChangeStatusBar(CurrentStatus.Warning); - else if (arg.Result == PathFinder.FindResult.Error) - ChangeStatusBar(CurrentStatus.Error); - SetSearchState(arg); - } - private void PathFinder_UpdatedPath(object sender, EventArgs e) { - bool AutomodeChecked = false; ConsoleManager.Log(ConsoleManager.LogType.Info, "Path update received. ( PathFinder_UpdatedPath() )", MAINTHREAD_NAME); var i = (PathFinder.UpdatedPathEventArgs)e; - Task.Run(() => UpdateUI(i)); + + if (i.Result == PathFinder.FindResult.None) + ChangeStatusBar(CurrentStatus.NotFound); + else if (i.Result == PathFinder.FindResult.Error) + ChangeStatusBar(CurrentStatus.Error); + + Task.Run(() => SetSearchState(i)); + Dispatcher.Invoke(() => { PathList.ItemsSource = PathFinder.FinalList; - AutomodeChecked = Automode.IsChecked.Value; }); _pathSelected = false; - if (AutomodeChecked) + if (CurrentConfig.AutoEnter) { if (i.Result == PathFinder.FindResult.None) { ConsoleManager.Log(ConsoleManager.LogType.Info, "Auto mode enabled. but can't find any path.", MAINTHREAD_NAME); - ChangeStatusBar(CurrentStatus.Warning); + ChangeStatusBar(CurrentStatus.NotFound); } else { + string content = PathFinder.FinalList.First().Content; ConsoleManager.Log(ConsoleManager.LogType.Info, "Auto mode enabled. automatically use first path.", MAINTHREAD_NAME); - ConsoleManager.Log(ConsoleManager.LogType.Info, "Execute Path : " + PathFinder.FinalList.First().Content, MAINTHREAD_NAME); - LastUsedPath = PathFinder.FinalList.First().Content; + ConsoleManager.Log(ConsoleManager.LogType.Info, "Execute Path : " + content, MAINTHREAD_NAME); + LastUsedPath = content; _pathSelected = true; - GameHandler.SendMessage(PathFinder.FinalList.First().Content); + GameHandler.SendMessage(content); + ChangeStatusBar(CurrentStatus.AutoEntered, content); } } + else + ChangeStatusBar(CurrentStatus.Normal); } private void ResetPathList() @@ -189,20 +235,16 @@ private void ResetPathList() Dispatcher.Invoke(() => PathList.ItemsSource = PathFinder.FinalList); } - private void KkutuHandler_MyTurnEndEvent(object sender, EventArgs e) + private void CommonHandler_MyTurnEndEvent(object sender, EventArgs e) { + ConsoleManager.Log(ConsoleManager.LogType.Warning, "Reset WordIndex to zero", MAINTHREAD_NAME); + WordIndex = 0; } - private void KkutuHandler_MyTurnEvent(object sender, EventArgs e) + private void CommonHandler_MyTurnEvent(object sender, EventArgs e) { - var word = ((CommonHandler.MyTurnEventArgs)e).Word; - bool EndwordChecked = false; - bool DontUseEndWord = false; - Dispatcher.Invoke(() => - { - EndwordChecked = PreferEndWord.IsChecked ?? false; - DontUseEndWord = MannerMode.IsChecked ?? false; - }); + var args = ((CommonHandler.MyTurnEventArgs)e); + var word = args.Word; try { if (PathFinder.EndWordList.Contains(word.Content) && (!word.CanSubstitution || PathFinder.EndWordList.Contains(word.Substitution))) @@ -210,10 +252,13 @@ private void KkutuHandler_MyTurnEvent(object sender, EventArgs e) ConsoleManager.Log(ConsoleManager.LogType.Warning, "Can't Find any path : Presented word is End word.", MAINTHREAD_NAME); ResetPathList(); SetSearchState(null, true); - ChangeStatusBar(CurrentStatus.NoPath); + ChangeStatusBar(CurrentStatus.EndWord); } else - PathFinder.FindPath(word, DontUseEndWord, EndwordChecked); + { + ChangeStatusBar(CurrentStatus.Searching); + PathFinder.FindPath(word, CurrentConfig.MissionDetection ? args.MissionChar : "", CurrentConfig.WordPreference, CurrentConfig.UseEndWord && PathFinder.PreviousPath.Count > 0); // 첫 턴 한방 방지 + } } catch (Exception ex) { @@ -221,35 +266,39 @@ private void KkutuHandler_MyTurnEvent(object sender, EventArgs e) } } - private void KkutuHandler_MyPathIsWrong(object sender, EventArgs e) + private void CommonHandler_WrongPathEvent(object sender, EventArgs e) { - bool AutomodeChecked = false; - ConsoleManager.Log(ConsoleManager.LogType.Info, "Entered word is wrong. ( KkutuHandler_MyPathIsWrong() )", MAINTHREAD_NAME); + string theWord = ((CommonHandler.WrongWordEventArgs)e).Word; + ConsoleManager.Log(ConsoleManager.LogType.Info, $"Entered word '{theWord}' is wrong; Added to removal list", MAINTHREAD_NAME); + PathFinder.AddToWrongWord(theWord); + } + private void CommonHandler_MyPathIsWrong(object sender, EventArgs e) + { var word = ((CommonHandler.WrongWordEventArgs)e).Word; + ConsoleManager.Log(ConsoleManager.LogType.Info, $"My path '{word}' is wrong.", MAINTHREAD_NAME); - // Remove from final-list - PathFinder.FinalList.RemoveAll(p => p.Content.Equals(word, StringComparison.InvariantCultureIgnoreCase)); + if (!CurrentConfig.AutoFix) + return; - if (PathFinder.FinalList.Count <= 0) + List localFinalList = PathFinder.FinalList; + if (localFinalList.Count < WordIndex - 1) { - ConsoleManager.Log(ConsoleManager.LogType.Warning, "Can't Find any path.", MAINTHREAD_NAME); - ChangeStatusBar(CurrentStatus.NoPath); + if (localFinalList.Count <= 0) + ConsoleManager.Log(ConsoleManager.LogType.Warning, "Can't Find any path.", MAINTHREAD_NAME); + else + ConsoleManager.Log(ConsoleManager.LogType.Warning, "Found path, but there's no path to use.", MAINTHREAD_NAME); + ChangeStatusBar(CurrentStatus.EndWord); } - Dispatcher.Invoke(() => - { - PathList.ItemsSource = PathFinder.FinalList; - AutomodeChecked = Automode.IsChecked.Value; - }); - _pathSelected = false; - if (AutomodeChecked) + if (CurrentConfig.AutoEnter) { try { - string path = PathFinder.FinalList.First().Content; - ConsoleManager.Log(ConsoleManager.LogType.Info, "Auto mode enabled. automatically use next path.", MAINTHREAD_NAME); + WordIndex++; + string path = localFinalList[WordIndex].Content; + ConsoleManager.Log(ConsoleManager.LogType.Info, $"Auto mode enabled. automatically use next path (index {WordIndex}).", MAINTHREAD_NAME); ConsoleManager.Log(ConsoleManager.LogType.Info, "Execute Path : " + path, MAINTHREAD_NAME); LastUsedPath = path; _pathSelected = true; @@ -260,22 +309,29 @@ private void KkutuHandler_MyPathIsWrong(object sender, EventArgs e) ConsoleManager.Log(ConsoleManager.LogType.Error, $"Can't execute path : {ex}", MAINTHREAD_NAME); } } - - PathFinder.AddExclusion(word); } - private void KkutuHandler_GameStart(object sender, EventArgs e) => ChangeStatusBar(CurrentStatus.Normal); + private void CommonHandler_GameStart(object sender, EventArgs e) + { + ChangeStatusBar(CurrentStatus.Normal); + WordIndex = 0; + } - private void KkutuHandler_GameEnd(object sender, EventArgs e) + private void CommonHandler_GameEnd(object sender, EventArgs e) { - bool EnableDBAutoUpdate = false; SetSearchState(null, false); ResetPathList(); - Dispatcher.Invoke(() => EnableDBAutoUpdate = AutoDBUpdate.IsEnabled); - PathFinder.AutoDBUpdate(EnableDBAutoUpdate); + if (CurrentConfig.AutoDBUpdateMode == Config.DBAUTOUPDATE_GAME_END_INDEX) + PathFinder.AutoDBUpdate(); ChangeStatusBar(CurrentStatus.Wait); } + private void CommonHandler_RoundChangeEvent(object sender, EventArgs e) + { + if (CurrentConfig.AutoDBUpdateMode == Config.DBAUTOUPDATE_GAME_ROUND_INDEX) + PathFinder.AutoDBUpdate(); + } + private void RemoveAd() { browser.ExecuteScriptAsyncWhenPageLoaded("document.body.style.overflow ='hidden'", false); @@ -285,7 +341,7 @@ private void RemoveAd() browser.ExecuteScriptAsyncWhenPageLoaded("document.getElementsByClassName('kktukorea__1LZzX_0')[0].style = 'display:none'", false); } - private void ChangeStatusBar(CurrentStatus status) + private void ChangeStatusBar(CurrentStatus status, params object[] formatterArgs) { Color StatusColor; string StatusContent; @@ -295,11 +351,11 @@ private void ChangeStatusBar(CurrentStatus status) StatusColor = Resource.ColorSource.NormalColor; StatusContent = "준비"; break; - case CurrentStatus.Warning: + case CurrentStatus.NotFound: StatusColor = Resource.ColorSource.WarningColor; StatusContent = "이 턴에 낼 수 있는 단어를 데이터 집합에서 찾을 수 없었습니다. 수동으로 입력하십시오."; break; - case CurrentStatus.NoPath: + case CurrentStatus.EndWord: StatusColor = Resource.ColorSource.ErrorColor; StatusContent = "더 이상 이 턴에 낼 수 있는 단어가 없습니다."; break; @@ -307,6 +363,30 @@ private void ChangeStatusBar(CurrentStatus status) StatusColor = Resource.ColorSource.ErrorColor; StatusContent = "서버에 문제가 있습니다. 자세한 사항은 콘솔을 참조하십시오."; break; + case CurrentStatus.Searching: + StatusColor = Resource.ColorSource.WarningColor; + StatusContent = "단어 찾는 중..."; + break; + case CurrentStatus.AutoEntered: + StatusColor = Resource.ColorSource.NormalColor; + StatusContent = "단어 자동 입력됨: {0}"; + break; + case CurrentStatus.DB_Job: + StatusColor = Resource.ColorSource.WarningColor; + StatusContent = "데이터베이스 작업 '{0}' 진행 중..."; + break; + case CurrentStatus.DB_Job_Done: + StatusColor = Resource.ColorSource.NormalColor; + StatusContent = "데이터베이스 작업 '{0}' 완료: {1}"; + break; + case CurrentStatus.Adding_Words: + StatusColor = Resource.ColorSource.WarningColor; + StatusContent = "단어 일괄 추가 작업 중..."; + break; + case CurrentStatus.Adding_Words_Done: + StatusColor = Resource.ColorSource.NormalColor; + StatusContent = "단어 일괄 추가 작업 완료"; + break; default: StatusColor = Resource.ColorSource.WaitColor; StatusContent = "게임 참가를 기다리는 중."; @@ -315,10 +395,10 @@ private void ChangeStatusBar(CurrentStatus status) } ConsoleManager.Log(ConsoleManager.LogType.Info, "Statusbar status change to " + status.ToString() + ".", MAINTHREAD_NAME); - Dispatcher.Invoke(delegate () + Dispatcher.Invoke(() => { StatusGrid.Background = new SolidColorBrush(StatusColor); - StatusLabel.Content = StatusContent; + StatusLabel.Content = string.Format(StatusContent, formatterArgs); }); } @@ -347,13 +427,19 @@ private void ClipboardSubmit_Click(object sender, RoutedEventArgs e) private void TextInput_GotFocus(object sender, RoutedEventArgs e) { if (TextInput.Text == INPUT_TEXT_PLACEHOLDER) + { TextInput.Text = ""; + TextInput.FontStyle = FontStyles.Normal; + } } private void TextInput_LostFocus(object sender, RoutedEventArgs e) { if (string.IsNullOrWhiteSpace(TextInput.Text)) + { TextInput.Text = INPUT_TEXT_PLACEHOLDER; + TextInput.FontStyle = FontStyles.Normal; + } } private void PathList_MouseDoubleClick(object sender, MouseButtonEventArgs e) @@ -378,14 +464,9 @@ private void PathList_MouseDoubleClick(object sender, MouseButtonEventArgs e) private void DBManager_Click(object sender, RoutedEventArgs e) => new DatabaseManagement().Show(); - private void MannerMode_Click(object sender, RoutedEventArgs e) - { - PathFinder.Manner = MannerMode.IsChecked ?? false; - } - - private void Return_Click(object sender, RoutedEventArgs e) + private void Settings_Click(object sender, RoutedEventArgs e) { - PathFinder.AllowDuplicate = Return.IsChecked ?? false; + new ConfigWindow(CurrentConfig).Show(); } } } diff --git a/PathFinder.cs b/PathFinder.cs index 5a1f9e0..0b14ca0 100644 --- a/PathFinder.cs +++ b/PathFinder.cs @@ -22,8 +22,7 @@ class PathFinder public static EventHandler UpdatedPath; - public static bool AllowDuplicate = false; - public static bool Manner = false; + public static Config CurrentConfig; public static void Init() { try @@ -36,49 +35,54 @@ public static void Init() } } - public static void AutoDBUpdate(bool IsEnabled) + public static void UpdateConfig(Config newConfig) { - if (IsEnabled) + CurrentConfig = newConfig; + } + + public static void AutoDBUpdate() + { + if (!CurrentConfig.AutoDBUpdate) + return; + + ConsoleManager.Log(ConsoleManager.LogType.Info, "Automatically update the DB based on last game.", LOGIN_INSTANCE_NAME); + if (NewPathList.Count + WrongPathList.Count == 0) + ConsoleManager.Log(ConsoleManager.LogType.Warning, "No such element in autoupdate list.", LOGIN_INSTANCE_NAME); + else { - ConsoleManager.Log(ConsoleManager.LogType.Info, "Automatically update the DB based on last game.", LOGIN_INSTANCE_NAME); - if (NewPathList.Count + WrongPathList.Count == 0) - ConsoleManager.Log(ConsoleManager.LogType.Warning, "No such element in autoupdate list.", LOGIN_INSTANCE_NAME); - else + ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Get {0} elements from NewPathList.", NewPathList.Count), LOGIN_INSTANCE_NAME); + foreach (string word in NewPathList) { - ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Get {0} elements from NewPathList.", NewPathList.Count), LOGIN_INSTANCE_NAME); - foreach (string word in NewPathList) + bool isEndWord = EndWordList.Contains(word.Last().ToString()); + try { - bool isEndWord = EndWordList.Contains(word.Last().ToString()); - try - { - ConsoleManager.Log(ConsoleManager.LogType.Info, $"Check and add '{word}' into database.", LOGIN_INSTANCE_NAME); - if (DatabaseManager.AddWord(word, isEndWord)) - ConsoleManager.Log(ConsoleManager.LogType.Info, $"Added '{word}' into database.", LOGIN_INSTANCE_NAME); - } - catch (Exception ex) - { - ConsoleManager.Log(ConsoleManager.LogType.Error, $"Can't add '{word}' to database : " + ex.ToString(), LOGIN_INSTANCE_NAME); - } + ConsoleManager.Log(ConsoleManager.LogType.Info, $"Check and add '{word}' into database.", LOGIN_INSTANCE_NAME); + if (DatabaseManager.AddWord(word, isEndWord)) + ConsoleManager.Log(ConsoleManager.LogType.Info, $"Added '{word}' into database.", LOGIN_INSTANCE_NAME); } - NewPathList = new List(); - - ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Get {0} elements from WrongPathList.", WrongPathList.Count), LOGIN_INSTANCE_NAME); - foreach (string word in WrongPathList) + catch (Exception ex) { - try - { - ConsoleManager.Log(ConsoleManager.LogType.Info, $"Delete '{word}' from database.", LOGIN_INSTANCE_NAME); - DatabaseManager.DeleteWord(word); - } - catch (Exception ex) - { - ConsoleManager.Log(ConsoleManager.LogType.Error, $"Can't delete '{word}' from database : " + ex.ToString(), LOGIN_INSTANCE_NAME); - } + ConsoleManager.Log(ConsoleManager.LogType.Error, $"Can't add '{word}' to database : " + ex.ToString(), LOGIN_INSTANCE_NAME); } - WrongPathList = new List(); + } + NewPathList = new List(); - ConsoleManager.Log(ConsoleManager.LogType.Info, "Automatic DB Update complete.", LOGIN_INSTANCE_NAME); + ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Get {0} elements from WrongPathList.", WrongPathList.Count), LOGIN_INSTANCE_NAME); + foreach (string word in WrongPathList) + { + try + { + ConsoleManager.Log(ConsoleManager.LogType.Info, $"Delete '{word}' from database.", LOGIN_INSTANCE_NAME); + DatabaseManager.DeleteWord(word); + } + catch (Exception ex) + { + ConsoleManager.Log(ConsoleManager.LogType.Error, $"Can't delete '{word}' from database : " + ex.ToString(), LOGIN_INSTANCE_NAME); + } } + WrongPathList = new List(); + + ConsoleManager.Log(ConsoleManager.LogType.Info, "Automatic DB Update complete.", LOGIN_INSTANCE_NAME); } } @@ -88,7 +92,7 @@ public static void AddPreviousPath(string word) PreviousPath.Add(word); } - public static void AddExclusion(string word) + public static void AddToWrongWord(string word) { if (!string.IsNullOrWhiteSpace(word)) WrongPathList.Add(word); @@ -101,7 +105,7 @@ private static List QualifyList(List input) { if (WrongPathList.Contains(o.Content)) ConsoleManager.Log(ConsoleManager.LogType.Warning, "Excluded '" + o.Content + "' because it is wrong word.", LOGIN_INSTANCE_NAME); - else if (!AllowDuplicate && PreviousPath.Contains(o.Content)) + else if (!CurrentConfig.ReturnMode && PreviousPath.Contains(o.Content)) ConsoleManager.Log(ConsoleManager.LogType.Warning, "Excluded '" + o.Content + "' because it is previously used.", LOGIN_INSTANCE_NAME); else result.Add(o); @@ -109,10 +113,9 @@ private static List QualifyList(List input) return result; } - public static void FindPath(CommonHandler.ResponsePresentedWord i, bool manner, bool preferEndWord) + public static void FindPath(CommonHandler.ResponsePresentedWord i, string missionChar, int wordPreference, bool useEndWord) { - bool canSubstitution = i.CanSubstitution; - if (canSubstitution) + if (i.CanSubstitution) ConsoleManager.Log(ConsoleManager.LogType.Info, $"Finding path for {i.Content} ({i.Substitution}).", LOGIN_INSTANCE_NAME); else ConsoleManager.Log(ConsoleManager.LogType.Info, $"Finding path for {i.Content}.", LOGIN_INSTANCE_NAME); @@ -125,21 +128,23 @@ public static void FindPath(CommonHandler.ResponsePresentedWord i, bool manner, var QualifiedEndList = new List(); try { - if (manner || preferEndWord) + if (wordPreference == Config.WORDPREFERENCE_BY_LENGTH_INDEX) { - NormalWord = DatabaseManager.FindWord(i, 0); - ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Find {0} Word.", NormalWord.Count), LOGIN_INSTANCE_NAME); - if (preferEndWord) - { - ConsoleManager.Log(ConsoleManager.LogType.Info, "Endword priority enabled.", LOGIN_INSTANCE_NAME); - EndWord = DatabaseManager.FindWord(i, 1); - ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Find {0} Word.", EndWord.Count), LOGIN_INSTANCE_NAME); - } + NormalWord = DatabaseManager.FindWord(i, missionChar, useEndWord ? 2 : 0); + ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Found {0} words.", NormalWord.Count), LOGIN_INSTANCE_NAME); } else { - NormalWord = DatabaseManager.FindWord(i, 2); - ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Find {0} Word.", NormalWord.Count), LOGIN_INSTANCE_NAME); + NormalWord = DatabaseManager.FindWord(i, missionChar, 0); + ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Found {0} normal words.", NormalWord.Count), LOGIN_INSTANCE_NAME); + // TODO: Attack word search here + // AttackWord = DatabaseManager.FindWord(i, 3); // 3 for only attack words + // ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Found {0} attack words.", NormalWord.Count), LOGIN_INSTANCE_NAME); + if (useEndWord) + { + EndWord = DatabaseManager.FindWord(i, missionChar, 1); + ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Find {0} end-words.", EndWord.Count), LOGIN_INSTANCE_NAME); + } } } catch (Exception e) @@ -150,7 +155,7 @@ public static void FindPath(CommonHandler.ResponsePresentedWord i, bool manner, UpdatedPath(null, new UpdatedPathEventArgs(FindResult.Error, 0, 0, 0, false)); } QualifiedNormalList = QualifyList(NormalWord); - if (preferEndWord) + if (useEndWord && wordPreference == Config.WORDPREFERENCE_BY_DAMAGE_INDEX) { QualifiedEndList = QualifyList(EndWord); if (QualifiedEndList.Count != 0) @@ -193,9 +198,9 @@ public static void FindPath(CommonHandler.ResponsePresentedWord i, bool manner, FinalList = QualifiedNormalList; } watch.Stop(); - ConsoleManager.Log(ConsoleManager.LogType.Warning, string.Format("Total {0} Path Ready. ({1}ms)", FinalList.Count, watch.ElapsedMilliseconds), LOGIN_INSTANCE_NAME); + ConsoleManager.Log(ConsoleManager.LogType.Info, string.Format("Total {0} words are ready. ({1}ms)", FinalList.Count, watch.ElapsedMilliseconds), LOGIN_INSTANCE_NAME); if (UpdatedPath != null) - UpdatedPath(null, new UpdatedPathEventArgs(FindResult.Normal, NormalWord.Count, FinalList.Count, Convert.ToInt32(watch.ElapsedMilliseconds), !manner)); + UpdatedPath(null, new UpdatedPathEventArgs(FindResult.Normal, NormalWord.Count, FinalList.Count, Convert.ToInt32(watch.ElapsedMilliseconds), useEndWord)); } public enum FindResult