public async Task <IActionResult> Edit(long id, [Bind("Id,Name,Description,Bane")] Clans clans) { if (id != clans.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(clans); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ClansExists(clans.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } return(View(clans)); }
/// <summary> /// Initializes a new instance of the <see cref="Resources"/> class. /// </summary> internal static void Initialize() { Resources.Logger = LogManager.GetCurrentClassLogger(typeof(Resources)); Factory.Initialize(); CSV.Initialize(); Home.Initialize(); Fingerprint.Initialize(); GameSettings.Initialize(); if (Constants.Database == DBMS.Mongo) { Mongo.Initialize(); } Resources.Redis = new Redis(); Resources.Players = new Players(); Resources.Clans = new Clans(); // Resources.Battles = new Battles(); Resources.Random = new XorShift(); Resources.TCPGateway = new TCPServer(); Resources.UDPGateway = new UDPServer(); Resources.Started = true; Parser.Initialize(); EventsHandler.Initialize(); }
public ActionResult StartNewAge(Age age) { age.StartTime = DateTime.Now; Clans jclans = new Clans(); List <PlayerStat> players = new List <PlayerStat>(); List <Clan> clans = new List <Clan>(); System.Net.WebClient wc = new System.Net.WebClient(); wc.Encoding = System.Text.Encoding.UTF8; string json = wc.DownloadString("http://berserktcg.ru/api/export/clans.json"); json = "{\"clans\":" + json + "}"; jclans = JsonConvert.DeserializeObject <Clans>(json); foreach (var clan in jclans.clans) { json = wc.DownloadString("http://berserktcg.ru/api/export/clan/" + clan.id + ".json"); JsonClan clann = JsonConvert.DeserializeObject <JsonClan>(json); var mclan = repository.Clans.FirstOrDefault(x => x.ID == clann.id); if (mclan == null) { mclan = new Clan(clann); clans.Add(mclan); } foreach (var jsPlayer in clann.players) { players.Add(new PlayerStat(jsPlayer, mclan, age.StartTime)); } } repository.SaveAge(age); repository.SaveClans(clans); repository.SavePlayers(players); return(View()); }
/// <summary> /// Initializes a new instance of the <see cref="Resources"/> class. /// </summary> internal static void Initialize() { Resources.Logger = LogManager.GetCurrentClassLogger(typeof(Resources)); Factory.Initialize(); CSV.Initialize(); LevelFile.Initialize(); Fingerprint.Initialize(); Globals.Initialize(); if (Constants.Database == DBMS.Mongo) { Mongo.Initialize(); } Resources.Redis = new Redis(); Resources.Regex = new Regex("[ ]{2,}", RegexOptions.Compiled); Resources.Players = new Players(); Resources.Clans = new Clans(); Resources.Chats = new Chats(); Resources.Battles = new Battles(); Resources.Random = new XorShift(); Resources.TCPGateway = new TCPServer(); Resources.UDPGateway = new UDPServer(); Resources.Started = true; Parser.Initialize(); EventsHandler.Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="Resources"/> class. /// </summary> internal static void Initialize() { Resources.Logger = LogManager.GetCurrentClassLogger(typeof(Resources)); CSV.Initialize(); Home.Initialize(); Factory.Initialize(); Globals.Initialize(); Fingerprint.Initialize(); Resources.TCPGateway = new TCPServer(); Resources.UDPGateway = new UDPServer(); Resources.Database = new MySqlDatabase(); Resources.CacheSystem = new RedisDatabase(); Resources.Players = new Players(); Resources.Clans = new Clans(); Resources.Random = new XorShift(); Resources.BattleManager = new BattleManager(); Resources.Started = true; Parser.Initialize(); EventsHandler.Initialize(); Timers.Initialize(); }
/// <summary> /// Initializes a new instance of the <see cref="Resources"/> class. /// </summary> internal static void Initialize() { Resources.Logger = LogManager.GetCurrentClassLogger(typeof(Resources)); Resources.Sentry = new Sentry(Constants.SentryAPI, Constants.SentryID, Constants.UseSentry); #if DEBUG Console.WriteLine("Loaded " + Factory.Messages.Count + " messages, " + Factory.Commands.Count + " commands, and " + Factory.Debugs.Count + " debug commands."); #endif Resources.Redis = new Redis(); Resources.Parser = new Parser(); Resources.Fingerprint = new Fingerprint(); Resources.CSV = new CSV(); Resources.Home = new Home(); Resources.Npc = new NPC(); Resources.Helpers = new Helpers(); Resources.Checker = new Timers(); Resources.Players = new Players(); Resources.Clans = new Clans(); Resources.Battles = new Battles(); Resources.Chats = new WorldChats(); Resources.Random = new XorShift(); Resources.Cluster = new Cluster(); Resources.Test = new Test(); Resources.Gateway = new TCPServer(); Resources.UGateway = new UDPServer(); Resources.Events = new EventsHandler(); Resources.Started = true; }
/// <summary> /// Initializes a new instance of the <see cref="Resources"/> class. /// </summary> internal static void Initialize() { Resources.Logger = LogManager.GetCurrentClassLogger(typeof(Resources)); Factory.Initialize(); CSV.Initialize(); Home.Initialize(); Fingerprint.Initialize(); GameDatas.Initialize(); Resources.Gametools = new GameTools(); Resources.Redis = new Redis(); Resources.Players = new Players(); Resources.Clans = new Clans(); Resources.Battles = new Battles(); Resources.Random = new XorShift(); Resources.TCPGateway = new TCPServer(); Resources.UDPGateway = new UDPServer(); Resources.Started = true; Parser.Initialize(); EventsHandler.Initialize(); }
public void SetupObjects() { for (int i = 0; i <= 5; i++) { Matches match = new Matches(); Clans clan = new Clans(); Players player = new Players(); clan.Id = i; clan.Name = "clan" + i; clan.Origin = "origin" + i; match.Id = i; match.ClanHomeId = i; match.ClanHomeScore = i; match.ClanAwayScore = i + 1; match.IsPlayed = true; player.Id = i; player.Age = i + 1; player.Score = i + 22; player.Name = "name" + i; matches.Add(match); clans.Add(clan); players.Add(player); } matches[0].ClanAwayId = 2; matches[1].ClanAwayId = 3; matches[2].ClanAwayId = 4; matches[3].ClanAwayId = 0; matches[4].ClanAwayId = 1; }
public static async Task CheckForRejoiners(Clan clan) { await SpreadsheetTools.Read(clan); List <SpreadsheetTools.User> rejoiners = new List <SpreadsheetTools.User>(); var ClanMembers = await GetClanInfoCards(clan); //SpreadsheetTools.savedUsers.ToList().ForEach(member => { // if (!ClanMembers.Select(t => t.membershipId).Contains(Convert.ToInt64(member.bungieID))) // { // if (!oldLeavers.Select(t => t.bungieID).Contains(member.bungieID)) // { // if (member.bungieID != null) leavers.Add(member); // } // } //}); //clan.Leavers.ForEach(member => //{ //});; foreach (var member in clan.members.ClanLeavers) { if (!ClanMembers.validMembers.Select(t => t.membershipId).Contains(Convert.ToInt64(member.BungieID))) { rejoiners.Add(member); } } clan.members.ClanLeavers = rejoiners; Clans.SaveClanMembers(clan, UserType.Leaver); }
/// <summary> /// Handles the specified <see cref="Message"/>. /// </summary> /// <param name="Device">The device.</param> /// <param name="Message">The message.</param> /// <param name="Cancellation">The cancellation.</param> public static async Task Handle(Device Device, Message Message, CancellationToken Cancellation) { var AskForAllianceDataMessage = (AskForAllianceDataMessage)Message; if (AskForAllianceDataMessage == null) { throw new LogicException(typeof(AskForAllianceDataHandler), nameof(AskForAllianceDataMessage) + " == null at Handle(Device, Message, CancellationToken)."); } Clan Clan = await Clans.Get(AskForAllianceDataMessage.HighId, AskForAllianceDataMessage.LowId); if (Clan != null) { Device.NetworkManager.SendMessage(new AllianceDataMessage(new AllianceFullEntry() { Header = Clan.HeaderEntry, Members = Clan.Members.Values.ToArray(), Description = Clan.Description })); } else { Logging.Warning(typeof(AskForAllianceDataHandler), "Clan == null at Handle(Device, Message, CancellationToken)."); } }
/// <summary> /// Returns true if ClanWarLeagueGroup instances are equal /// </summary> /// <param name="input">Instance of ClanWarLeagueGroup to be compared</param> /// <returns>Boolean</returns> public bool Equals(ClanWarLeagueGroup?input) { if (input == null) { return(false); } return (( Tag == input.Tag || (Tag != null && Tag.Equals(input.Tag)) ) && ( State == input.State || State.Equals(input.State) ) && ( Season == input.Season || (Season != null && Season.Equals(input.Season)) ) && ( Clans == input.Clans || Clans != null && input.Clans != null && Clans.SequenceEqual(input.Clans) ) && ( Rounds == input.Rounds || Rounds != null && input.Rounds != null && Rounds.SequenceEqual(input.Rounds) )); }
public async Task <IActionResult> Create([Bind("Id,Name,Origin")] Clans clans) { if (ModelState.IsValid) { await _dataAccess.AddClans(clans); return(RedirectToAction(nameof(Index))); } return(View(clans)); }
/// <summary> /// 클랜찾기 에서 클랜정보볼떄 /// </summary> public void Set_ClanInfo(Clans _clans, Dictionary <byte, Clan_members> _clan_members) { clans = _clans; Dic_clanMembers = _clan_members; Apply_ClanInfo(); Check_userClan(); }
public async Task <IActionResult> Create([Bind("Id,Name,Description,Bane")] Clans clans) { if (ModelState.IsValid) { _context.Add(clans); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(clans)); }
/// <summary> /// Handles the specified <see cref="Message"/>. /// </summary> /// <param name="Device">The device.</param> /// <param name="Message">The message.</param> /// <param name="Cancellation">The cancellation.</param> public static async Task Handle(Device Device, Message Message, CancellationToken Cancellation) { var EndClientTurnMessage = (EndClientTurnMessage)Message; if (EndClientTurnMessage == null) { throw new LogicException(typeof(EndClientTurnHandler), nameof(EndClientTurnMessage) + " == null at Handle(Device, Message, CancellationToken)."); } if (EndClientTurnMessage.Commands != null) { EndClientTurnMessage.Commands.ForEach(Command => { if (Command.ExecuteTick <= EndClientTurnMessage.Tick) { Device.GameMode.CommandManager.AddCommand(Command); } }); } for (int I = Device.GameMode.Time; I < EndClientTurnMessage.Tick; I++) { Device.GameMode.UpdateOneTick(); } Player Player = Device.GameMode.Player; if (Player.IsInAlliance) { Clan Clan = await Clans.Get(Player.ClanHighId, Player.ClanLowId); if (Clan != null) { if (Clan.Members.TryGetValue(Player.PlayerId, out var Member)) { Member.SetPlayer(Player); } } else { Logging.Error(typeof(EndClientTurnHandler), "Clan == null at Handle(Device, Message, CancellationToken)."); } } /* if (Device.GameMode.State == HomeState.Home) * { * if (EndClientTurnMessage.Checksum != Device.GameMode.Checksum) * { * Logging.Error(this.GetType(), "Player is out of sync (S: " + Device.GameMode.Checksum + ", C: " + EndClientTurnMessage.Checksum + ")."); * Device.NetworkManager.SendMessage(new OutOfSyncMessage(Device, EndClientTurnMessage.Checksum, Device.GameMode.Checksum)); * } * } */ }
public static async Task SelectiveUpdate(Clan clan) { await Read(clan); var workingList = clan.members.BungieUsers; workingList.RemoveAll(t => string.IsNullOrEmpty(t.BungieProfile)); workingList = workingList.DistinctBy(t => t.BungieProfile).ToList(); workingList = workingList.OrderBy(t => t.SteamName).ToList(); clan.members.BungieUsers = workingList; Write(clan); Clans.SaveClanMembers(clan); }
//static void Main(string[] args) //{ // ConfigValues.LoadConfig(); // TrackTimeLive(); // Clans.LoadClans(); // MainAsync().GetAwaiter().GetResult(); //} static async Task Main(string[] args) { Random = new Random(); ConfigValues.LoadConfig(); //TrackTimeLive(); Clans.LoadClans(); await SpreadsheetTools.SetUpSheet(); startTime = DateTime.UtcNow; await Discord.SetupClient(); await Task.Delay(-1); }
protected override async Task OnParametersSetAsync() { if (_clanTag != ClanTag) { _clanTag = ClanTag; _clan = default; _clanMemberList = default; _clan = await Clans.GetClanAsync($"#{_clanTag}"); _clanMemberList = (ClanMemberList)await Clans.GetClanMembersAsync($"#{_clanTag}"); } }
/// <summary> /// Initializes a new instance of the Clash of Clans API /// </summary> /// <param name="tokens">Your personal API key(s)</param> public ClashOfClansClient(params string[] tokens) { TokenValidator.Validate(tokens); _options = new ClashOfClansOptionsInternal(tokens); var gameData = new GameData(_options); Clans = new Clans(gameData); Locations = new Locations(gameData); Leagues = new Leagues(gameData); Players = new Players(gameData); Labels = new Labels(gameData); GoldPass = new GoldPass(gameData); }
internal static void Initialize() { Server_Resources.Classes = new Classes(); Server_Resources.Exceptions = new Exceptions(); Server_Resources.Devices = new Devices(); Server_Resources.Players = new Players(); Server_Resources.Clans = new Clans(); Server_Resources.Battles = new Battles(); Server_Resources.Random = new Random(); Server_Resources.Region = new Region(); Server_Resources.WebAPI = new WebAPI(); Server_Resources.Gateway = new Gateway(); Server_Resources.Parser = new Parser(); }
public async Task <bool> AddClans(Clans clan) { try { _context.Add(clan); } catch (DbUpdateConcurrencyException ex) { Console.Write(ex); return(false); } await _context.SaveChangesAsync(); return(true); }
public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Origin")] Clans clans) { if (id != clans.Id) { return(NotFound()); } if (ModelState.IsValid) { await _dataAccess.UpdateClans(clans); return(RedirectToAction(nameof(Index))); } return(View(clans)); }
private void SetRelationalProperties() { if (_season != null && Clans?.Count() > 0) { _groupId = $"{_season.ToShortDateString()};{Clans.OrderBy(c => c.ClanTag).First().ClanTag}"; } if (Clans?.Count() > 0 && _season != null) { foreach (var clan in Clans) { clan.LeagueClanId = $"{_season.ToShortDateString()};{clan.ClanTag}"; } } }
public IActionResult Clans() { logger.LogInformation("Clans"); var data = new Clans(); var badges = from c in db.Clans select new ClanModel { Description = c.Description, Image = c.BadgeUrl, IsWarLogPublic = c.IsWarLogPublic, Level = c.ClanLevel, Location = c.LocationName, Losses = c.WarLosses, Name = c.Name, Points = c.ClanPoints, RequiredTrophies = c.RequiredTrophies, Tag = c.Tag, Ties = c.WarTies, Type = c.Type, WarFrequency = c.WarFrequency, Wins = c.WarWins, WinStreak = c.WarWinStreak }; var weights = new WeightCalculator(db).Calculate().ToDictionary(w => w.Tag); foreach (var row in badges) { if (weights.TryGetValue(row.Tag, out WeightCalculator.Results weight)) { row.Th14Count = weight.Th14Count; row.Th13Count = weight.Th13Count; row.Th12Count = weight.Th12Count; row.Th11Count = weight.Th11Count; row.Th10Count = weight.Th10Count; row.Th9Count = weight.Th9Count; row.Th8Count = weight.Th8Count; row.ThLowCount = weight.ThLowCount; row.EstimatedWeight = weight.EstimatedWeight; } data.Add(row); } return(Ok(data)); }
public void DistributeHuts(Random rng) { // Distribute Initial Huts List <Clan> avail = Clans.ToList <Clan>(); for (int gid = 0; gid < 12; gid++) { avail = Clans.ToList <Clan>(); for (int i = 0; i < 5; i++) { int rid = gid * 5 + i; int chosen = rng.Next(avail.Count()); Regions[rid].AddHut(avail[chosen]); avail.RemoveAt(chosen); } } }
private void UpdateLeagueTeamSize(CocApi cocApi, ILeagueGroup?leagueGroup) { if (leagueGroup is LeagueGroupApiModel leagueGroupApiModel) { if (leagueGroupApiModel.TeamSize > 15) { return; } if (Clans.Any(c => c.AttackCount > 15)) { leagueGroupApiModel.TeamSize = 30; cocApi.LeagueGroupTeamSizeChangeDetectedEvent(leagueGroupApiModel); } } }
internal static void Initialize() { Resources.Logger = LogManager.GetCurrentClassLogger(typeof(Resources)); Factory.Initialize(); CSV.Initialize(); LevelFile.Initialize(); GameEvents.Initialize(); Globals.Initialize(); Settings.Initialize(); Fingerprint.Initialize(); if (Constants.Database == DBMS.Mongo) { Mongo.Initialize(); } Resources.Regex = new Regex("[ ]{2,}", RegexOptions.Compiled); Resources.Name = new Regex("^[a-zA-Z0-9- ]*$"); Resources.Processor = new Processor(); Resources.Devices = new Devices(); Resources.Accounts = new Accounts(); Resources.Battles = new Battles(); Resources.Clans = new Clans(); Resources.Chats = new Chats(); Resources.Duels = new Duels(); Resources.Random2 = new System.Random(DateTime.UtcNow.ToString().GetHashCode()); Resources.Random = new XorShift(); Resources.Gateway = new Gateway(); Resources.StartTime = DateTime.UtcNow; Resources.Timers = new Timers(); Resources.Started = true; Parser.Initialize(); EventsHandler.Initialize(); Console.WriteLine("We loaded " + Factory.Messages.Count + " messages, " + Factory.Commands.Count + " commands, and " + Factory.Debugs.Count + " debug commands.\n"); #if Debug Resources.Test = new Test(); #endif }
public async Task <Clans> GetClanById(int id) { Clans clan = new Clans(); try { clan = await _context.Clans.FirstOrDefaultAsync(m => m.Id == id); } catch (DbException ex) { Console.Write(ex); } if (clan == null) { return(null); } return(clan); }
/// <summary> /// <para> /// Initialize a new instance of the <see cref="ResourcesManager" /> /// </para> /// <para>class.</para> /// </summary> public ResourcesManager() { m_vDatabase = new DatabaseManager(); //m_vClients = new ConcurrentDictionary<long, Device>(); m_vOnlinePlayers = new List <Level>(); this._Home = new Home(); Devices = new Devices(); //Players = new Players(); Clans = new Clans(); Battles = new Battles(); Tournaments = new Tournaments(); Random = new Random(); m_vInMemoryLevels = new ConcurrentDictionary <long, Level>(); this.m_vTimerCanceled = false; TimerCallback TimerDelegate = this.ReleaseOrphans; Timer TimerItem = new Timer(TimerDelegate, null, 60000, 60000); this.TimerReference = TimerItem; Console.WriteLine("The Resources Manager class has been initialized."); }
public void StartGame(Random rng) { DistributeHuts(rng); // Shuffle Player Order Names = Shuffler.Shuffle <string>(Names, rng).ToList <string>(); for (int i = 0; i < Names.Count; i++) { Players.Add(new Player(this, i, Names[i])); } // Assign 1 clan to each player List <Clan> avail = Clans.ToList <Clan>(); foreach (Player p in Players) { int chosen = rng.Next(avail.Count()); p.HiddenClan = avail[chosen]; avail.RemoveAt(chosen); } CurrentPlayer = Players.Last(); NewTurn(); }