public void TestAllSlotsContainsAll() { foreach (var slotObj in Enum.GetValues(typeof(Slots))) { var slot = (Slots)slotObj; if (slot == Slots.NONE || slot == Slots.LAST) { // Not real slots, skip these. continue; } Assert.That(AllSlots.Contains(slot)); } }
/// <summary> /// Invites a player to the game via battletag. /// </summary> /// <param name="playerName">Battletag of the player to invite. Is case sensitive. Ex: Tracer#1818</param> /// <param name="slot">Slot that the invited player will join.</param> /// <returns>Returns true if <paramref name="playerName"/> is a valid battletag.</returns> /// <exception cref="ArgumentNullException">Thrown if <paramref name="playerName"/> is null.</exception> public bool InvitePlayer(string playerName, int slot) { using (LockHandler.Interactive) { if (playerName == null) { throw new ArgumentNullException(nameof(playerName)); } if (!IsSlotValid(slot)) { throw new InvalidSlotException(slot); } if (IsSlotInQueue(slot)) { throw new InvalidSlotException("slot cannot be in queue."); } if (AllSlots.Contains(slot)) { return(false); } LeftClick(Interact.FindSlotLocation(slot)); LeftClick(Points.INVITE_VIA_BATTLETAG, 100); // click via battletag TextInput(playerName); Thread.Sleep(200); UpdateScreen(); if (Capture.CompareColor(Points.INVITE_INVITE, Colors.CONFIRM, Fades.CONFIRM)) { LeftClick(Points.INVITE_INVITE); // invite player //ResetMouse(); return(true); } else { LeftClick(Points.INVITE_BACK); // click back //ResetMouse(); return(false); } } }
private SlotIdentity GetSlotIdentity(int slot) { using (LockHandler.Passive) { if (!AllSlots.Contains(slot)) { return(null); } if (slot == 5 && OpenChatIsDefault) { Chat.CloseChat(); } if (slot == 0) { ResetMouse(); } Point origin = Point.Empty; int width = 0; int height = 0; if (IsSlotBlueOrRed(slot)) { width = 158; height = Distances.LOBBY_SLOT_HEIGHT; int comp = slot; if (IsSlotBlue(slot)) { origin = new Point(145, 239); } else if (IsSlotRed(slot)) { origin = new Point(372, 239); comp -= 6; } origin.Y += Distances.LOBBY_SLOT_DISTANCE * comp; } else if (IsSlotSpectatorOrQueue(slot)) { width = 158; height = Distances.LOBBY_SPECTATOR_SLOT_HEIGHT; origin = new Point(666, 245); int comp = slot; if (IsSlotSpectator(slot)) { origin.Y += FindSpectatorOffset(true); comp -= SpectatorID; } else if (IsSlotInQueue(slot)) { origin.Y -= Distances.LOBBY_QUEUE_OFFSET; comp -= QueueID; } origin.Y += Distances.LOBBY_SPECTATOR_SLOT_DISTANCE * comp; } UpdateScreen(); DirectBitmap identity = Capture.Clone(origin.X, origin.Y, width, height); if (slot == 5 && OpenChatIsDefault) { Chat.OpenChat(); } return(new SlotIdentity(identity, slot)); } }