Exemple #1
0
        private static List <DAL.Ship> ConvertShips(DAL.Player player, List <Ship> domainShips)
        {
            var dalShips = new List <DAL.Ship>();

            // Convert all Domain ships to DAL ship objects
            foreach (var domainShip in domainShips)
            {
                var dalShip = new DAL.Ship {
                    Player       = player,
                    Title        = domainShip.Title,
                    Symbol       = domainShip.Symbol,
                    Size         = domainShip.Size,
                    Direction    = (int)domainShip.Direction,
                    ShipStatuses = null,
                    X            = domainShip.ShipPos.X,
                    Y            = domainShip.ShipPos.Y
                };

                dalShip.ShipStatuses = ConvertShipStatus(dalShip, domainShip.ShipStatuses);

                dalShips.Add(dalShip);
            }

            return(dalShips);
        }
Exemple #2
0
        private static HashSet <DAL.MovesAgainstPlayer> ConvertMovesAgainstPlayer(DAL.Player player,
                                                                                  HashSet <Pos> domainMoves)
        {
            var dalMoves = new HashSet <DAL.MovesAgainstPlayer>();

            // Convert all Domain positions to DAL position objects
            foreach (var domainMove in domainMoves)
            {
                var dalMove = new DAL.MovesAgainstPlayer {
                    Player = player,
                    X      = domainMove.X,
                    Y      = domainMove.Y
                };

                dalMoves.Add(dalMove);
            }

            return(dalMoves);
        }
Exemple #3
0
        private static List <DAL.Player> ConvertPlayers(DAL.Game game)
        {
            var dalPlayers = new List <DAL.Player>();

            // Convert all Domain players to DAL player objects
            foreach (var domainPlayer in GameSystem.ActiveGame.Players)
            {
                var dalPlayer = new DAL.Player {
                    Name = domainPlayer.Name,
                    MovesAgainstThisPlayer = null,
                    Ships = null,
                    Game  = game
                };

                dalPlayer.MovesAgainstThisPlayer =
                    ConvertMovesAgainstPlayer(dalPlayer, domainPlayer.MovesAgainstThisPlayer);
                dalPlayer.Ships = ConvertShips(dalPlayer, domainPlayer.Ships);

                dalPlayers.Add(dalPlayer);
            }

            return(dalPlayers);
        }
Exemple #4
0
        public override int Create(Models.PlayerViewModel model)
        {
            var player = new DAL.Player()
            {
                AttackMax           = model.AttackMax,
                CharacterTypeId     = model.CharacterTypeId.Value,
                AttackMin           = model.AttackMin,
                PlayerId            = model.PlayerId,
                CurrentLife         = model.CurrentLife,
                MaxLife             = model.MaxLife,
                SpeedRun            = model.SpeedRun,
                SpeedWalk           = model.SpeedWalk,
                IsBeingControllable = model.IsBeingControllable,
                PlayerMode          = model.PlayerMode.Value,
                InitialX            = model.InitialX,
                InitialY            = model.InitialY,
                LastMoviment        = (int)model.LastMoviment.Value,
                IsTank = model.IsTank
            };

            ListContext.Add(player);
            return(player.PlayerId);
        }