Beispiel #1
0
        public Models.Salvo salvear(SalvoView salvoView, long gamePlayerId)
        {
            GamePlayer gameplayer = _repository.FindById(gamePlayerId);
            int        ultimoTurno;

            if (gameplayer.salvos == null)
            {
                ultimoTurno = 0;
            }
            else
            {
                ultimoTurno = gameplayer.salvos.Count;
            }


            var salvo = new Models.Salvo();

            salvo.Locations = new List <SalvoLocation>();
            salvo.Turn      = ultimoTurno + 1;
            foreach (SalvoLocationView salvoVloc in salvoView.locations)
            {
                SalvoLocation SalvoLoco = new SalvoLocation();
                SalvoLoco.Location = salvoVloc.location;
                salvo.Locations.Add(SalvoLoco);
            }
            return(salvo);
        }
Beispiel #2
0
 public HitDTO(Models.Salvo salvo)
 {
     turn = salvo.Turn;
     hits = new List <HitLocationView>();
     foreach (var barquito in salvo.GamePlayer.Rival().ships)
     {
         HitLocationView hitLocationView = new HitLocationView(salvo, barquito);
         hits.Add(hitLocationView);
     }
 }
Beispiel #3
0
 public SalvoView(Models.Salvo salvo)
 {
     id        = salvo.Id;
     player    = new PlayerView(salvo.GamePlayer.Player);
     turn      = salvo.Turn;
     locations = new List <SalvoLocationView>();
     foreach (var SalvoLocation in salvo.Locations)
     {
         locations.Add(new SalvoLocationView(SalvoLocation));
     }
 }
        public List <string> getHits(Models.Salvo salvo, Ship suBarco)
        {
            List <string> efectivos = new List <string>();

            foreach (var ubicaciones in salvo.Locations)
            {
                ICollection <string> hits = PosicionesDeShipsDelRival(salvo.GamePlayer.Rival())
                                            .Where(a => a.Equals(ubicaciones.Location)).ToList();
                efectivos.AddRange(hits);
            }
            return(efectivos);
            //List<string> misTiros = PosicionesDeMisSalvos(gamePlayer);
            //List<string> misObjetivos = PosicionesDeShipsDelRival(gamePlayer.Rival());

            //List<string> myHits = misTiros.Intersect(misObjetivos).ToList();
            //return myHits;
        }
 public HitLocationView(Models.Salvo salvo, Ship suBarco)
 {
     type = suBarco.Type;
     hits = getHits(salvo, suBarco);
 }