Beispiel #1
0
        private IDictionary <byte, GlobalPos> CheckForWinners(IMove move)
        {
            var winners = new Dictionary <byte, GlobalPos>();
            var width   = move.GetAreaWidth();
            var height  = move.GetAreaHeight();

            if (width > 0 && height > 0)
            {
                var start = move.GetAreaCorner();
                var pos   = new GlobalPos(start.X, start.Y);
                for (var y = 0; y < height; ++y)
                {
                    pos.X = start.X;
                    for (var x = 0; x < width; ++x)
                    {
                        var owner = _grid.GetSymbol(pos);
                        if (_referee.HasWon(_grid, pos) && owner != BasicChunk.NoOwner)
                        {
                            _grid.SetSymbol(pos, owner);
                            if (!winners.ContainsKey(owner))
                            {
                                winners[owner] = new GlobalPos();
                            }
                        }
                        ++pos.X;
                    }
                    ++pos.Y;
                }
            }

            return(winners);
        }