// TODO: Re-do the equipment system. private void ReadEquipment(Enums.Classes targetClass, string equipment) { if (targetClass >= 0 && targetClass <= Enums.Classes.Heavy) { string[] weaponCodes = equipment.Split(','); for (byte i = 0; i < Equipment.MAX_SLOTS; i++) { if (weaponCodes.Length <= i) { Equipment.Add(targetClass, i, null); } else { Item item = Get(weaponCodes[i]); if (item != null) { Equipment.Add(targetClass, i, item); } else { for (byte j = 0; j < DEFAULT_ITEMS.Length; j++) { if (weaponCodes[i].ToUpper() == DEFAULT_ITEMS[j].ToUpper()) { Equipment.Add(targetClass, i, new Item(-1, 0, DEFAULT_ITEMS[j], 0)); break; } } } } } } }
public static Entity GenerateHeroPower(Enums.Classes theClass) { switch (theClass) { case Enums.Classes.Priest: return(new Entity { CardId = "CS1h_001", IsHeroPower = true }); case Enums.Classes.Warlock: return(new Entity { CardId = "CS2_056", IsHeroPower = true }); case Enums.Classes.Druid: case Enums.Classes.Hunter: case Enums.Classes.Mage: case Enums.Classes.Paladin: case Enums.Classes.Rouge: case Enums.Classes.Shaman: case Enums.Classes.Warrior: default: throw new ArgumentOutOfRangeException(nameof(theClass), theClass, null); } }
public Item Get(Enums.Classes Class, byte slot) { Item output = null; switch (Class) { case Enums.Classes.Engineer: { if (Engeneer.ContainsKey(slot)) { Engeneer.TryGetValue(slot, out output); } break; } case Enums.Classes.Medic: { if (Medic.ContainsKey(slot)) { Medic.TryGetValue(slot, out output); } break; } case Enums.Classes.Sniper: { if (Sniper.ContainsKey(slot)) { Sniper.TryGetValue(slot, out output); } break; } case Enums.Classes.Assault: { if (Assault.ContainsKey(slot)) { Assault.TryGetValue(slot, out output); } break; } case Enums.Classes.Heavy: { if (Heavy.ContainsKey(slot)) { Heavy.TryGetValue(slot, out output); } break; } } return(output); }
public Item Get(Enums.Classes Class, string weaponCode) { Item output = null; switch (Class) { case Enums.Classes.Engineer: { try { output = Engeneer.Select(n => n.Value).Where(n => n.ItemCode == weaponCode).First(); } catch { output = null; } break; } case Enums.Classes.Medic: { try { output = Medic.Select(n => n.Value).Where(n => n.ItemCode == weaponCode).First(); } catch { output = null; } break; } case Enums.Classes.Sniper: { try { output = Sniper.Select(n => n.Value).Where(n => n.ItemCode == weaponCode).First(); } catch { output = null; } break; } case Enums.Classes.Assault: { try { output = Assault.Select(n => n.Value).Where(n => n.ItemCode == weaponCode).First(); } catch { output = null; } break; } case Enums.Classes.Heavy: { try { output = Heavy.Select(n => n.Value).Where(n => n.ItemCode == weaponCode).First(); } catch { output = null; } break; } } return(output); }
public void Spawn(Enums.Classes Class) { Health = 1000; IsAlive = true; this.Class = Class; if (User.Room.Mode == Mode.Explosive) { CanSpawn = false; } }
public void Spawn(Enums.Classes Class) { Health = 1000; IsAlive = true; this.Class = Class; ItemsPlanted = 0; InVehicle = false; VehicleSeatId = -1; VehicleId = -1; if (User.Room.Mode == Mode.Explosive) { CanSpawn = false; } SpawnProtection = 3000; }
public static List <Entity> GeneratePlayerAndOpponentWithHeroPowers(Enums.Classes playerClass, Enums.Classes opponentClass, bool playerHasCoin) { var entities = new List <Entity>(); var player = GeneratePlayer(playerHasCoin); var opponent = GenerateOpponent(!playerHasCoin); var playerHeroPower = GenerateHeroPower(playerClass); playerHeroPower.Tags.Add(GameTag.CONTROLLER, player.Tags[GameTag.PLAYER_ID]); var opponentHeroPower = GenerateHeroPower(opponentClass); opponentHeroPower.Tags.Add(GameTag.CONTROLLER, opponent.Tags[GameTag.PLAYER_ID]); entities.Add(player); entities.Add(playerHeroPower); entities.Add(opponent); entities.Add(opponentHeroPower); return(entities); }
public async Task <List <SearchResult> > Source(Enums.Classes id) { var request = new TopRequest() { By = "Classification", Class = id }; if (!_settings.Cache.Database) { return(await _repo.TopImageSearchAsync(request, CancellationToken.None)); } return(await _memoryCache.GetOrCreateAsync($"top:classification:{id}", async cacheEntry => { cacheEntry.SetAbsoluteExpiration(new TimeSpan(0, 60, 0)); return await _repo.TopImageSearchAsync(request, CancellationToken.None); })); }
public static ImageDetail ProcessImageElement(this IScrapeProcessor processor, IElement element, Enums.Sources source, Enums.Classes classification = Enums.Classes.Any) { var image = new ImageDetail { IndexSource = source }; if (classification != Enums.Classes.Any) { image.Class = classification; } if (!processor.GetImageUrl(element, image)) { return(null); } processor.GetWhoStamp(element, image); processor.GetResolution(element, image); processor.GetTags(element, image); try { image.ImageId = image.ImageUrl?.Split('/')?.Last()?.Split('.')?.First() ?? ""; image.ImageExtension = image.ImageUrl?.Split('/')?.Last()?.Split('.')?.Last() ?? ""; } catch { // pass } return(image); }
public bool Add(Enums.Classes Class, byte slot, Item item) { bool isAdded = false; Remove(Class, slot); switch (Class) { case Enums.Classes.Engineer: { if (!Engeneer.ContainsKey(slot)) { isAdded = Engeneer.TryAdd(slot, item); } break; } case Enums.Classes.Medic: { if (!Medic.ContainsKey(slot)) { isAdded = Medic.TryAdd(slot, item); } break; } case Enums.Classes.Sniper: { if (!Sniper.ContainsKey(slot)) { isAdded = Sniper.TryAdd(slot, item); } break; } case Enums.Classes.Assault: { if (!Assault.ContainsKey(slot)) { isAdded = Assault.TryAdd(slot, item); } break; } case Enums.Classes.Heavy: { if (!Heavy.ContainsKey(slot)) { isAdded = Heavy.TryAdd(slot, item); } break; } } if (isAdded) { item.Equiped[(byte)Class] = (sbyte)slot; } return(isAdded); }
private int ObterPassageirosPorClasse(IEnumerable <Passenger> passengers, Enums.Classes classePassageiros) { return(passengers .Where(w => w.Pclass == (int)classePassageiros) .Count()); }
public void Process(Enums.Sources source, Enums.Classes classification = Enums.Classes.Any) { var url = ""; string board; CurrentBoard = source; try { //Get the board URL. board = Core.Constants.SourceUrls[source]; Helpers.LogMessage($"Starting Board: {board}"); //loop pages for (var x = 1; x <= Settings.MaxPages; x++) { if (x != 1) { url = $"{x}"; } //Helpers.LogMessage($"Getting Page Contents for {url}"); var pageContents = Helpers.GetPageContents(board + url); // - - get threads on pages //Helpers.LogMessage($"Getting Page Threads"); var threads = GetPageThreads(pageContents); //Helpers.LogMessage($"Threads found :: {threads.Count}"); //loop the threads on the this page foreach (var thread in threads) { //generate thread url var threadUrl = !string.IsNullOrWhiteSpace(Constants.ThreadUrlCleanup[source]) ? thread.Replace(Constants.ThreadUrlCleanup[source], "") : thread; //Helpers.LogMessage($"Getting Thread Contents :: {threadUrl}"); var threadContents = Helpers.GetPageContents(board + threadUrl); //Helpers.LogMessage($"Processing Post"); var post = GetPagePost(threadContents); //Helpers.LogMessage($"Processing Images"); var image = this.ProcessImageElement(post, source); if (string.IsNullOrWhiteSpace(image?.ImageId)) { continue; } // - - - - check if images have been scrapped before if (ScrapeRepositories.ImageScrapeRepository .ExistsAsync(image.ImageId, image.IndexSource, CancellationToken.None).GetAwaiter() .GetResult()) { continue; } Helpers.LogMessage($"Image not in Scrape Repo {image.ImageId}"); ScrapeRepositories.Queue.Enqueue(image); } } } catch (Exception ex) { Console.WriteLine(ex); } }
public void ThenPlayerClassShouldBe(Enums.Classes c) { Assert.Equal(c, generatedMetadata.PlayerClass); }
public void ThenOpponentClassShouldBe(Enums.Classes c) { Assert.Equal(c, generatedMetadata.OpponentClass); }
public static ReplayKeyPoint GenerateKeyPointContainingBothPlayersAndTheirHeroPowers(Enums.Classes playerClass, Enums.Classes opponentClass, bool playerHasCoin) { var entities = GeneratePlayerAndOpponentWithHeroPowers(playerClass, opponentClass, playerHasCoin); return(new ReplayKeyPoint { Data = entities.ToArray() }); }
public void Remove(Enums.Classes Class, byte slot) { Item itm = null; switch (Class) { case Enums.Classes.Engineer: { if (Engeneer.ContainsKey(slot)) { Engeneer.TryRemove(slot, out itm); } break; } case Enums.Classes.Medic: { if (Medic.ContainsKey(slot)) { Medic.TryRemove(slot, out itm); } break; } case Enums.Classes.Sniper: { if (Sniper.ContainsKey(slot)) { Sniper.TryRemove(slot, out itm); } break; } case Enums.Classes.Assault: { if (Assault.ContainsKey(slot)) { Assault.TryRemove(slot, out itm); } break; } case Enums.Classes.Heavy: { if (Heavy.ContainsKey(slot)) { Heavy.TryRemove(slot, out itm); } break; } } if (itm != null) { itm.Equiped[(byte)Class] = -1; } }
public static void ProcessImgurGallery(string url, Enums.Sources source, Enums.Classes classification = Enums.Classes.Any) { if (string.IsNullOrWhiteSpace(url)) { return; } var page = Helpers.GetPageContents(url); var parser = new HtmlParser(); var document = parser.Parse(page); var jsElements = document.GetElementsByTagName("script"); if (!jsElements.Any()) { Helpers.LogMessage($"Cant find Script Sections for this page {url}"); return; } var imagesElement = jsElements.First(element => element.InnerHtml.Contains("window.runSlots")).TextContent; var startPosi = imagesElement.IndexOf("{", StringComparison.OrdinalIgnoreCase); var firstSemi = imagesElement.IndexOf(";", StringComparison.OrdinalIgnoreCase); var stopLength = firstSemi - startPosi; var json = imagesElement.Substring(startPosi, stopLength); try { if (string.IsNullOrWhiteSpace(json)) { return; } var images = JsonHelpers.LoadJson <ImgurJson>(json); if (images.Item.album_images.images.Any()) { //item.album_images.images foreach (var image in images.Item.album_images.images) { try { //{ // "hash": "kiylMhV", // "title": "", // "description": "Verona", // "width": 1920, // "height": 1080, // "size": 484650, // "ext": ".jpg", // "animated": false, // "prefer_video": false, // "looping": false, // "datetime": "2017-08-29 22:37:18" //} var title = image.title ?? ""; var description = image.description ?? ""; var extension = image.ext ?? ""; var imageDetail = new ImageDetail { ImageUrl = $"http://i.imgur.com/{image.hash}{image.ext}", ImageId = image.hash, ImageExtension = extension.Remove(0, 1), Resolution = $"{image.width}x{image.height}", Tag = document.GetElementsByClassName("post-title").First().TextContent + (!string.IsNullOrWhiteSpace(description) ? $",{description}" : "") + (!string.IsNullOrWhiteSpace(title) ? $",{title}" : ""), Who = images.Item.author ?? "Anonymous", IndexSource = Enums.Sources.Imgur }; if (classification != Enums.Classes.Any) { imageDetail.Class = classification; } // - - - - check if images have been scrapped before if (Helpers.ScrapeRepositories.ImageScrapeRepository.ExistsAsync(imageDetail.ImageId, imageDetail.IndexSource, CancellationToken.None).GetAwaiter().GetResult()) { continue; } //Helpers.LogMessage($"Image not in Scrape Repo {imageDetail.ImageId}"); Helpers.ScrapeRepositories.Queue.Enqueue(imageDetail); } catch (Exception e) { Helpers.LogMessage($"Error on Imgur For Loop : {e.Message}"); } } } else { //singular image var image = images.Item; try { //{ // "hash": "kiylMhV", // "title": "", // "description": "Verona", // "width": 1920, // "height": 1080, // "size": 484650, // "ext": ".jpg", // "animated": false, // "prefer_video": false, // "looping": false, // "datetime": "2017-08-29 22:37:18" //} var title = image.title ?? ""; var description = image.description ?? ""; var extension = image.ext ?? ""; var imageDetail = new ImageDetail { ImageUrl = $"http://i.imgur.com/{image.hash}{image.ext}", ImageId = image.hash, ImageExtension = extension.Remove(0, 1), Resolution = $"{image.width}x{image.height}", Tag = document.GetElementsByClassName("post-title").First().TextContent + (!string.IsNullOrWhiteSpace(description) ? $",{description}" : "") + (!string.IsNullOrWhiteSpace(title) ? $",{title}" : ""), Who = images.Item.author ?? "Anonymous", IndexSource = Enums.Sources.Imgur }; if (classification != Enums.Classes.Any) { imageDetail.Class = classification; } // - - - - check if images have been scrapped before if (Helpers.ScrapeRepositories.ImageScrapeRepository.ExistsAsync(imageDetail.ImageId, imageDetail.IndexSource, CancellationToken.None).GetAwaiter().GetResult()) { return; } //Helpers.LogMessage($"Image not in Scrape Repo {imageDetail.ImageId}"); Helpers.ScrapeRepositories.Queue.Enqueue(imageDetail); } catch (Exception e) { Helpers.LogMessage($"Error on Imgur For Loop : {e.Message}"); } } } catch (Exception e) { //possibly only a single picture page Helpers.LogMessage($"Error on Imgur JSON Parse : {e.Message}"); } }
public void Process(Enums.Sources source, Enums.Classes classification = Enums.Classes.Any) { var url = ""; try { //Get the board URL. var board = Core.Constants.SourceUrls[source]; Helpers.LogMessage($"Starting Board: {board}"); var tabs = new List <string> { "top", "new", "" }; foreach (var tab in tabs) { var boardurl = $"{board}{tab}"; var lastPost = ""; //loop pages for (var x = 1; x <= Settings.MaxPages; x++) { if (x != 1) { url = $"?count={(x - 1) * 25}&after={lastPost}"; } Helpers.LogMessage($"Getting Page Contents for {boardurl}{url}"); var pageContents = Helpers.GetPageContents(boardurl + url); // - - get threads on pages //Helpers.LogMessage($"Getting Page Threads"); var threads = GetPageThreads(pageContents); //Helpers.LogMessage($"Threads found :: {threads.Count}"); if (!threads.Any()) { break; } //loop the threads on the this page foreach (var thread in threads) { var imagelink = thread.GetAttribute("data-domain"); var dataUrl = thread.GetAttribute("data-url"); try { if (imagelink == "imgur.com") { var ext = dataUrl.Split("/").Last().Split(".").Last(); if (new[] { "png", "jpeg", "jpg", "gif", "png" }.Contains(ext)) { imagelink = "i.imgur.com"; } } } catch { //do nothing } //determine the action to run switch (imagelink) { case "i.redd.it": //if domain = i.redd.it this is a direct link case "i.imgur.com": //if domain = i.imgur.com this is a direct link var image = new ImageDetail { IndexSource = source }; if (classification != Enums.Classes.Any) { image.Class = classification; } if (!GetImageUrl(thread, image)) { continue; } GetWhoStamp(thread, image); GetResolution(thread, image); GetTags(thread, image); try { image.ImageId = thread.GetAttribute("data-fullname"); image.ImageExtension = image.ImageUrl?.Split('/')?.Last()?.Split('.')?.Last() ?? ""; } catch { // pass } // - - - - check if images have been scrapped before if (ScrapeRepositories.ImageScrapeRepository.ExistsAsync(image.ImageId, imagelink == "i.imgur.com" ? Enums.Sources.Imgur : source, CancellationToken.None).GetAwaiter().GetResult()) { continue; } //Helpers.LogMessage($"Image not in Scrape Repo {image.ImageId}"); if (image != null) { ScrapeRepositories.Queue.Enqueue(image); } break; case "imgur.com": //if domain = imgur.com this is a gallery gotta go loop this shit ImgurHelper.ProcessImgurGallery(thread.GetAttribute("data-url") ?? "", source, classification); break; } } if (threads.Any()) { lastPost = threads.Last().GetAttribute("data-fullname"); } else { break; } } } } catch (Exception ex) { Console.WriteLine(ex); } }