public UniqueBase GetRandomUniqueBase(int ilvl, GroupType?group = null, EquipSlotType?slot = null) { if (uniqueList == null) { LoadUniques(); } WeightList <UniqueBase> possibleUniqueList = new WeightList <UniqueBase>(); foreach (UniqueBase unique in uniqueList.Values) { if (group != null && unique.group != group) { continue; } if (slot != null && unique.equipSlot != slot) { continue; } if (unique.dropLevel <= ilvl) { possibleUniqueList.Add(unique, unique.spawnWeight); } } if (possibleUniqueList.Count == 0) { return(null); } return(possibleUniqueList.ReturnWeightedRandom()); }
public static IEnumerable <Group> ReadAll(string fileName = null) { GroupType?currentGroupType = null; var currentSequence = 0; foreach (var line in InputFile.ReadAllLines(fileName)) { if (line == "Immune System:") { currentGroupType = GroupType.ImmuneSystem; currentSequence = 0; continue; } if (line == "Infection:") { currentGroupType = GroupType.Infection; currentSequence = 0; continue; } if (string.IsNullOrEmpty(line)) { continue; } if (currentGroupType == null) { throw new Exception("Expected group type header."); } yield return(ParseGroup(line, currentGroupType.Value, ++currentSequence)); } }
/// <summary> /// Gets all query. /// </summary> /// <param name="groupType">Type of the group.</param> /// <param name="orderBy">The order by.</param> /// <returns>the query of words</returns> public IQueryable <Word> GetAllQuery( GroupType?groupType = null, OrderByWord orderBy = OrderByWord.Spanish) { var query = this.wordRepository.TableNoTracking; if (groupType.HasValue) { query = query.Where(c => c.GroupId == Convert.ToInt16(groupType)); } switch (orderBy) { case OrderByWord.Random: query = query.OrderBy(c => Guid.NewGuid()); break; case OrderByWord.Spanish: query = query.OrderBy(c => c.Spanish); break; case OrderByWord.English: query = query.OrderBy(c => c.English); break; default: query = query.OrderBy(c => c.Id); break; } return(query); }
public async Task <List <GetMaterialsType> > GetMaterialsType(GroupType?group) { var url = $"/api/Recipe/materials-type?group=" + $"{group}"; var result = await GetAll <GetMaterialsType>(url); return(result); }
public async Task <List <GetMaterialsType> > GetMaterialsType(GroupType?group) { var materialsType = _context.MaterialsTypes; List <GetMaterialsType> result; if (group != null) { result = await materialsType.Where(x => x.GroupType == group) .Select(x => new GetMaterialsType() { Id = x.Id, Code = x.Code, Name = x.Name }).ToListAsync(); } else { result = await materialsType .Select(x => new GetMaterialsType() { Id = x.Id, Code = x.Code, Name = x.Name }).ToListAsync(); } return(new List <GetMaterialsType>(result)); }
/// <summary> /// Gets all. /// </summary> /// <param name="groupType">Type of the group.</param> /// <param name="orderBy">The order by.</param> /// <param name="page">The page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns> /// the words /// </returns> public IPagedList <Word> GetAll( GroupType?groupType = null, OrderByWord orderBy = OrderByWord.Spanish, int page = 0, int pageSize = int.MaxValue) { return(new PagedList <Word>(this.GetAllQuery(groupType, orderBy), page, pageSize)); }
/// <summary> /// Initializes a new instance of the GroupUpdateParameters class. /// </summary> /// <param name="displayName">Group name.</param> /// <param name="description">Group description.</param> /// <param name="type">Group type. Possible values include: 'custom', /// 'system', 'external'</param> /// <param name="externalId">Identifier of the external groups, this /// property contains the id of the group from the external identity /// provider, e.g. for Azure Active Directory /// `aad://<tenant>.onmicrosoft.com/groups/<group object /// id>`; otherwise the value is null.</param> public GroupUpdateParameters(string displayName = default(string), string description = default(string), GroupType?type = default(GroupType?), string externalId = default(string)) { DisplayName = displayName; Description = description; Type = type; ExternalId = externalId; CustomInit(); }
/// <summary> /// Gets all asynchronous. /// </summary> /// <param name="groupType">Type of the group.</param> /// <param name="orderBy">The order by.</param> /// <param name="page">The page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns> /// the words /// </returns> public async Task <IPagedList <Word> > GetAllAsync( GroupType?groupType = null, OrderByWord orderBy = OrderByWord.Spanish, int page = 0, int pageSize = int.MaxValue) { return(await new PagedList <Word>().Async(this.GetAllQuery(groupType, orderBy), page, pageSize)); }
/// <summary> /// Initializes a new instance of the GroupContractProperties class. /// </summary> /// <param name="displayName">Group name.</param> /// <param name="description">Group description. Can contain HTML /// formatting tags.</param> /// <param name="builtIn">true if the group is one of the three system /// groups (Administrators, Developers, or Guests); otherwise /// false.</param> /// <param name="type">Group type. Possible values include: 'custom', /// 'system', 'external'</param> /// <param name="externalId">For external groups, this property /// contains the id of the group from the external identity provider, /// e.g. for Azure Active Directory /// `aad://<tenant>.onmicrosoft.com/groups/<group object /// id>`; otherwise the value is null.</param> public GroupContractProperties(string displayName, string description = default(string), bool?builtIn = default(bool?), GroupType?type = default(GroupType?), string externalId = default(string)) { DisplayName = displayName; Description = description; BuiltIn = builtIn; Type = type; ExternalId = externalId; CustomInit(); }
/// <summary> /// Gets all asynchronous. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="groupType">Type of the group.</param> /// <param name="originLanguage">The origin language.</param> /// <param name="orderBy">order by game</param> /// <param name="page">The page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns> /// the games /// </returns> public async Task <IPagedList <Game> > GetAllAsync( int?userId = null, GroupType?groupType = null, Language?originLanguage = null, OrderByGame orderBy = OrderByGame.Newest, int page = 0, int pageSize = int.MaxValue) { return(await new PagedList <Game>().Async(this.GetAllQuery(userId, groupType, originLanguage, orderBy), page, pageSize)); }
/// <summary> /// Gets all. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="groupType">Type of the group.</param> /// <param name="originLanguage">The origin language.</param> /// <param name="orderBy">order by game</param> /// <param name="page">The page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns> /// the game /// </returns> public IPagedList <Game> GetAll( int?userId = null, GroupType?groupType = null, Language?originLanguage = null, OrderByGame orderBy = OrderByGame.Newest, int page = 0, int pageSize = int.MaxValue) { return(new PagedList <Game>(this.GetAllQuery(userId, groupType, originLanguage), page, pageSize)); }
/// <summary> /// Initializes a new instance of the GroupContract class. /// </summary> /// <param name="displayName">Group name.</param> /// <param name="id">Resource ID.</param> /// <param name="name">Resource name.</param> /// <param name="type">Resource type for API Management /// resource.</param> /// <param name="description">Group description. Can contain HTML /// formatting tags.</param> /// <param name="builtIn">true if the group is one of the three system /// groups (Administrators, Developers, or Guests); otherwise /// false.</param> /// <param name="groupContractType">Group type. Possible values /// include: 'custom', 'system', 'external'</param> /// <param name="externalId">For external groups, this property /// contains the id of the group from the external identity provider, /// e.g. for Azure Active Directory /// `aad://<tenant>.onmicrosoft.com/groups/<group object /// id>`; otherwise the value is null.</param> public GroupContract(string displayName, string id = default(string), string name = default(string), string type = default(string), string description = default(string), bool?builtIn = default(bool?), GroupType?groupContractType = default(GroupType?), string externalId = default(string)) : base(id, name, type) { DisplayName = displayName; Description = description; BuiltIn = builtIn; GroupContractType = groupContractType; ExternalId = externalId; CustomInit(); }
public static Equipment CreateRandomUnique(int ilvl, GroupType?group = null) { UniqueBase uniqueBase = ResourceManager.Instance.GetRandomUniqueBase(ilvl, group); if (uniqueBase == null) { return(null); } return(CreateUniqueFromBase(uniqueBase, ilvl)); }
public IActionResult Error(string _Message, GroupType?_GroupId) { var _vm = new ErrorViewModel { Message = _Message, RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier, GroupId = (GroupType)_GroupId }; return(View(_vm)); }
public static Equipment CreateRandomEquipment_EvenSlotWeight(int ilvl, GroupType?group = null, float baseLevelSkew = 1f) { EquipSlotType slot = (EquipSlotType)UnityEngine.Random.Range(0, 9); if (slot == EquipSlotType.RING_SLOT_1) { slot = EquipSlotType.RING; } Equipment equip = CreateEquipmentFromBase(ResourceManager.Instance.GetRandomEquipmentBase(ilvl, group, slot, baseLevelSkew), ilvl); return(equip); }
public Task <IActionResult> Get(GroupType?type, string name, int?page, CancellationToken token) { IQueryable <Group> ret = DB.Groups; if (type.HasValue) { ret = ret.Where(x => x.Type == type.Value); } if (!string.IsNullOrWhiteSpace(name)) { ret = ret.Where(x => x.Name.Contains(name) || name.Contains(x.Name)); } if (!page.HasValue) { page = 1; } return(Paged(ret, page.Value, 20, token)); }
/// <summary> /// Gets all query. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="groupType">Type of the group.</param> /// <param name="originLanguage">The origin language.</param> /// <param name="orderBy">The order by.</param> /// <returns>the query</returns> private IQueryable <Game> GetAllQuery( int?userId = null, GroupType?groupType = null, Language?originLanguage = null, OrderByGame orderBy = OrderByGame.Newest) { var query = this.gameRepository.TableNoTracking; if (userId.HasValue) { query = query.Where(c => c.UserId == userId.Value); } if (groupType.HasValue) { query = query.Where(c => c.GroupId == Convert.ToInt16(groupType)); } if (originLanguage.HasValue) { query = query.Where(c => c.OriginLanguage.Equals(originLanguage.ToString())); } switch (orderBy) { case OrderByGame.Newest: query = query.OrderByDescending(c => c.CreationDate); break; case OrderByGame.Top: query = query.OrderByDescending(c => c.Positives); break; default: query = query.OrderBy(c => c.Id); break; } return(query); }
public EquipmentBase GetRandomEquipmentBase(int ilvl, GroupType?group = null, EquipSlotType?slot = null, float baseLevelSkew = 1f) { if (equipmentList == null) { LoadEquipment(); } WeightList <EquipmentBase> possibleEquipList = new WeightList <EquipmentBase>(); foreach (EquipmentBase equipment in equipmentList.Values) { if (group != null && equipment.group != group) { continue; } if (slot != null && equipment.equipSlot != slot) { continue; } if (equipment.dropLevel <= ilvl) { float weight = 1f; if (baseLevelSkew != 1f) { weight *= Mathf.Lerp(1 / baseLevelSkew, baseLevelSkew, (float)equipment.dropLevel / ilvl); } possibleEquipList.Add(equipment, (int)(equipment.spawnWeight * weight)); } } if (possibleEquipList.Count == 0) { return(null); } return(possibleEquipList.ReturnWeightedRandom()); }
// Base Stuff for splitted up commands // Some commands behave differently on query and full client /// <summary>Creates a new server group using the name specified with <paramref name="name"/> and return its ID. /// The optional <paramref name="type"/> parameter can be used to create ServerQuery groups and template groups.</summary> public abstract R <ServerGroupAddResponse, CommandError> ServerGroupAdd(string name, GroupType?type = null);
internal static string ToSerializedValue(this GroupType?value) { return(value == null ? null : ((GroupType)value).ToSerializedValue()); }
// serverrequestconnectioninfo // servergetvariables // Splitted base commands public override R <ServerGroupAddResponse, CommandError> ServerGroupAdd(string name, GroupType?type = null) { var cmd = new Ts3Command("servergroupadd", new List <ICommandPart> { new CommandParameter("name", name) }); if (type.HasValue) { cmd.AppendParameter(new CommandParameter("type", (int)type.Value)); } var result = SendNotifyCommand(cmd, NotificationType.ServerGroupList); if (!result.Ok) { return(result.Error); } return(result.Value.Notifications .Cast <ServerGroupList>() .Where(x => x.Name == name) .Take(1) .Select(x => new ServerGroupAddResponse() { ServerGroupId = x.ServerGroupId }) .WrapSingle()); }
public static Equipment CreateRandomEquipment(int ilvl, GroupType?group = null) { Equipment equip = CreateEquipmentFromBase(ResourceManager.Instance.GetRandomEquipmentBase(ilvl, group), ilvl); return(equip); }
public async Task <IActionResult> GetMaterialsType(GroupType?group) { var result = await _recipeApiClient.GetMaterialsType(group); return(Ok(result)); }
// Splitted base commands public override R <ServerGroupAddResponse, CommandError> ServerGroupAdd(string name, GroupType?type = null) => Send <ServerGroupAddResponse>(new Ts3Command("servergroupadd") { { "name", name }, { "type", (int?)type } }).WrapSingle();
// Splitted base commands public override R <ServerGroupAddResponse, CommandError> ServerGroupAdd(string name, GroupType?type = null) => Send <ServerGroupAddResponse>("servergroupadd", type.HasValue ? new List <ICommandPart> { new CommandParameter("name", name), new CommandParameter("type", (int)type.Value) } : new List <ICommandPart> { new CommandParameter("name", name) }).WrapSingle();
public static void Run() { int boost = 0; int step = 50; GroupType?lastWinner = GroupType.Infection; while (true) { List <BattleGroup> groups = new List <BattleGroup>(); foreach (var line in File.ReadAllLines(@"Day24\ImmuneSystem.txt")) { groups.Add(ParseRow(line, GroupType.ImmuneSystem)); } foreach (var line in File.ReadAllLines(@"Day24\Infection.txt")) { groups.Add(ParseRow(line, GroupType.Infection)); } bool draw = false; while (groups.GroupBy(x => x.Type).Count() > 1) { HashSet <BattleGroup> alreadyChosenGroups = new HashSet <BattleGroup>(); List <(BattleGroup attacker, BattleGroup defender)> fight = new List <(BattleGroup attacker, BattleGroup defender)>(); foreach (var attackingGroup in groups.OrderByDescending(x => x.EffectivePower).ThenByDescending(x => x.Initiative)) { var defendingGroup = groups.Where(x => x.GetDamage(attackingGroup) > 0 && !alreadyChosenGroups.Contains(x)). OrderByDescending(x => x.GetDamage(attackingGroup)). ThenByDescending(x => x.EffectivePower). ThenByDescending(x => x.Initiative). FirstOrDefault(); if (defendingGroup != null) { fight.Add((attackingGroup, defendingGroup)); alreadyChosenGroups.Add(defendingGroup); } } var groupsBefore = groups.Select(x => x.UnitsCount).ToList(); foreach (var item in fight.OrderByDescending(x => x.attacker.Initiative)) { item.defender.OnAttacked(item.attacker); } draw = groupsBefore.SequenceEqual(groups.Select(x => x.UnitsCount)); if (draw) { break; } groups.RemoveAll(x => x.IsDead); } GroupType?winner = draw ? (GroupType?)null : groups.First().Type; Console.WriteLine($"{(draw ? "DRAW" : winner.ToString())} ({boost}, {step}) | Total units: {groups.Sum(x => x.UnitsCount)}"); if (step <= 1 && step >= -1 && winner == GroupType.ImmuneSystem) { break; } if (!draw && lastWinner != winner) { step *= -1; step /= 2; } lastWinner = winner; boost += step; } Console.WriteLine("End"); BattleGroup ParseRow(string input, GroupType type) { var splitWithoutWeakImun = Regex.Replace(input, @"\s\(.*\)", string.Empty).Split(' '); int unitsCount = int.Parse(splitWithoutWeakImun[0]); int hitPoints = int.Parse(splitWithoutWeakImun[4]); int attackPoints = int.Parse(splitWithoutWeakImun[12]); string attackType = splitWithoutWeakImun[13].Trim(); int initiative = int.Parse(splitWithoutWeakImun[17]); var weakInum = Regex.Match(input, @"\(.*\)").Value.Trim("()".ToCharArray()).Split(';'); List <string> weaknesses = new List <string>(); List <string> imunities = new List <string>(); foreach (var item in weakInum.Select(x => x.Trim())) { if (item.StartsWith("weak to")) { weaknesses = item.Replace("weak to", "").Split(',').Select(x => x.Trim()).ToList(); } if (item.StartsWith("immune to")) { imunities = item.Replace("immune to", "").Split(',').Select(x => x.Trim()).ToList(); } } if (type == GroupType.ImmuneSystem) { attackPoints += boost; } return(new BattleGroup(hitPoints, unitsCount, weaknesses, imunities, attackPoints, attackType, initiative, type)); } }
/// <summary> /// Gets the best scores. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="groupType">Type of the group.</param> /// <param name="page">The page.</param> /// <param name="pageSize">Size of the page.</param> /// <returns> /// the scores /// </returns> public async Task <IPagedList <BestScore> > GetBestScoresAsync(int?userId = null, GroupType?groupType = null, int page = 0, int pageSize = int.MaxValue) { var query = this.bestScoreRepository.TableNoTracking .Include(c => c.User) .AsQueryable(); if (userId.HasValue) { query = query.Where(c => c.UserId == userId); } if (groupType.HasValue) { query = query.Where(c => c.GroupId == Convert.ToInt16(groupType)); } return(await new PagedList <BestScore>().Async(query, page, pageSize)); }