public MatchConfig(MatchConfig copy) { StartingShips = new ShipList(copy.StartingShips); NumberOfRounds = copy.NumberOfRounds; FieldSize = copy.FieldSize; TimeLimit = copy.TimeLimit; GameMode = copy.GameMode; Random = copy.Random; }
/// <summary> /// Does nothing, but makes it so only deriving classes may create a <see cref="MatchInfo"/>. /// </summary> public MatchInfo(MatchConfig conf, List<Register> registers) { fieldSize = conf.FieldSize; gameMode = conf.GameMode; initShips = conf.StartingShips; methodTimeLimit = conf.TimeLimit; controllerNames = new List<string>(); foreach (var reg in registers) { controllerNames.Add(reg.Name); } }
/// <summary> /// Does nothing, but makes it so only deriving classes may create a <see cref="MatchInfo"/>. /// </summary> public MatchInfo(MatchConfig conf, List <Register> registers) { fieldSize = conf.FieldSize; gameMode = conf.GameMode; initShips = conf.StartingShips; methodTimeLimit = conf.TimeLimit; controllerNames = new List <string>(); foreach (var reg in registers) { controllerNames.Add(reg.Name); } }
public void SetConfiguration(Configuration config) { Config = config; var newConfig = new MatchConfig(); newConfig.FieldSize = new Coordinates(Config.GetValue<int>("mbc_field_width"), Config.GetValue<int>("mbc_field_height")); newConfig.NumberOfRounds = Config.GetValue<int>("mbc_match_rounds"); var initShips = new ShipList(); foreach (var length in Config.GetList<int>("mbc_ship_sizes")) { initShips.Add(new Ship(length)); } newConfig.StartingShips = initShips; newConfig.TimeLimit = Config.GetValue<int>("mbc_player_timeout"); newConfig.GameMode = 0; foreach (var mode in Config.GetList<GameMode>("mbc_game_mode")) { newConfig.GameMode |= mode; } if (!newConfig.GameMode.HasFlag(GameMode.Classic)) { throw new NotImplementedException("The " + newConfig.GameMode.ToString() + " game mode is not supported."); } newConfig.Random = new Random(); ApplyEvent(new MatchConfigChangedEvent(newConfig)); }