/// <summary> /// Базовый конструктор /// Base constructor /// </summary> /// <param name="snakeFactory">Производство змеек/Snakes factory</param> /// <param name="mapSideSize">Сторона карты/Map's edge</param> /// <param name="foodCount">Максимальное колличество еды/Max amount of food</param> public GameLogicBase(HashSet <GameLogicsAttributes.GameoverPredicates> gameoverPredicates, ISnakeFactory snakeFactory, int mapSideSize, int foodCount, List <string> snakeNames, bool leftDeadSnakeBody = false, GameLogicsAttributes.Barriers barriers = GameLogicsAttributes.Barriers.None) { BarriersType = barriers; this.SnakeFactory = snakeFactory; this.SnakesForLogic = new GameLogicsAttributes.SnakesForLogic(); Map = new PlayingMap(mapSideSize, foodCount); LeftDeadSnakeBody = leftDeadSnakeBody; InitialGameoverPredicate(gameoverPredicates); if (snakeNames.Count == 0) { snakeNames.Add(nameof(PlayerArrows)); } var snakesCordinates = GetInitialSnakesCordinates(mapSideSize, snakeNames.Count); for (int i = 0; i < snakeNames.Count; i++) { var snake = snakeFactory.GetSnakeByName(snakeNames[i], snakesCordinates[i]); snake.ID = i; SnakesForLogic.Snakes.Add(snake); } foreach (var snake in SnakesForLogic.Snakes) { Map.Snake.Add(new PlayingMapAttributes.Snake(snake.SnakeName, snake.SnakeBody, snake, snake.Statistics)); } InsertBarriers(Map); InsertFood(Map); }
public CustomisingLogic(HashSet <GameLogicsAttributes.GameoverPredicates> gameoverPredicates, List <string> snakeNames, ISnakeFactory snakeFactory, int mapSideSize, int foodCount, bool leftDeadSnakeBody, GameLogicsAttributes.Barriers barriers = GameLogicsAttributes.Barriers.None) : base(gameoverPredicates, snakeFactory, mapSideSize, foodCount, snakeNames, leftDeadSnakeBody, barriers) { var situations = SituationsInit.Instance.GetSituationsObjects(); AchievedLength = situations.AchievedLength; CollisionWithBarrier = situations.CollisionWithBarrier; CollisionWithFood = situations.CollisionWithFood; CollisionWithSnake = situations.CollisionWithSnake; DidStepsWithoutFood = situations.DidStepsWithoutFood; }