public IActionResult GenerateFriends() { string id = User.FindFirst(ClaimTypes.NameIdentifier).Value; string id2 = $"{FRIENDSLISTID1}"; string id3 = $"{FRIENDSLISTID2}"; List <Gamers> gamerList = _context.Gamers.Where(x => x.UserId == id2 || x.UserId == id3).ToList(); List <Gamers> userGamerList = _context.Gamers.Where(x => x.UserId == id).ToList(); List <string> gamertags = new List <string>(); foreach (Gamers gamers in userGamerList) { gamertags.Add(gamers.Gamertag); } for (int i = 0; i < gamerList.Count; i++) { Gamers newgamer = new Gamers(); newgamer.CopyGamer(gamerList[i]); newgamer.UserId = id; if (gamertags.Contains(gamerList[i].Gamertag) == false) // if our old friendslist doesn't contain this new gametag { _context.Gamers.Add(newgamer); _context.SaveChanges(); } } return(RedirectToAction("DisplayGamers")); }
public async Task <ActionResult> CreateProfile(Users newUser) { //creates a profile from the register user page, grabs the gamertag for that profile as well, adds both to database if they're valid if (ModelState.IsValid) { string id = User.FindFirst(ClaimTypes.NameIdentifier).Value; var client = new HttpClient(); client.BaseAddress = new Uri($"https://www.haloapi.com/stats/h5/servicerecords/arena"); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", $"{APIKEYVARIABLE}"); var response = await client.GetAsync($"?players={newUser.Gamertag}"); var searchedPlayer = await response.Content.ReadAsAsync <PlayerRootObject>(); if (searchedPlayer == null || searchedPlayer.Results[0].Result.PlayerId.Gamertag == null) { ViewBag.Message = "This Gamertag does not exist, please try again!"; return(View("RegisterUser", "_RegisterUserLayout")); } if (searchedPlayer.Results[0].Result.ArenaStats.TotalTimePlayed == "") { ViewBag.Message = "This Gamertag does not have any Halo 5 play time!"; return(View("RegisterUser", "_RegisterUserLayout")); } Gamers searchedGamer = new Gamers(searchedPlayer, 0); searchedGamer.UserId = id; newUser.UserId = id; newUser.Gamertag = searchedGamer.Gamertag; _context.Gamers.Add(searchedGamer); _context.Users.Add(newUser); _context.SaveChanges(); return(RedirectToAction("MyProfile")); } return(RedirectToAction("RegisterUser")); }
private void JudgeResult() { if (IsGameOver()) { PushMsg("很遗憾队伍全灭,请再接再厉!"); return; } if (Gamers.Count == 1) { var winner = Gamers.First(); var treasureStr = TreasureTotal.ToString(); if (string.IsNullOrEmpty(treasureStr)) { PushMsg($"获胜者为 {CodeApi.Code_At(winner.QQNum)} !但是没有任何物品掉落"); return; } PushMsg($"获胜者为 {CodeApi.Code_At(winner.QQNum)} !获得以下物品:\r\n{treasureStr}"); TreasureTotal.SaveToPerson(winner.QQNum); return; } var msg = "恭喜你们获得了胜利!\r\n"; var treasures = TreasureTotal.Split(); msg += $"{CodeApi.Code_At(Gamers[0].QQNum)} 获取了\r\n{treasures[0]}\r\n{CodeApi.Code_At(Gamers[1].QQNum)} 获取了\r\n{treasures[1]}"; PushMsg(msg); treasures[0].SaveToPerson(Gamers[0].QQNum); treasures[1].SaveToPerson(Gamers[1].QQNum); }
private void PlayerAct(XunYuanGamingModel player, int choice, XunyuanMonsterModel monster, XunYuanGamingModel partner) { switch (choice) { case -1: { PushMsg("你放弃了思考!"); break; } case 0: { monster.HP = Math.Max(0, monster.HP - player.Attack); PushMsg($"{monster.Name} 受到了 {CodeApi.Code_At(player.QQNum)} 的 {player.Attack} 点伤害,剩余 {monster.HP} 点生命值"); break; } case 1: { partner.HP = Math.Max(0, partner.HP - player.Attack); PushMsg($"{CodeApi.Code_At(player.QQNum)} 受到了 {CodeApi.Code_At(player.QQNum)} 的 {player.Attack} 点伤害,剩余 {partner.HP} 点生命值"); if (partner.IsDead) { PushMsg($"{CodeApi.Code_At(partner.QQNum)} 被移除了队伍!"); Gamers.Remove(partner); } break; } } }
static void Main(string[] args) { Gamers gamer = new Gamers() { GamerId = 1, GamerName = "Nur", GamerSurname = "Hayat", BirthYear = 2000 }; Campaign campaign = new Campaign() { CampaignId = 1, CampaignName = "february campaign ", CampaignDiscount = 50 }; Game game = new Game() { GameName = "VALORANT", GamePrice = 100, GameType = "FPS", GameId = 1 }; GamerManager gamerManager = new GamerManager(new ValidationManager()); GameManager gameManager = new GameManager(); CampaignManager campaignManager = new CampaignManager(); gameManager.Add(game); campaignManager.Add(campaign); SalesManager salesManager = new SalesManager(); salesManager.Sales(gamer, game); salesManager.CampaignSales(gamer, game, campaign); }
public IActionResult MyProfile() //displays your profile. finds both your user and gamer and combines them to send to the view { string id = User.FindFirst(ClaimTypes.NameIdentifier).Value; Users foundUser = _context.Users.Where(x => x.UserId == id).First(); Gamers foundGamer = _context.Gamers.Where(x => x.UserId == id && x.Gamertag == foundUser.Gamertag).First(); UsersGamers UserProfile = new UsersGamers(foundUser, foundGamer); return(View(UserProfile)); }
public bool Validate(Gamers gamer) { if (gamer.GamerId == 1 && gamer.GamerName == "NUR" && gamer.GamerSurname == "HAYAT" && gamer.BirthYear == 2000) { return(true); } else { return(false); } }
public void Add(Gamers gamer) { if (_userValidationService.Validate(gamer) == true) { Console.WriteLine(gamer.GamerName + "gamer added "); } else { Console.WriteLine(gamer.GamerName + "could not be added "); } }
public void Add(Gamers gamer) { if (_iValidationCheckService.Validate(gamer)) { Console.WriteLine(gamer.GamerFirstName + " added"); } else { Console.WriteLine("Validate failed!"); } }
public bool Validate(Gamers gamer) { if (gamer.YearOfBirth == 1997 && gamer.GamerFirstName == "ENES" && gamer.GamerLastName == "TURKMEN" && gamer.GamerTcNo == 12345678901) { return(true); } else { return(false); } }
public override IRoomStat getRoomStat() { return(new RoomStat() { Pasport = this.Passport, Players_count = Gamers.Count(), /*Creator_Pasport = this.CreatorPassport*/ CreatorName = this.Creator != null ? this.Creator.Name: "", Game_Type = GameSetings != null ? GameSetings.GameType : GameType.NotGame, MaxPlayersCount = GameSetings != null ? GameSetings.MaxPlayersCount : 0 }); }
public override void Delete(Gamers gamers) { if (_gamersCheckService.CheckIfRealPerson(gamers)) { base.Delete(gamers); } else { Console.WriteLine("Silinmek istenen oyuncu geçerli kimlik bilgilerine sahip değil"); Console.ReadLine(); } }
public override void Save(Gamers gamers) { if (_gamersCheckService.CheckIfRealPerson(gamers)) { base.Save(gamers); } else { Console.WriteLine("Kayıt olmak isteyen oyuncu geçerli kimlik bilgilerine sahip değil"); Console.ReadLine(); } }
public bool CheckIfRealPerson(Gamers gamers) { KPSPublicSoapClient client = new KPSPublicSoapClient(KPSPublicSoapClient.EndpointConfiguration.KPSPublicSoap); long TCKimlikNo = gamers.NationalityId; string Ad = gamers.FirstName.ToUpper(); string Soyad = gamers.LastName.ToUpper(); int DogumYili = gamers.DateOfBirth.Year; return(false); //return client.TCKimlikNoDogrulaAsync(new TCKimlikNoDogrulaRequest(new TCKimlikNoDogrulaRequestBody( // TCKimlikNo, Ad, Soyad, DogumYili))).Result.Body.TCKimlikNoDogrulaResult; }
static MainConsoleManager() { _gamersDb = new Gamers(); _gamerManager = new GamerManager(_gamersDb, new MernisServiceAdapter()); _gamesDb = new Games(); _gameManager = new GameManager(_gamesDb); _campaignsDb = new Campaigns(); _campaignManager = new CampaignManager(_campaignsDb); _ordersDb = new Orders(); _orderManager = new OrderManager(_ordersDb); _orderDetailsDb = new OrderDetails(); _orderDetailManager = new OrderDetailManager(_orderDetailsDb); ExampleDatas(); }
private void MonsterTurn(XunyuanMonsterModel monster) { var target = Gamers[Rander.RandInt(Gamers.Count)]; target.HP = Math.Max(0, target.HP - monster.Atk); PushMsg($"{CodeApi.Code_At(target.QQNum)} 受到了 {monster.Name} 的 {monster.Atk}点攻击伤害!剩余 {target.HP}点生命"); if (!target.IsDead) { return; } PushMsg($"{CodeApi.Code_At(target.QQNum)} 被移除了队伍!"); Gamers.Remove(target); }
private void MonsterEncounter(XunyuanMonsterModel monster) { while (!monster.IsDead && !IsGameOver()) { PlayersTurn(monster); if (monster.IsDead || monster.Name == "逃跑的小偷" && Gamers.IsNullOrEmpty()) { break; } MonsterTurn(monster); } MonsterSettlement(monster); }
public IActionResult AddToGamers(Gamers newPlayer) { if (ModelState.IsValid) { string id = User.FindFirst(ClaimTypes.NameIdentifier).Value; List <Gamers> gamerList = _context.Gamers.Where(x => x.UserId == id).ToList(); for (int i = 0; i < gamerList.Count; i++) { if (gamerList[i].Gamertag == newPlayer.Gamertag) { return(RedirectToAction("DisplayGamers")); } } _context.Gamers.Add(newPlayer); _context.SaveChanges(); } return(RedirectToAction("DisplayGamers")); }
public async Task <ActionResult> GetPlayerBySearch(string search) //searches for player, checks if it's valid and returns view with gamer { if (search == null) { string id = User.FindFirst(ClaimTypes.NameIdentifier).Value; ViewBag.Gamertag = _context.Users.Where(x => x.UserId == id).First().Gamertag; List <Gamers> userGamers = GetGamerList(); ViewBag.Message = "This gamertag does not exist"; return(View("DisplayGamers", userGamers)); } var client = new HttpClient(); client.BaseAddress = new Uri($"https://www.haloapi.com/stats/h5/servicerecords/arena"); client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", $"{APIKEYVARIABLE}"); var response = await client.GetAsync($"?players={search}"); var searchedPlayer = await response.Content.ReadAsAsync <PlayerRootObject>(); ViewBag.UserId = User.FindFirst(ClaimTypes.NameIdentifier).Value; Gamers searchedGamer = new Gamers(searchedPlayer, 0); if (searchedGamer.Gamertag == null) { string id = User.FindFirst(ClaimTypes.NameIdentifier).Value; Users foundUser = _context.Users.Where(x => x.UserId == id).First(); Gamers foundGamer = _context.Gamers.Where(x => x.UserId == id && x.Gamertag == foundUser.Gamertag).First(); UsersGamers UserProfile = new UsersGamers(foundUser, foundGamer); ViewBag.Message = "This Gamertag does not exist, please try again!"; return(View("MyProfile", UserProfile)); } else if (searchedGamer.TotalTimePlayed == "") { string id = User.FindFirst(ClaimTypes.NameIdentifier).Value; Users foundUser = _context.Users.Where(x => x.UserId == id).First(); Gamers foundGamer = _context.Gamers.Where(x => x.UserId == id && x.Gamertag == foundUser.Gamertag).First(); UsersGamers UserProfile = new UsersGamers(foundUser, foundGamer); ViewBag.Message = "This Gamertag does not have any Halo 5 play time!"; return(View("MyProfile", UserProfile)); } return(View(searchedGamer)); }
public IActionResult DeleteFromGamers(int id) { Gamers found = _context.Gamers.Find(id); if (found != null) { string id2 = User.FindFirst(ClaimTypes.NameIdentifier).Value; Users foundUser = _context.Users.Where(x => x.UserId == id2).First(); if (found.Gamertag.ToLower() == foundUser.Gamertag.ToLower()) { List <Gamers> userGamers = _context.Gamers.Where(x => x.UserId == id2).ToList(); ViewBag.Gamertag = foundUser.Gamertag; return(View("DisplayGamers", userGamers)); } else { _context.Gamers.Remove(found); _context.SaveChanges(); } } return(RedirectToAction("DisplayGamers")); }
private void PlayersTurn(XunyuanMonsterModel monster) { var randPlayers = Rander.RandSort(Gamers.ToArray()); var firstPlayer = randPlayers[0]; var choice = 0; if (randPlayers.Length > 1) { choice = WaiterSvc.WaitForOptions(GroupNum, firstPlayer.QQNum, "请做出抉择!", new[] { "攻击怪物", "攻击队友" }, BindAi); } PlayerAct(firstPlayer, choice, monster, randPlayers.Length > 1 ? randPlayers[1] : null); if (Gamers.Count <= 1 || monster.IsDead) { return; } var secondPlayer = randPlayers[1]; choice = WaiterSvc.WaitForOptions(GroupNum, secondPlayer.QQNum, "请做出抉择!", new[] { "攻击怪物", "攻击队友" }, BindAi); PlayerAct(secondPlayer, choice, monster, firstPlayer); }
public void Update(Gamers gamer) { Console.WriteLine(gamer.GamerName + "gamer updated "); }
public void Delete(Gamers gamer) { Console.WriteLine(gamer.GamerName + "gamer deleted "); }
public void CampaignSales(Gamers gamer, Game game, Campaign campaign) { }
public void Sales(Gamers gamer, Game game) { }
public virtual void Update(Gamers gamers) { Console.WriteLine("Oyuncu bilgileri güncellendi : " + gamers.FirstName + " " + gamers.LastName); }
public virtual void Delete(Gamers gamers) { Console.WriteLine("Oyuncu silindi : " + gamers.FirstName + " " + gamers.LastName); }
public virtual void Save(Gamers gamers) { Console.WriteLine("Oyuncu veri tabanına eklendi : " + gamers.FirstName + " " + gamers.LastName); }
public bool CheckIfRealPerson(Gamers gamers) { return(true); }
private bool IsGameOver() { return(Gamers.IsNullOrEmpty()); }