private bool _WillMoveToDifferentUnit(ISentientEntity entity, ISentientEntity unit, List <WorldRequest> proposedRequests)
        {
            WorldRequest unitRequest   = GetEntityRequest(unit, proposedRequests);
            WorldRequest entityRequest = GetEntityRequest(entity, proposedRequests);

            if (unitRequest == null)
            {
                return(false);
            }

            //if(_PredictOutcome(unitRequest) == _PredictOutcome(entityRequest))
            //{
            //    return true;
            //}

            // Will other entity walk onto this entity
            var entityPossibility = _GetEntityAt(_TheRoom, _GetCurrentLocation(unit, _TheRoom), unit.CurrentDirection, 1);

            if (entityPossibility == entity)
            {
                return(false);
            }

            //Should be false when entity tries to move thru another.
            return(true);
        }
        private bool _IsValid(WorldRequest request, List <WorldRequest> proposedRequests)
        {
            switch (request.Request)
            {
            case ActionRequest.WalkForward:
                var entity         = request.Entity as ISentientEntity;
                var entityLocation = GetCoordinatesOf(entity, _TheRoom);
                var proposedUnit   = _GetEntityAt(_TheRoom, entityLocation, entity.CurrentDirection, 1) as ISentientEntity;

                // If no entity in unit then we're set!
                if (proposedUnit == null)
                {
                    return(true);
                }
                // If there's an entity in the unit but it's going to
                // move then we're set!
                if (proposedUnit != null && _WillMoveToDifferentUnit(entity, proposedUnit, proposedRequests))
                {
                    return(true);
                }

                return(false);

            default:
                return(true);
            }
        }
        private WorldCoordinates _PredictOutcome(WorldRequest request)
        {
            if (request.Request == ActionRequest.WalkForward)
            {
                //return _GetCoordinatesAt(_TheRoom, _GetCurrentLocation(request.Entity, _TheRoom), request.Entity);
            }

            return(null);
        }
        private WorldRequest GetEntityRequest(ISentientEntity entity, List <WorldRequest> proposedRequests)
        {
            WorldRequest unitRequest = null;

            foreach (var request in proposedRequests)
            {
                if (request.Entity == entity)
                {
                    unitRequest = request;
                    break;
                }
            }
            return(unitRequest);
        }
        private WorldResponse _Process(WorldRequest request)
        {
            switch (request.Request)
            {
            case ActionRequest.WalkForward:
                // We should have a guarantee at this point that this cast
                // is a valid one.
                MoveForward(request.Entity as ISentientEntity, _TheRoom);
                break;

            case ActionRequest.TurnLeft:
                Turn(request.Entity as ISentientEntity, RelativeDirections.ToTheLeftSide);
                break;

            default:
                new GeneralGameException("This request can not be processed.");
                break;
            }
            return(new WorldResponse(request.Entity, request.TheRoom));
        }
 private WorldResponse _Process(WorldRequest request)
 {
     switch (request.Request)
     {
         case ActionRequest.WalkForward:
             // We should have a guarantee at this point that this cast
             // is a valid one.
             MoveForward(request.Entity as ISentientEntity, _TheRoom);
             break;
         case ActionRequest.TurnLeft:
             Turn(request.Entity as ISentientEntity, RelativeDirections.ToTheLeftSide);
             break;
         default:
             new GeneralGameException("This request can not be processed.");
             break;
     }
     return new WorldResponse(request.Entity, request.TheRoom);
 }
        private WorldCoordinates _PredictOutcome(WorldRequest request)
        {
            if(request.Request == ActionRequest.WalkForward)
            {

                //return _GetCoordinatesAt(_TheRoom, _GetCurrentLocation(request.Entity, _TheRoom), request.Entity);
            }

            return null;
        }
        private bool _IsValid(WorldRequest request, List<WorldRequest> proposedRequests)
        {
            switch(request.Request)
            {
                case ActionRequest.WalkForward:
                    var entity = request.Entity as ISentientEntity;
                    var entityLocation = GetCoordinatesOf(entity, _TheRoom);
                    var proposedUnit = _GetEntityAt(_TheRoom, entityLocation, entity.CurrentDirection, 1) as ISentientEntity;

                    // If no entity in unit then we're set!
                    if(proposedUnit == null) return true;
                    // If there's an entity in the unit but it's going to
                    // move then we're set!
                    if(proposedUnit != null && _WillMoveToDifferentUnit(entity, proposedUnit, proposedRequests))
                    {
                        return true;
                    }

                    return false;
                default:
                    return true;
            }
        }