예제 #1
0
        private void BtnKakaoLogout_Click(object sender, EventArgs e)
        {
            if (GlobalState.isLogin)
            {
                if (kakaoTalkManager.UsingApiEvent(KakaoTalkManager.HttpMethod.Post, GlobalApiEndPoint.KAKAO_URL_UNLINK))
                {
                    PictureUserImg.Image = null;
                    LabelUserName.Text   = "unKnown";

                    LabelState.ForeColor   = Color.DarkRed;
                    PictureState.ForeColor = Color.DarkRed;

                    LabelState.Text = "로그아웃";
                }
            }
            else
            {
                status = new StatusDisplay("중복 로그아웃은 할 수 없습니다.", StatusDisplay.enumType.Warning);
            }
        }
예제 #2
0
        // 자동 클릭 타이머
        private async void TimerAutoClick_Tick(object sender, EventArgs e)
        {
            // 클라이언트가 연결 되지 않았으면 리턴
            if (riotClientManager.isClientConnect != true)
            {
                //Console.WriteLine("AutoClick : 클라이언트 연결 끊김");
                return;
            }

            // AutoClick 로직
            try
            {
                //Console.WriteLine("AutoClick");

                // 현제 매칭 상태 찾기
                using (var jResult = await riotClientManager.UsingApiEventHttpMessage(HttpMethod.Get, GlobalApiEndPoint.LOBBY_MATCHMAKING_STATE))
                {
                    string sResult = JsonConvert.DeserializeObject(await jResult.Content.ReadAsStringAsync()).ToString();
                    //Console.WriteLine($"게임 상태 : {sResult}");
                    switch (sResult)
                    {
                    case "Reconnect":
                    case "None":
                    case "Lobby":
                    case "Matchmaking":
                        // 매칭 데이터 변수 초기화
                        if (matchingUserData.userSummonerDictionary.Count > 0)
                        {
                            //Console.WriteLine("Event : userSummonerDictionary 초기화!");
                            matchingUserData.userSummonerDictionary.Clear();
                        }
                        // 각 옵션 bool 변수 초기화
                        if (isAccept || isSendMessage || isPickMessage || isAutoRune || isMultiSearch)
                        {
                            //Console.WriteLine("Event : 상태 초기화!");
                            OptionDataInit();
                        }
                        break;

                    case "ReadyCheck":
                        // 수락 상태 전이면~
                        if (!isAccept)
                        {
                            //Console.WriteLine("Event : 수락 버튼 누르기!");
                            // 매칭 딜레이 옵션
                            if (GlobalState.isAcceptDelay)
                            {
                                TimerAutoClick.Stop();
                                Thread.Sleep(9900);
                                TimerAutoClick.Start();
                            }

                            // 수락 버튼 클릭
                            await riotClientManager.UsingApiEventHttpMessage(HttpMethod.Post, GlobalApiEndPoint.MATCHMAKING_CLICK);

                            // 수락 체크
                            isAccept = true;
                        }
                        break;

                    case "ChampSelect":

                        // 로그인 상태 && 매칭 정보 메시지를 보내지 않았다면
                        if (GlobalState.isLogin && !isSendMessage)
                        {
                            //Console.WriteLine("Event : 매칭 정보 메시지 보내기!");

                            // 매칭 완료 메시지 보내기
                            kakaoTalkManager.UsingApiEvent(KakaoTalkManager.HttpMethod.Post, GlobalApiEndPoint.KAKAO_URL_SEND_MATCHINGMESSAGE);

                            // 딕셔너리 초기화가 됐을 때
                            if (matchingUserData.userSummonerDictionary.Count == 0)
                            {
                                await MatchMakingDataSetting();

                                var messageJson = kakaoTalkManager.SendMessageJsonData();     // 기본 메시지 Json 얻기

                                // 보낼 메시지 내용 입력
                                messageJson.Add("text", $"매칭 타입 : {matchingUserData.queueType}\n" +
                                                $"진영 : {matchingUserData.myTeam}\n" +
                                                $"라인 : {matchingUserData.userSelectLines[matchingUserData.myPickCount]}\n" +
                                                $"픽 순서 : {matchingUserData.myPickCount + 1}픽");

                                // 매칭 데이터 메시지 보내기
                                kakaoTalkManager.UsingApiEvent(KakaoTalkManager.HttpMethod.Post, GlobalApiEndPoint.KAKAO_URL_SEND_PICKTURNMESSAGE, messageJson);
                            }

                            isSendMessage = true;
                        }

                        // 멀티 서치
                        else if (GlobalState.isMultiSearch && !isMultiSearch)
                        {
                            //Console.WriteLine("Event : 멀티 서치!");

                            // 멀티 서치 체크
                            isMultiSearch = true;

                            // op.gg 멀티 서치 url
                            string localPath = "https://www.op.gg/multi/query=";

                            // 매칭 데이터가 null 이면~
                            if (matchingUserData.userSummonerDictionary.Count == 0)
                            {
                                //Console.WriteLine("Event : 멀티 서치 하기전 딕셔너리 초기화!");
                                await MatchMakingDataSetting();
                            }

                            // 매칭 데이터의 소환사 아이다 값만 추출
                            foreach (var item in matchingUserData.userSummonerDictionary.Values)
                            {
                                //Console.WriteLine(item);
                                localPath += item + "%2C";
                            }

                            // 멀티 서치 홈페이지 실행
                            Process.Start(localPath);
                        }

                        // 픽 순서 체크
                        else if (GlobalState.isLogin && GlobalState.isPickTurn && !isPickMessage)
                        {
                            //Console.WriteLine("Event : 픽 시간 보내기!");

                            CurrentPickCheck();
                        }

                        // 룬 설정
                        else if (GlobalState.isAutoRune && !isAutoRune)
                        {
                            //Console.WriteLine("Event : 오토 룬 설정");

                            // 현재 픽한 챔피언 요청 (챔피언 별 Int값으로 return)
                            var message = await riotClientManager.UsingApiEventHttpMessage(HttpMethod.Get, GlobalApiEndPoint.CHAMPSELECT_CURRENT_DATA);

                            var championNum = Convert.ToInt32(await message.Content.ReadAsStringAsync());

                            // 0 = 봇, 을 제외한
                            if (championNum > 0)
                            {
                                //Console.WriteLine("Event : 오토 룬 설정중....!");

                                isAutoRune = true;

                                // 챔피언 Json파일에서 현재 챔피언 추출
                                var champion = ChampionData.ChampionJsonData[championNum.ToString()];
                                matchingUserData.currentChampion = champion.ToString();

                                // 크롤링할 페이지 URL
                                string opggUrl = "https://www.op.gg/champion/" + champion + "/statistics/";

                                // 크롤링 데이터 얻기
                                var json = riotRuneManager.GetRuneDataSetting(opggUrl);

                                // 데이터를 얻었다면~
                                if (json != null)
                                {
                                    // 룬 데이터 설정
                                    json.Add("name", champion);

                                    // 현재 접속된 소환사 룬 페이지 데이터 얻기 (룬 페이지가 없거나, 룬 페이지가 꽉 찼을 때 예외 처리)
                                    var currentRuneMessage = await riotClientManager.UsingApiEventHttpMessage(HttpMethod.Get, GlobalApiEndPoint.RUNE_PAGE_PAGES);

                                    var currentRune = JArray.Parse(await currentRuneMessage.Content.ReadAsStringAsync());
                                    var currentId   = currentRune[0]["id"].ToString();

                                    // 룬 페이지 지우기 (54~51 롤 기본 룬 페이지)
                                    if (Convert.ToInt32(currentId) > 54)
                                    {
                                        await riotClientManager.UsingApiEventHttpMessage(HttpMethod.Delete, GlobalApiEndPoint.RUNE_PAGE_PAGES + "/" + currentId);
                                    }

                                    // 1초 중지
                                    Thread.Sleep(1000);

                                    // 룬 페이지 업데이트
                                    await riotClientManager.UsingApiEventHttpMessage(HttpMethod.Post, GlobalApiEndPoint.RUNE_PAGE_PAGES, json);
                                }
                                else
                                {
                                    status = new StatusDisplay($"{champion}룬 설정중 오류가 발생했습니다...!", StatusDisplay.enumType.Error);
                                }
                            }
                        }

                        // 챔피언 스왑 판별
                        else if (isAutoRune)
                        {
                            //Console.WriteLine("Event : 스왑 판별");

                            // 현재 챔피언 데이터 얻기
                            var message1 = await riotClientManager.UsingApiEventHttpMessage(HttpMethod.Get, GlobalApiEndPoint.CHAMPSELECT_CURRENT_DATA);

                            var championNum1 = Convert.ToInt32(await message1.Content.ReadAsStringAsync());
                            var champion     = ChampionData.ChampionJsonData[championNum1.ToString()];

                            // 현재 챔피언이 이전과 동일한지 판별
                            if (!champion.ToString().Equals(matchingUserData.currentChampion))
                            {
                                isAutoRune = false;
                            }
                        }
                        break;

                    case "InProgress":
                        Console.WriteLine("Event : 게임 시작");
                        GameClientStartEvent();
                        break;
                    }
                }
            }
            catch
            {
            }
        }