Skip to content

Commit

Permalink
Hotfix2
Browse files Browse the repository at this point in the history
단어 조건 대신 이전에 입력된 단어가 그대로 넘어올 경우에도 제대로 핸들링할 수 있도록 수정
  • Loading branch information
hsheric0210 committed Apr 10, 2022
1 parent 922316b commit d785f57
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 16 deletions.
13 changes: 5 additions & 8 deletions Handlers/CommonHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,6 @@ private void CheckGameState(CheckType type, int watchdogID)
else if (!_isMyTurn)
{
ResponsePresentedWord presentedWord = GetPresentedWord();
if (presentedWord == null)
return;
if (presentedWord.CanSubstitution)
GetLogger(watchdogID).InfoFormat("My Turn. presented word is {0} (Subsitution: {1})", presentedWord.Content, presentedWord.Substitution);
else
Expand Down Expand Up @@ -321,12 +319,10 @@ private ResponsePresentedWord GetPresentedWord()
primary = content[0].ToString();
secondary = content[2].ToString();
}
else if (content.Length <= 1) // 가끔가다가 서버 랙때문에 '내가 입력해야할 단어의 조건' 대신 '이전 라운드에 입력되었었던 단어'가 나한테 넘어오는 경우가 있음
{
else if (content.Length <= 1)
primary = content;
}
else
return null;
else // 가끔가다가 서버 랙때문에 '내가 입력해야할 단어의 조건' 대신 '이전 라운드에 입력되었었던 단어'가 나한테 넘어오는 경우가 있음
primary = PathFinder.ConvertToWord(content);

return new ResponsePresentedWord(primary, hasSecondary, secondary);
}
Expand Down Expand Up @@ -407,8 +403,9 @@ public bool IsGameNotInProgress()

public bool IsGameNotInMyTurn()
{
string element = EvaluateJS("document.getElementsByClassName('game-input')[0]");
string displayOpt = EvaluateJS("document.getElementsByClassName('game-input')[0].style.display");
return string.IsNullOrWhiteSpace(displayOpt) || displayOpt.Equals("none", StringComparison.InvariantCultureIgnoreCase);
return string.Equals(element, "undefined", StringComparison.InvariantCultureIgnoreCase) || string.IsNullOrWhiteSpace(displayOpt) || displayOpt.Equals("none", StringComparison.InvariantCultureIgnoreCase);
}

public string GetGamePresentedWord()
Expand Down
15 changes: 7 additions & 8 deletions PathFinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using System.Collections.Concurrent;

namespace AutoKkutu
{
Expand All @@ -14,15 +15,11 @@ class PathFinder
private static readonly ILog Logger = LogManager.GetLogger("PathFinder");

public static List<string> EndWordList;

public static List<PathObject> FinalList;

public static List<string> PreviousPath = new List<string>();

public static List<string> UnsupportedPathList = new List<string>();
public static List<string> InexistentPathList = new List<string>();

public static List<string> NewPathList = new List<string>();
public static ConcurrentBag<string> InexistentPathList = new ConcurrentBag<string>();
public static ConcurrentBag<string> NewPathList = new ConcurrentBag<string>();

public static EventHandler UpdatedPath;

Expand Down Expand Up @@ -78,7 +75,7 @@ public static string AutoDBUpdate()
Logger.Error($"Can't add '{word}' to database", ex);
}
}
NewPathList = new List<string>();
NewPathList = new ConcurrentBag<string>();

InexistentPathCount = InexistentPathList.Count;
Logger.InfoFormat("Get {0} elements from WrongPathList.", InexistentPathCount);
Expand All @@ -93,7 +90,7 @@ public static string AutoDBUpdate()
Logger.Error($"Can't delete '{word}' from database", ex);
}
}
InexistentPathList = new List<string>();
InexistentPathList = new ConcurrentBag<string>();

string result = $"{AddedPathCount} of {NewPathCount} added, {RemovedPathCount} of {InexistentPathCount} removed";
Logger.Info($"Automatic DB Update complete ({result})");
Expand Down Expand Up @@ -202,6 +199,8 @@ public static void FindPath(CommonHandler.ResponsePresentedWord word, string mis
});
}

public static string ConvertToWord(string path) => (CurrentConfig.ReverseMode ? path.First() : path.Last()).ToString();

public enum FindResult
{
Normal,
Expand Down

0 comments on commit d785f57

Please sign in to comment.