public TextBox(int x, int y, int width = 100, string name = "", int tsize = 12, int limit = 16, bool encoded = false) : base(x, y, width, TextDisplay.GetHeight(12) + 4, new RGBColor(255, 255, 255)) { Limit = limit; Selected = false; Encoded = encoded; Text = new StringBuilder(); TitleText = new TextDisplay(2, -20, name, color: new RGBColor(10, 10, 10)); TextField = new TextDisplay(2, 2, "", size: tsize, color: new RGBColor(10, 10, 10)); SelectedMarket = new FilledRectangle(1, 1, 2, Height - 2, new RGBColor(0, 0, 0)) { Visible = false }; KeyBoardHandler = new KeyBoardHandler(); KeyBoardHandler.BindKey(new LoEKey() { Key = Keys.Back, Event = delegate { if (Text.Length > 0) { Text.Length--; } } }); AddChild(SelectedMarket); AddChild(TitleText); AddChild(TextField); }
internal bool ShowBastion() { string battlePath = $"{_imgDirPath}{_imgNameBattle}"; if (!File.Exists(battlePath)) { ConsoleWriter.WriteLineError($"Cannot find file {battlePath}"); return(false); } MouseHandler.SetCursorPosition(0, 0); Bitmap bitmapTemoin = new Bitmap(battlePath); int c = 0; debut: WindowHandler.RepositionRaidWindow(raidProcessId); if (c > 20) { throw new Exception("Cannot find the bastion. Number of attempts failed."); } Bitmap bitmapTest = ImgHandler.GetBitmap(_recBattle); if (ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed)) { KeyBoardHandler.SendKey(KEY_ESCAPE); Thread.Sleep(2000); c++; goto debut; } return(true); }
public async Task ShowAllOrders(long chatid, MessageEventArgs messageObject, bool isBuisnessman = false) { int countTask; BuisnessTaskDTO task; string message; // для бизнесменов if (isBuisnessman) { countTask = await provider.buisnessTaskService.CountTask(chatid); if (countTask == 0) { await client.SendTextMessageAsync(chatid, "Вы не создали ниодной задачи"); } task = await provider.buisnessTaskService.GetFirstElement(chatid); message = $"Заявка номер: {task.Id} \n" + $"Регион: {task.Region} \n" + $"Описание: {task.Description} \n" + $"Сумма: {task.Sum}"; await provider.showOrderService.SetDefaultProduct(chatid, true); await provider.showOrderService.ChangeMessageId(chatid, messageObject.Message.MessageId); await client.SendTextMessageAsync(chatid, message, 0, false, false, 0, KeyBoardHandler.CallBackShowOrdersForBuisnessman()); return; } countTask = await provider.buisnessTaskService.CountTask(); if (countTask == 0) { // отправлять await client.SendTextMessageAsync(chatid, "Еще нету созданных задач"); await provider.userService.ChangeAction(chatid, "NULL", 0); return; } task = await provider.buisnessTaskService.GetFirstElement(); message = $"Заявка номер: {task.Id} \n" + $"Регион: {task.Region} \n" + $"Описание: {task.Description} \n" + $"Сумма: {task.Sum}"; await provider.showOrderService.SetDefaultProduct(chatid); await provider.showOrderService.ChangeMessageId(chatid, messageObject.Message.MessageId); await client.SendTextMessageAsync(chatid, message, 0, false, false, 0, KeyBoardHandler.CallBackShowOrders()); }
void Start() { if (instance != null) { Destroy(this); } else { instance = this; } }
public static void Update(GameTime gameTime) { GameTime = gameTime; KeyBoardHandler.Update(); ControllerHandler.Update(); BaseConnectScreen.UpdateConnectSet(); if (!GameInstance.IsActive) { if (CurrentScreen.CanBePaused) { Core.SetScreen(Screen.CreatePauseScreen(CurrentScreen)); } } else { if (KeyBoardHandler.KeyPressed(KeyBindings.Escape) || ControllerHandler.ButtonDown(Buttons.Start)) { CurrentScreen.EscapePressed(); } } CurrentScreen?.Update(gameTime); if (CurrentScreen.CanChat) { if (KeyBoardHandler.KeyPressed(KeyBindings.Chat) || ControllerHandler.ButtonPressed(Buttons.RightShoulder)) { if (BaseJoinServerScreen.Online || Player.SandBoxMode || GameController.IS_DEBUG_ACTIVE) { SetScreen(Screen.CreateChatScreen((CurrentScreen))); } } } MainGameFunctions.FunctionKeys(); MusicManager.Update(gameTime); GameMessage.Update(); Controls.MakeMouseVisible(); MouseHandler.Update(); LoadingDots.Update(); ForcedCrash.Update(); ServersManager.Update(); }
public static void Update() { if (KeyBoardHandler.KeyDown(Core.KeyBindings.DebugControl) && KeyBoardHandler.KeyDown(Keys.C)) { //Debug.Print("CRASH IN: " + Delay.ToString(NumberFormatInfo.InvariantInfo)); Delay -= 0.1f; if (Delay <= 0f) { Crash(); } } else { Delay = 14f; } }
private bool GoToCampaignMap() { if (!ShowBastion()) { return(false); } KeyBoardHandler.SendKey(KEY_ENTER); if (!(ImgHandler.ReadBitmap(_recDungeonTitle).ToUpper() == "DUNGEONS")) { ConsoleWriter.WriteLineError("Cannot find the campaign. Abort."); return(false); } else { Console.WriteLine("--> Entering the campaign map..."); Thread.Sleep(1000); MouseHandler.MouseClick(812, 321); return(true); } }
private int AutoBattleForKeeps(int nbLoop, int compteur, string keepName) { MouseHandler.MouseWheelDown(25); Thread.Sleep(500); MouseHandler.MouseClick(1803, 380); ConsoleWriter.CountDown("Starting battle in {0} ", _battleCountDown); MouseHandler.MouseClick(1790, 550); DateTime dateStart = DateTime.Now; TimeSpan t; Bitmap bmpReplay = new Bitmap($"{_imgDirPath}{_imgNameReplay}"); Bitmap bmpLvlUp = new Bitmap($"{_imgDirPath}{_imgNameLevelUp}"); compteur++; do { WindowHandler.RepositionRaidWindow(raidProcessId); Thread.Sleep(500); var bmpTestReplay = ImgHandler.GetBitmap(_recReplay); var bmpTestLvlUp = ImgHandler.GetBitmap(_recLevelUp); if (!ImgHandler.AreBitmapsDifferent(bmpReplay, bmpTestReplay, RaidOptions.SavePicturesAllowed)) { t = DateTime.Now - dateStart; ConsoleWriter.KeepAwake(); if ((t.TotalMinutes > 20) && (RaidOptions.CheckMineAllowed || RaidOptions.CheckPitAllowed || RaidOptions.CheckRewardsAllowed)) { Console.Write("\nPausing the battle to check the bastion..."); Thread.Sleep(800); break; } if ((nbLoop != 0) && (compteur >= nbLoop)) { Console.Write("\nMax number of allowed battle reached..."); //switch (keepName) //{ // case "magic keep": // RaidOptions.MagicKeepAllowed = false; // break; // case "void keep": // RaidOptions.VoidKeepAllowed = false; // break; // case "spirit keep": // RaidOptions.SpiritKeepAllowed = false; // break; // case "force keep": // RaidOptions.ForceKeepAllowed = false; // break; // case "arcane keep": // RaidOptions.ArcaneKeepAllowed = false; // break; // default: // throw new ArgumentNullException($"Cannot find the keep '{keepName}' !"); //} break; } KeyBoardHandler.SendKey(KEY_R); compteur++; Thread.Sleep(1000); } else if (!ImgHandler.AreBitmapsDifferent(bmpLvlUp, bmpTestLvlUp, RaidOptions.SavePicturesAllowed)) { KeyBoardHandler.SendKey(KEY_ESCAPE); } if (nbLoop != 0) { Console.Write($"\r=> Starting run {compteur}/{nbLoop} "); } else { Console.Write($"\r=> Starting run {compteur} "); } Thread.Sleep(_battleIdle); } while (true); Console.WriteLine(); return(compteur); }
public async Task ReplenishAccount(MessageEventArgs messageObject) { string messageText = messageObject.Message.Text; long chatId = messageObject.Message.Chat.Id; int currStep = await provider.userService.GetCurrentActionStep(chatId); if (currStep == 1) { string cart = EasyPay.GetCart(); await client.SendTextMessageAsync(chatId, $"Внесите оплату на кошелек:{cart}\nПосле этого введите ваш номер чека"); await provider.userService.ChangeAction(chatId, "Пополнить баланс", ++currStep); return; } if (currStep == 2) { Regex isPayCorrect = new Regex(@"/^(\d){1,13}$/g"); if (isPayCorrect.IsMatch(messageText)) { int?sum = await EasyPay.IsPayCorrect(messageText); if (sum == null) { await client.SendTextMessageAsync(chatId, "Неправильный кошелек", 0, false, false, 0, KeyBoardHandler.Murkup_BuisnessmanMenu()); await provider.userService.ChangeAction(chatId, "NULL", 0); return; } UserDTO user = await provider.userService.FindById(chatId); user.balance = sum; await provider.userService.Update(user); await client.SendTextMessageAsync(chatId, "Вы успешно пополнили баланс", 0, false, false, 0, KeyBoardHandler.Murkup_BuisnessmanMenu()); } else { await client.SendTextMessageAsync(chatId, "Вы ввели некорректный формат чека", 0, false, false, 0, KeyBoardHandler.Murkup_BuisnessmanMenu()); await provider.userService.ChangeAction(chatId, "NULL", 0); return; } } }
public async Task CommandHandler_BuisnessRegistrationKorporativ(long chatid, string message, MessageEventArgs messageObject) { if (provider.userService == null) { await client.SendTextMessageAsync(chatid, "strange"); } int currentStep = await provider.userService.GetCurrentActionStep(chatid); UserDTO user = await provider.userService.FindById(chatid); DronDTO dron = new DronDTO(); if (currentStep == 1) { if (user == null) { await provider.userService.AuthenticateUser(chatid); } user.FIO = message; await provider.userService.Update(user); await provider.userService.ChangeAction(chatid, "Корпоративная бизнесс-регистрация", ++currentStep); await client.SendTextMessageAsync(chatid, "Введите номер телефона"); return; } if (currentStep == 2) { if (RegularExpression.IsTelephoneCorrect(message)) { user.Phone = message; user.BuisnesPrivilag = 1; await provider.userService.Update(user); await provider.userService.ChangeAction(chatid, "NULL", 0); await client.SendTextMessageAsync(chatid, "Вы успешно зарегистрировались", 0, false, false, 0, KeyBoardHandler.Murkup_BuisnessmanMenu()); await provider.managerPush.SendMessage(client, chatid); return; } else { await client.SendTextMessageAsync(chatid, "Вы ввели некорректный телефон,попробуйте еще раз"); } } }
public async override Task SendCallBack(CallbackQueryEventArgs callback) { long chatid = callback.CallbackQuery.Message.Chat.Id; string message = callback.CallbackQuery.Message.Text; string id = String.Empty; int index = message.IndexOf(":") + 1; for (int i = index; i < index + 10; i++) { id += message[i]; } long chatIdReceiver; if (!long.TryParse(id, out chatIdReceiver)) { throw new System.Exception("Incorrect parse"); } UserDTO user = await provider.userService.FindById(chatid); BuisnessTaskDTO task = await provider.buisnessTaskService.GetCurrentTask(chatid); // проверка пилот в диалоге if (await provider.hubService.PilotInDialog(chatIdReceiver)) { await client.SendTextMessageAsync(chatid, "Пилот в диалоге"); return; } string messageAnswer = $"{user.FIO} хочет с вами связаться \n " + $"Заявка в регионе {task.Region} \n" + $"Описание заявки: {task.Description} "; // попытка установки соеденения await provider.hubService.CreateDialog(chatid, chatIdReceiver); await client.SendTextMessageAsync(chatIdReceiver, messageAnswer, 0, false, false, 0, KeyBoardHandler.ChatConfirm()); }
public async Task StartCommenication(CallbackQueryEventArgs callback) { // кто шлёт каллбек получатель по умолчанию long chatid = callback.CallbackQuery.Message.Chat.Id; long[] chatIds = await provider.hubService.GetChatId(chatid); long chatIdReceiver = chatIds[0]; if (chatIds.Length == 0) { throw new System.Exception("Dialog is incorrect"); } //ПРОВЕРКА ВОЗМОЖНО БИЗНЕСМЕН В ДИАЛОГЕ await provider.hubService.ConfirmDialog(chatIdReceiver, chatid, true); List <string> Surname = await provider.userService.GetSurNames(chatid, chatIdReceiver); DateTime now = DateTime.Now; await File.AppendAllTextAsync($"{chatid}" + " " + $"{chatIdReceiver}" + ".txt", $"Начало диалога:\n{now}\n"); await client.SendTextMessageAsync(chatIdReceiver, "Подключение установлено", 0, false, false, 0, KeyBoardHandler.EndDialogForBuisnessMan()); await client.SendTextMessageAsync(chatid, "Подключение установлено", 0, false, false, 0, KeyBoardHandler.EndDialog()); }
public async ValueTask <bool> isAllowedUser(UserDTO user, int privil) { if (user == null) { return(false); } if (user.PilotPrivilag < privil) { await client.SendTextMessageAsync(user.ChatId, "Вам недоступна данная функция", 0, false, false, 0, KeyBoardHandler.Murkup_Start_AfterChange()); return(false); } return(true); }
public async override Task SendCallBack(CallbackQueryEventArgs callback) { long chatid = callback.CallbackQuery.Message.Chat.Id; string message; if (callback.CallbackQuery.Data == "ShowUserNext") { UserDTO user = await provider.showUserService.GetNextUser(chatid); if (user == null) { await client.SendTextMessageAsync(chatid, "Вы просматриваете последнего пользователя"); return; } int messageId = await provider.showUserService.GetMessageId(chatid); message = $"Пилот:{user.FIO} \n" + $"Телефон:{user.Phone}"; await client.EditMessageTextAsync(chatid, messageId + 2, message, 0, false, (InlineKeyboardMarkup)KeyBoardHandler.CallBackShowForUser()); return; } if (callback.CallbackQuery.Data == "ShowUserPrevious") { UserDTO user = await provider.showUserService.GetPreviousUser(chatid); if (user == null) { await client.SendTextMessageAsync(chatid, "Вы просматриваете первого пользователя"); return; } int messageId = await provider.showUserService.GetMessageId(chatid); message = $"Пилот:{user.FIO} \n" + $"Телефон:{user.Phone}"; await client.EditMessageTextAsync(chatid, messageId + 2, message, 0, false, (InlineKeyboardMarkup)KeyBoardHandler.CallBackShowForUser()); return; } }
public static void FunctionKeys() { if (KeyBoardHandler.KeyPressed(Core.KeyBindings.ScreenShot) && Core.CurrentScreen.CanTakeScreenshot) { CaptureScreen(); } if (KeyBoardHandler.KeyPressed(Core.KeyBindings.FullScreen) && Core.CurrentScreen.CanGoFullscreen) { ToggleFullScreen(); } if (KeyBoardHandler.KeyPressed(Core.KeyBindings.DebugControl)) { Core.GameOptions.ShowDebug = !Core.GameOptions.ShowDebug; Options.SaveOptions(Core.GameOptions); } if (KeyBoardHandler.KeyPressed(Core.KeyBindings.GUIControl)) { Core.GameOptions.ShowGUI = !Core.GameOptions.ShowGUI; Options.SaveOptions(Core.GameOptions); } if (KeyBoardHandler.KeyPressed(Core.KeyBindings.MuteMusic) && Core.CurrentScreen.CanMuteMusic) { Core.GameOptions.Muted = !Core.GameOptions.Muted; MusicManager.Mute(Core.GameOptions.Muted); SoundEffectManager.Mute(Core.GameOptions.Muted); Options.SaveOptions(Core.GameOptions); Core.CurrentScreen.ToggledMute(); } if (KeyBoardHandler.KeyPressed(Core.KeyBindings.LightKey)) { Core.GameOptions.LightingEnabled = !Core.GameOptions.LightingEnabled; } if (KeyBoardHandler.KeyDown(Core.KeyBindings.DebugControl)) { if (KeyBoardHandler.KeyPressed(Keys.F)) { TextureManager.TextureList.Clear(); } if (KeyBoardHandler.KeyPressed(Keys.S)) { Core.SetWindowSize(new Vector2(1200, 680)); } if (KeyBoardHandler.KeyPressed(Keys.L)) { Logger.DisplayLog = !Logger.DisplayLog; } } if (ControllerHandler.ButtonPressed(Buttons.Back, true)) { Core.GameOptions.GamePadEnabled = !Core.GameOptions.GamePadEnabled; Core.GameMessage.ShowMessage(Core.GameOptions.GamePadEnabled ? "Enabled XBOX 360 GamePad support." : "Disabled XBOX 360 GamePad support.", 12, FontManager.MainFont, Color.White); Options.SaveOptions(Core.GameOptions); } if (KeyBoardHandler.KeyPressed(Keys.B) && KeyBoardHandler.KeyDown(Core.KeyBindings.DebugControl)) { Core.GameOptions.DrawViewBox = !Core.GameOptions.DrawViewBox; } }
public async Task CommandHandler_PaidRegistrationWithInsurance(UserDTO user, string message, MessageEventArgs messageObject = null) { long chatid = user.ChatId; int currentStep = await provider.userService.GetCurrentActionStep(chatid); DronDTO dron = new DronDTO(); ProposalDTO proposal = await provider.proposalService.FindById(chatid); if (currentStep == 1) { user.FIO = message; await provider.userService.Update(user); await provider.userService.ChangeAction(chatid, "Платная регистрация со страховкой", ++currentStep); await client.SendTextMessageAsync(chatid, "Введите телефон"); return; } if (currentStep == 2) { if (RegularExpression.IsTelephoneCorrect(message)) { await provider.proposalService.Create(user); user.Phone = message; await provider.userService.Update(user); await provider.userService.ChangeAction(chatid, "Платная регистрация со страховкой", ++currentStep); await client.SendTextMessageAsync(chatid, "Введите марку дрона"); return; } else { await client.SendTextMessageAsync(chatid, "Вы ввели некорректный телефон,попробуйте еще раз"); return; } } if (currentStep == 3) { dron.Mark = message; await provider.dronService.Create(dron); await provider.userService.ChangeAction(chatid, "Платная регистрация со страховкой", ++currentStep); await client.SendTextMessageAsync(chatid, "Введите тип страховки"); return; } if (currentStep == 4) { proposal.TypeOfInsurance = message; await provider.proposalService.Update(proposal); await provider.userService.ChangeAction(chatid, "Платная регистрация со страховкой", ++currentStep); await client.SendTextMessageAsync(chatid, "Введите адрес"); return; } if (currentStep == 5) { proposal.Adress = message; await provider.proposalService.Update(proposal); await provider.userService.ChangeAction(chatid, "Платная регистрация со страховкой", ++currentStep); await client.SendTextMessageAsync(chatid, "Сбросьте вашу геопозицию"); return; } if (currentStep == 6) { if (messageObject.Message.Location != null) { proposal.longtitude = messageObject.Message.Location.Longitude; proposal.latitude = messageObject.Message.Location.Latitude; string realAdres = await GeolocateHandler.GetAddressFromCordinat(proposal.longtitude, proposal.latitude); proposal.Region = GetGeolocateRegion.GetRegion(realAdres); proposal.RealAdress = realAdres; await provider.proposalService.Update(proposal); await client.SendTextMessageAsync(chatid, "Ожидаем оплату,если все нормально - кидаем клаву с этими кнопками и если все оплатил кидаем в админ-уведомление" , 0, false, false, 0, KeyBoardHandler.PilotWithSubscribe_Murkup()); await provider.proposeHandler.ChangeProposeCount(); user.PilotPrivilag = 2; await provider.userService.Update(user); await provider.adminPush.MessageAboutRegistrationPilot(client, provider, chatid); await provider.userService.ChangeAction(chatid, "NULL", 0); // можно считать человека зарегистрированым только после оплаты , и определяем насколько он крут в плане полномочий string region = GetGeolocateRegion.GetRegion(realAdres); await provider.regionService.Create(region); await client.SendTextMessageAsync(chatid, "Вы успешно зарегистрировались"); return; } } }
public static void Draw() { if (BaseJoinServerScreen.Online && BaseConnectScreen.Connected) { if (KeyBoardHandler.KeyDown(Core.KeyBindings.OnlineStatus)) { var playerList = Core.ServersManager.PlayerCollection; int width = 1; int height = playerList.Count; if (height > 10) { width = Convert.ToInt32(Math.Ceiling(height / 10d)); } height = 10; int startX = Convert.ToInt32(Core.WindowSize.Width / 2 - ((width * 256) / 2)); int startY = 120; for (var x = 1; x <= width; x++) { for (var y = 1; y <= height; y++) { Canvas.DrawRectangle(new Rectangle(startX + (x - 1) * 256, startY + (y - 1) * 40, 256, 40), new Color(0, 0, 0, 150)); if (playerList.Count - 1 >= (x - 1) * 10 + (y - 1)) { string name = playerList[(x - 1) * 10 + (y - 1)].Name; Color c = Color.White; if (playerList[(x - 1) * 10 + (y - 1)].ServersID == Core.ServersManager.ID) { name = Core.Player.Name; c = BaseChat.OwnColor; } else { if (Core.Player.IsGameJoltSave) { string GJID = playerList[(x - 1) * 10 + (y - 1)].GameJoltId; if (!string.IsNullOrEmpty(GJID) && Core.GameJoltSave.Friends.Contains(GJID)) { c = BaseChat.FriendColor; } } } Core.SpriteBatch.DrawString(FontManager.MainFont, name, new Vector2(startX + (x - 1) * 256 + 4, startY + (y - 1) * 40 + 6), c); switch (playerList[(x - 1) * 10 + (y - 1)].BusyType) { case 1: //Battle Core.SpriteBatch.Draw(TextureManager.GetTexture("Textures|emoticons", new Rectangle(48, 16, 16, 16), ""), new Rectangle(startX + (x - 1) * 256 + 222, startY + (y - 1) * 40 + 6, 32, 32), Color.White); break; case 2: //Chat Core.SpriteBatch.Draw(TextureManager.GetTexture("Textures|emoticons", new Rectangle(0, 0, 16, 16), ""), new Rectangle(startX + (x - 1) * 256 + 222, startY + (y - 1) * 40 + 6, 32, 32), Color.White); break; case 3: //AFK Core.SpriteBatch.Draw(TextureManager.GetTexture("Textures|emoticons", new Rectangle(0, 48, 16, 16), ""), new Rectangle(startX + (x - 1) * 256 + 222, startY + (y - 1) * 40 + 6, 32, 32), Color.White); break; } } Canvas.DrawBorder(3, new Rectangle(startX + (x - 1) * 256, startY + (y - 1) * 40, 256, 40), new Color(220, 220, 220)); } } string serverName = BaseJoinServerScreen.SelectedServer.GetName(); int plateLength = 256; if (FontManager.MainFont.MeasureString(serverName).X > 230f) { plateLength = 26 + Convert.ToInt32(FontManager.MainFont.MeasureString(serverName).X); } Canvas.DrawRectangle(new Rectangle(Convert.ToInt32(Core.WindowSize.Width / 2 - plateLength / 2), 80, plateLength, 40), new Color(0, 0, 0, 150)); Core.SpriteBatch.DrawString(FontManager.MainFont, serverName, new Vector2(Convert.ToInt32(Core.WindowSize.Width / 2 - plateLength / 2) + 4, 80 + 6), BaseChat.ServerColor); Canvas.DrawBorder(3, new Rectangle(Convert.ToInt32(Core.WindowSize.Width / 2 - plateLength / 2), 80, plateLength, 40), new Color(220, 220, 220)); } } }
public async Task SosHandler(MessageEventArgs messageObject) { long chatid = messageObject.Message.Chat.Id; string message = messageObject.Message.Text; int currStep = await provider.userService.GetCurrentActionStep(chatid); SosDTO sos = await provider.sosTableServide.FindById(chatid); if (currStep == 0) { await provider.userService.ChangeAction(chatid, "SOS", ++currStep); return; } if (currStep == 1) { if (message == "Страховой случай" || message == "Аварийный случай") { if (message == "Страховой случай") { await client.SendTextMessageAsync(chatid, "Не указано откуда брать данные и куда их слать"); return; } else if (message == "Аварийный случай") { await provider.sosTableServide.Create(new SosDTO { ChatId = chatid, Type = 1 }); await client.SendTextMessageAsync(chatid, "Сбросьте вашу геолокацию", 0, false, false, 0, KeyBoardHandler.Markup_Back_From_First_Action()); await provider.userService.ChangeAction(chatid, "SOS", ++currStep); return; } } else { await client.SendTextMessageAsync(chatid, "Вы выбрали несуществующий вариант"); } } if (currStep == 2) { if (sos.Type == 1) { if (messageObject.Message.Location != null) { sos.lautitude = messageObject.Message.Location.Latitude; sos.longtitude = messageObject.Message.Location.Longitude; await provider.sosTableServide.Update(sos); List <long> lstId = await provider.userService.GetUsersIdByRegion(chatid); UserDTO user = await provider.userService.FindById(chatid); string _message = $"У пилота {user.ChatId} проблемы \n" + $"свяжитесь с ним по телефону {user.Phone} \n " + $"Могу добавить еще описание проблемы"; foreach (var i in lstId) { await client.SendTextMessageAsync(i, _message); await client.SendLocationAsync(chatid, sos.lautitude, sos.longtitude); } await provider.userService.ChangeAction(chatid, "NULL", 0); await client.SendTextMessageAsync(chatid, "Мы разослали письмо о помощи нашем партнерам"); return; } } } }
public async Task ShowOffersCallBack(CallbackQueryEventArgs callback) { long chatid = callback.CallbackQuery.Message.Chat.Id; ShowOrdersDTO order = await provider.showOrderService.CurrentProduct(chatid); int currProductId = order.CurrentProductId; BuisnessTaskDTO task = await provider.buisnessTaskService.FindTaskByTaskId(currProductId); if (task == null) { throw new System.Exception("task cannot be null"); } List <UserDTO> offers = await provider.offerService.GetUsersOffer(currProductId); if (offers.Count == 0) { await client.SendTextMessageAsync(chatid, "Вам не поступало заявлений"); return; } offers.ForEach(async(item) => { string message = $"ChatId пользователя: {item.ChatId}\n " + $"Телефон:{item.FIO}"; await client.SendTextMessageAsync(chatid, message, 0, false, false, 0, KeyBoardHandler.InviteUserToDialog()); }); }
public void Update() { if (Showing) { ResetCursor(); if (PositionY <= Core.WindowSize.Height - 160f) { if (!_through) { if (Text.Length > _currentChar) { if (_delay <= 0f) { if (Text[_currentChar].ToString(NumberFormatInfo.InvariantInfo) == "\\") { if (Text.Length > _currentChar + 1) { _showText[_currentLine] += Text[_currentChar + 1]; _currentChar += 2; } else { _currentChar += 1; } } else { switch (Text[_currentChar]) { case '~': if (_currentLine == 1) { _through = true; } else { _currentLine += 1; } break; case '*': _currentLine = 0; _clearNextLine = true; _through = true; break; case '%': ProcessChooseBox(); break; default: _showText[_currentLine] += Text[_currentChar]; break; } _currentChar += 1; } if (KeyBoardHandler.KeyDown(Core.KeyBindings.Enter1) || KeyBoardHandler.KeyDown(Core.KeyBindings.Enter2) || MouseHandler.ButtonDown(MouseHandler.MouseButtons.LeftButton) == true || ControllerHandler.ButtonDown(Buttons.A) == true || ControllerHandler.ButtonDown(Buttons.B) == true) { _delay = 0f; } else { _delay = GetTextSpeed(); } } else { _delay -= 0.1f; } } else { _through = true; } } else { if (Controls.Accept() || Controls.Dismiss()) { SoundEffectManager.PlaySound("select"); if (Text.Length <= _currentChar) { if (CanProceed == true) { Showing = false; ResetCursor(); if ((FollowUp != null)) { FollowUp.Invoke(); FollowUp = null; } TextFont = FontManager.GetFontContainer("textfont"); TextColor = DefaultColor; if (_doReDelay == true) { ReDelay = 1f; } } } else { if (_clearNextLine == true) { _showText[0] = ""; } else { _showText[0] = _showText[1]; } _showText[1] = ""; _through = false; _clearNextLine = false; } } } } else { float ySpeed = 3.5f; switch (TextSpeed) { case 1: ySpeed = 3.5f; break; case 2: ySpeed = 4.5f; break; case 3: ySpeed = 6.5f; break; } PositionY -= ySpeed; } } else { if (ReDelay > 0f) { ReDelay -= 0.1f; if (ReDelay <= 0f) { ReDelay = 0f; } } } }
internal int RunDurhamForest(int nbLoop) { int compteur = 0; DateTime dateStart = DateTime.Now; TimeSpan t; Bitmap bmpReplay = new Bitmap($"{_imgDirPath}{_imgNameReplay}"); Bitmap bmpLvlUp = new Bitmap($"{_imgDirPath}{_imgNameLevelUp}"); Console.Write("-> Starting the Durham Forest run "); if (nbLoop != 0) { Console.Write($"({nbLoop} run left)"); } Console.WriteLine(); Thread.Sleep(1000); if (GoToCampaignMap()) { Console.WriteLine("---> Entering durham forest..."); Thread.Sleep(1000); MouseHandler.MouseDrag(1767, 327, 905, 467); Thread.Sleep(2000); MouseHandler.MouseClick(1239, 271); Thread.Sleep(2000); MouseHandler.MouseClick(1815, 130); ConsoleWriter.CountDown("Starting battle in {0} ", _battleCountDown); MouseHandler.MouseClick(1790, 550); compteur++; do { Thread.Sleep(1000); WindowHandler.RepositionRaidWindow(raidProcessId); Thread.Sleep(500); var bmpTestReplay = ImgHandler.GetBitmap(_recReplay); var bmpTestLvlUp = ImgHandler.GetBitmap(_recLevelUp); if (!ImgHandler.AreBitmapsDifferent(bmpReplay, bmpTestReplay, RaidOptions.SavePicturesAllowed)) { t = DateTime.Now - dateStart; ConsoleWriter.KeepAwake(); if ((t.TotalMinutes > 20) && (RaidOptions.CheckMineAllowed || RaidOptions.CheckPitAllowed || RaidOptions.CheckRewardsAllowed)) { Console.Write("\nPausing the battle to check the bastion..."); Thread.Sleep(800); break; } if ((nbLoop != 0) && (compteur >= nbLoop)) { Console.Write("\nMax number of allowed battle reached..."); RaidOptions.DurhamForestAllowed = false; break; } KeyBoardHandler.SendKey(KEY_R); compteur++; Thread.Sleep(1000); } else if (!ImgHandler.AreBitmapsDifferent(bmpLvlUp, bmpTestLvlUp, RaidOptions.SavePicturesAllowed)) { KeyBoardHandler.SendKey(KEY_ESCAPE); } if (nbLoop != 0) { Console.Write($"\r=> Starting run {compteur}/{nbLoop} "); } else { Console.Write($"\r=> Starting run {compteur} "); } Thread.Sleep(_battleIdle); } while (true); Console.WriteLine(); } if (nbLoop != 0) { return(nbLoop - compteur); } else { return(nbLoop); } }
internal void CheckPlaytimeRewards() { //daily playtime reward string imgPath = $"{_imgDirPath}{_imgNameReward}"; Console.WriteLine("-> Starting to check the playtime rewards..."); if (!File.Exists(imgPath)) { ConsoleWriter.WriteLineWarning($"Cannot find file {imgPath}. Phase skipped."); return; } WindowHandler.RepositionRaidWindow(raidProcessId); MouseHandler.SetCursorPosition(0, 0); Bitmap bitmapTemoin = new Bitmap(imgPath); Bitmap bitmapTest = ImgHandler.GetBitmap(_recReward); //bitmapTest.Save("RewardRedDot.bmp"); Thread.Sleep(100); if (!ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed)) { ConsoleWriter.WriteLineInformation("Playtime rewards found. Let's get them."); MouseHandler.MouseClick(1853, 486); Thread.Sleep(100); MouseHandler.MouseClick(1038, 404); Thread.Sleep(100); MouseHandler.MouseClick(1148, 399); Thread.Sleep(100); MouseHandler.MouseClick(1259, 403); Thread.Sleep(100); MouseHandler.MouseClick(1370, 406); Thread.Sleep(100); MouseHandler.MouseClick(1474, 399); Thread.Sleep(100); MouseHandler.MouseClick(1591, 402); Thread.Sleep(100); } else { Console.WriteLine("No rewards found."); Thread.Sleep(100); } ShowBastion(); //daily login rewards imgPath = $"{_imgDirPath}{_imgDailyReward}"; Console.WriteLine("-> Starting to check the daily login rewards..."); if (!File.Exists(imgPath)) { ConsoleWriter.WriteLineWarning($"Cannot find file {imgPath}. Phase skipped."); Thread.Sleep(500); return; } WindowHandler.RepositionRaidWindow(raidProcessId); MouseHandler.SetCursorPosition(0, 0); bitmapTemoin = new Bitmap(imgPath); bitmapTest = ImgHandler.GetBitmap(_recDailyReward); if (!ImgHandler.AreBitmapsDifferent(bitmapTemoin, bitmapTest, RaidOptions.SavePicturesAllowed)) { Console.WriteLine("Daily rewards found. Let's go get them."); MouseHandler.MouseClick(717, 314); MouseHandler.MouseClick(744, 110); KeyBoardHandler.SendKey(KEY_ESCAPE); } else { Console.WriteLine("No rewards found."); Thread.Sleep(500); } }
public async Task Response(MessageEventArgs messageObject) { if (provider == null) { await client.SendTextMessageAsync(messageObject.Message.Chat.Id, "оч странно"); } long chatid = messageObject.Message.Chat.Id; int currStep = await provider.userService.GetCurrentActionStep(chatid); string messageText = messageObject.Message.Text; int countUser; string message; if (currStep == 1) { await client.SendTextMessageAsync(chatid, "Выберите один из вариантов", 0, false, false, 0, KeyBoardHandler.ShowPartners()); await provider.userService.ChangeAction(chatid, "Партнеры рядом", ++currStep); return; } if (currStep == 2) { if (messageText == "Просмотр пилотов") { await provider.userService.ChangeAction(chatid, "Партнеры рядом", ++currStep); await client.SendTextMessageAsync(chatid, "Выберите один из вариантов", 0, false, false, 0, KeyBoardHandler.ShowPatnersPilot()); return; } else { await client.SendTextMessageAsync(chatid, "Вы ввели некорректную команду"); } } if (currStep == 3) { if (messageText == "Из геолокации" || messageText == "Выбрать по региону") { countUser = await provider.showUserService.CountUsersAsync(); if (messageText == "Из геолокации") { if (countUser > 1) { ProposalDTO proposal = await provider.proposalService.FindById(chatid); UserDTO user = await provider.showUserService.GetFirstUserForCommand(chatid, proposal.Region); message = $"Пилот:{user.FIO} \n" + $"Телефон:{user.Phone}"; await provider.showUserService.ChangeMessageId(chatid, messageObject.Message.MessageId); await client.SendTextMessageAsync(chatid, "Вы можете просмотреть пользователей", 0, false, false, 0, KeyBoardHandler.Markup_Back_From_First_Action()); await client.SendTextMessageAsync(chatid, message, 0, false, false, 0, KeyBoardHandler.CallBackShowForUser()); return; } else if (countUser == 1) { await client.SendTextMessageAsync(chatid, "К сожалению,вы зарегестрированы один", 0, false, false, 0, KeyBoardHandler.Markup_Back_From_First_Action()); return; } } if (messageText == "Выбрать по региону") { if (countUser > 1) { GenerateButtons buttons = new GenerateButtons(client, provider); ReplyKeyboardMarkup keyboard = await buttons.GenerateKeyBoards(); await client.SendTextMessageAsync(chatid, "Выберите интересующий вас регион", 0, false, false, 0, keyboard); await provider.userService.ChangeAction(chatid, "Партнеры рядом", ++currStep); return; } else if (countUser == 1) { await client.SendTextMessageAsync(chatid, "Вы один зарегестрированный пилот", 0, false, false, 0, KeyBoardHandler.Markup_Back_From_First_Action()); return; } } } else { await client.SendTextMessageAsync(chatid, "Вы выбрали несуществующий вариант"); await client.SendTextMessageAsync(chatid, "Попробуйте еще раз"); } } if (currStep == 4) { List <string> regions = await provider.regionService.GetAllRegions(); if (regions.Contains(messageText)) { UserDTO user = await provider.showUserService.GetFirstUserForCommand(chatid, messageText); await provider.showUserService.ChangeMessageId(chatid, messageObject.Message.MessageId); message = $"Пилот:{user.FIO} \n" + $"Телефон:{user.Phone}"; await client.SendTextMessageAsync(chatid, "Вы можете просмотреть пользователей", 0, false, false, 0, KeyBoardHandler.Markup_Back_From_First_Action()); await client.SendTextMessageAsync(chatid, message, 0, false, false, 0, KeyBoardHandler.CallBackShowForUser()); return; } else { await client.SendTextMessageAsync(chatid, "Вы выбрали несуществующий регион"); } } }
public async Task EndChat(long chatid) { if (!await provider.hubService.IsChatActive(chatid)) { await client.SendTextMessageAsync(chatid, "У вас нету активных соеденений"); await ExceptionMessage.SendExceptionMessage(client, "Возможно ошибка с закрытием диалога"); } long[] chatIds = await provider.hubService.GetChatId(chatid); await provider.hubService.StopChat(chatid); await client.SendTextMessageAsync(chatid, "Выберите один из вариантов", 0, false, false, 0, KeyBoardHandler.Murkup_Start_AfterChange()); await client.SendTextMessageAsync(chatIds[0], "Выберите один из вариантов", 0, false, false, 0, KeyBoardHandler.Murkup_Start_AfterChange()); }
public async Task ShowOrdersCallBack(CallbackQueryEventArgs callback) { long chatid = callback.CallbackQuery.Message.Chat.Id; if (callback.CallbackQuery.Data == "RequestTask") { UserDTO user = await provider.userService.FindById(chatid); if (user == null) { throw new System.Exception("User cannot be null"); } } if (callback.CallbackQuery.Data == "Next") { BuisnessTaskDTO task = await provider.showOrderService.GetNextProduct(chatid); if (task == null) { await client.SendTextMessageAsync(chatid, "Это была последняя задача"); return; } int messageId = await provider.showOrderService.GetMessageId(chatid); string message = $"Заявка номер: {task.Id} \n" + $"Регион: {task.Region} \n" + $"Описание: {task.Description} \n" + $"Сумма: {task.Sum}"; await client.EditMessageTextAsync(chatid, messageId + 1, message, 0, false, (InlineKeyboardMarkup)KeyBoardHandler.CallBackShowOrders()); } if (callback.CallbackQuery.Data == "Back") { BuisnessTaskDTO task = await provider.showOrderService.GetPreviousProduct(chatid); if (task == null) { await client.SendTextMessageAsync(chatid, "Это первая задача"); return; } int messageId = await provider.showOrderService.GetMessageId(chatid); string message = $"Заявка номер: {task.Id} \n" + $"Регион: {task.Region} \n" + $"Описание: {task.Description} \n" + $"Сумма: {task.Sum}"; await client.EditMessageTextAsync(chatid, messageId + 1, message, 0, false, (InlineKeyboardMarkup)KeyBoardHandler.CallBackShowOrders()); } }