示例#1
0
    /// <summary>
    /// gets the players currents area table for the area they are in
    /// </summary>
    /// <param name="prPlayer">used to correctly select the current area the player is in by using the email</param>
    /// <returns>returns the players current area table</returns>
    public string GetDirectionsPossible(Player prPlayer)
    {
        TablePlayer lcPlayer = _connection.Table <TablePlayer>().Where(x => x.Email == prPlayer._email).FirstOrDefault();
        TableArea   lcArea   = _connection.Table <TableArea>().Where(x => x.AreaName == lcPlayer.CurrentArea).FirstOrDefault();

        string lcDecisions = null;

        if (lcArea.North != null)
        {
            lcDecisions = lcDecisions + "\n" + "go north";
        }

        if (lcArea.South != null)
        {
            lcDecisions = lcDecisions + "\n" + "go south";
        }

        if (lcArea.East != null)
        {
            lcDecisions = lcDecisions + "\n" + "go east";
        }

        if (lcArea.West != null)
        {
            lcDecisions = lcDecisions + "\n" + "go west";
        }

        return(lcDecisions);
    }
        private List <TableArea> GetChilds(TableArea model, List <TableArea> models)
        {
            var childs = models.Where(x => x.ParentId == model.Id).ToList();

            childs.ForEach(x =>
            {
                x.children = GetChilds(x, models);
            });

            return(childs.ToList());
        }
        public ResponseDto <Boolean> Remove([FromBody] TableArea request)
        {
            ResponseDto <Boolean> response = new ResponseDto <Boolean>();

            if (string.IsNullOrEmpty(request.Id.ToStringExtension()))
            {
                response.Message = "Key 不能为空";
                response.Success = false;
                return(response);
            }

            var _entity = _appSystemServices.GetEntitys <TableArea>();

            response.Data = _entity.Where(x => x.Id == request.Id).ToDelete().ExecuteAffrows() > 0;

            return(response);
        }
        public ResponseDto <TableArea> Save([FromBody] TableArea request)
        {
            ResponseDto <TableArea> response = new ResponseDto <TableArea>();
            var _entity = _appSystemServices.GetEntitys <TableArea>();

            request.CompanyId = CurrentUser.CompanyId;
            if (string.IsNullOrEmpty(request.Id.ToStringExtension()) || request.Id.ToInt32() == 0)
            {
                request.SetCreateDefault(this.CurrentUser);
                _appSystemServices.Create <TableArea>(request);
            }
            else
            {
                request.SetModifyDefault(this.CurrentUser);
                _appSystemServices.Modify <TableArea>(request);
            }
            return(response);
        }
示例#5
0
    /// <summary>
    /// Attemps to move player in direction specified by parameter
    /// </summary>
    /// <param name="prDirection">Direction passed in by the command processor</param>
    /// <returns>returns true or false dependant on if the move command was successful</returns>
    public bool Move(DIRECTION prDirection, string prEmail)
    {
        //get player for current area
        TablePlayer lcPlayer = _connection.Table <TablePlayer>().Where(x => x.Email == prEmail).FirstOrDefault();

        //get area table to check for direction entry
        TableArea lcArea = _connection.Table <TableArea>().Where(x => x.AreaName == lcPlayer.CurrentArea).FirstOrDefault();

        if (prDirection == DIRECTION.North)
        {
            //return false if no north movement found
            if (lcArea.North == null)
            {
                return(false);
            }
            else
            {
                //if direction found change current area to the corresponding area in that direction
                //update in database
                //return true
                lcPlayer.CurrentArea = lcArea.North;
                _connection.Update(lcPlayer);
                return(true);
            }
        }
        else if (prDirection == DIRECTION.South)
        {
            //return false if no south movement found
            if (lcArea.South == null)
            {
                return(false);
            }
            else
            {
                //if direction found chang current area to the corresponding area in that direction
                //update in database
                //return true
                lcPlayer.CurrentArea = lcArea.South;
                _connection.Update(lcPlayer);
                return(true);
            }
        }
        else if (prDirection == DIRECTION.East)
        {
            //return false if no East movement found
            if (lcArea.East == null)
            {
                return(false);
            }
            else
            {
                //if direction found chang current area to the corresponding area in that direction
                //update in database
                //return true
                lcPlayer.CurrentArea = lcArea.East;
                _connection.Update(lcPlayer);
                return(true);
            }
        }
        else if (prDirection == DIRECTION.West)
        {
            //return false if no West movement found
            if (lcArea.West == null)
            {
                return(false);
            }
            else
            {
                //if direction found chang current area to the corresponding area in that direction
                //update in database
                //return true
                lcPlayer.CurrentArea = lcArea.West;
                _connection.Update(lcPlayer);
                return(true);
            }
        }
        else
        {
            return(false);
        }
    }