public IActionResult Create(CreatePlayerModel createPlayer) { if (ModelState.IsValid) { var webRoot = _env.WebRootPath; var filePath = Path.Combine(webRoot.ToString() + "\\images\\players\\" + createPlayer.imageUpload.FileName); if (createPlayer.imageUpload.FileName.Length > 0) { using (var stream = new FileStream(filePath, FileMode.Create)) { createPlayer.imageUpload.CopyTo(stream); } } var player = new Player { Name = createPlayer.Name, Description = createPlayer.Description, Image = "\\images\\players\\" + createPlayer.imageUpload.FileName }; _assets.Add(player); return(RedirectToAction("Index")); } return(View(createPlayer)); }
public void Invoke(IPlayer ser) { Console.Write("Name of the player:\n "); var name = Validator.validator_name(Console.ReadLine()); Console.Write("Surname: \n"); var surname = Validator.validator_name(Console.ReadLine()); ser.Add(name, surname); }
/// <summary> /// Creates a city under the specified player with initial troop and main building /// </summary> public virtual void CreateCity(ICityFactory cityFactory, IPlayer player, string cityName, byte level, Position cityPosition, IBarbarianTribeManager barbarianTribeManager, out ICity city) { city = cityFactory.CreateCity(world.Cities.GetNextCityId(), player, cityName, cityPosition, formula.GetInitialCityResources(), formula.GetInitialCityRadius(), formula.GetInitialAp(), Theme.DEFAULT_THEME_ID, Theme.DEFAULT_THEME_ID, Theme.DEFAULT_THEME_ID, Theme.DEFAULT_THEME_ID); var mainBuildingPosition = cityPosition.Left(); IStructure mainBuilding = city.CreateStructure(2000, level, mainBuildingPosition.X, mainBuildingPosition.Y); player.Add(city); world.Cities.Add(city); city.BeginUpdate(); mainBuilding.BeginUpdate(); world.Regions.Add(mainBuilding); mainBuilding.EndUpdate(); var defaultTroop = city.CreateTroopStub(); defaultTroop.BeginUpdate(); defaultTroop.AddFormation(FormationType.Normal); defaultTroop.AddFormation(FormationType.Garrison); defaultTroop.AddFormation(FormationType.InBattle); defaultTroop.EndUpdate(); RecalculateCityResourceRates(city); SetResourceCap(city); city.EndUpdate(); if (player.GetCityCount() == 1) { barbarianTribeManager.CreateBarbarianTribeNear(1, 10, city.PrimaryPosition.X, city.PrimaryPosition.Y, 10); } }
public void ReadJsonDeserialize(string fileName, ITeam _teams, IPlayer _players, IEnumerable <Playersalary> playerSalaries) { Rootobject rootObject = JsonConvert.DeserializeObject <Rootobject>(File.ReadAllText(fileName)); decimal salary; int i = 1; int j = 0; foreach (var item in rootObject.rosterplayers.playerentry) { try { var name = item.player.LastName + " " + item.player.FirstName; System.Diagnostics.Debug.Write("#: " + i++ + "Id: " + item.player.ID + " " + name); Playersalary playerSalary = playerSalaries.FirstOrDefault(p => p.Player == name); if ((playerSalary == null) || (playerSalary.Salary == null)) { System.Diagnostics.Debug.Write(" " + j++ + "No Salary"); salary = 1000000; } else { salary = ( decimal )(playerSalary.Salary); } salary /= 1000000; SalaryCapData.Data.Models.Team team = new SalaryCapData.Data.Models.Team { Id = Convert.ToInt32(item.team.ID), City = item.team.City, Name = item.team.Name, Abbrev = item.team.Abbreviation }; int playerId = Convert.ToInt32(item.player.ID); SalaryCapData.Data.Models.PlayerPosition playerPosition = new SalaryCapData.Data.Models.PlayerPosition { PlayerId = playerId, Position = item.player.Position }; SalaryCapData.Data.Models.Player player = new SalaryCapData.Data.Models.Player { Id = playerId, Age = Convert.ToInt32(item.player.Age), FirstName = item.player.FirstName, LastName = item.player.LastName, IsRookie = item.player.IsRookie == "true" ? true : false, Position = item.player.Position, Team = team, TeamId = team.Id, //TotalPoints = 0, //PlayerPositions = playerPositions, InitialValue = salary }; _players.Add(player); _teams.Add(team); _players.AddPlayerPosition(playerPosition); //System.Diagnostics.Debug.Write( "\n" ); } catch (Exception ex) { System.Diagnostics.Debug.Write(ex); } System.Diagnostics.Debug.WriteLine(i + "Records Processed. " + j + "Had no salary. Delta: " + (i - j)); } }
public Group() { player = new Player(playerId, DateTime.MinValue, SystemClock.Now, "player " + playerId, string.Empty, PlayerRights.Basic); playerId++; BaseBattleStats baseBattleStats = new BaseBattleStats(type: 2000, lvl: 1, weapon: WeaponType.Sword, wpnClass: WeaponClass.Elemental, armor: ArmorType.Building3, armrClass: ArmorClass.Stone, maxHp: 500, atk: 0, splash: 0, range: 0, stealth: 0, speed: 0, groupSize: 1, carry: 0, normalizedCost: 0); StructureBaseStats structureBaseStats = new StructureBaseStats(name: "MainBuilding", spriteClass: "", type: 2000, lvl: 1, radius: 0, cost: null, baseBattleStats: baseBattleStats, maxLabor: 0, buildTime: 0, workerId: 0); StructureStats structurestats = new StructureStats(structureBaseStats); var main = new Structure(structurestats); city = Ioc.Kernel.Get <ICityFactory>() .CreateCity(id: cityId, owner: player, name: "city " + cityId, resource: Formula.Current.GetInitialCityResources(), radius: Formula.Current.GetInitialCityRadius(), ap: 0); main.ObjectId = 1; city.Add(main.ObjectId, main, false); player.Add(city); cityId++; AttackStub = new TroopStub(0, city); AttackStub.AddFormation(FormationType.Normal); obj = new TroopObject(AttackStub); using (Concurrency.Current.Lock(city)) { city.Troops.Add(AttackStub); city.Add(obj); } TroopObject = new TroopObject(AttackStub) { X = city.X, Y = city.Y }; TroopObject.BeginUpdate(); TroopObject.Stats = new TroopStats(Formula.Current.GetTroopRadius(AttackStub, null), Formula.Current.GetTroopSpeed(AttackStub)); TroopObject.EndUpdate(); city.Add(TroopObject); }