SnakeBattleNet.Core.FieldComparer.IsEqual C# (CSharp) Method

IsEqual() private method

private IsEqual ( Direction direction, IList chip, Fighter fighter ) : bool
direction Direction
chip IList
fighter Fighter
return bool
        private bool IsEqual(Direction direction, IList<ChipCell> chip, Fighter fighter)
        {
            var chipHead = chip.First(c => c.Content == Content.Head && c.IsSelf);

            var bools = Color.All
                .Where(color => chip.Any(c => c.Color.Name == color.Key))
                .Select(color => color.Value.IsAnd
                    ? chip
                        .Where(cell => cell.Color.Name == color.Key)
                        .All(c => IsEqual(fighter, field.RelativeCell(direction, fighter.Head, chipHead, c), c))
                    : chip
                        .Where(cell => cell.Color.Name == color.Key)
                        .Any(c => IsEqual(fighter, field.RelativeCell(direction, fighter.Head, chipHead, c), c)));

            var andType = Color.All.Any(c => c.Value.IsAnd && c.Key == chipHead.Color.Name);
            return andType
                ? bools.All(b => b)
                : bools.Any(b => b);
        }

Same methods

FieldComparer::IsEqual ( Fighter fighter, Cell fieldCell, ChipCell chipCell ) : bool