Exemplo n.º 1
0
        public static ShotResult CreateMisfire(string reason)
        {
            var result = new ShotResult(false, false)
            {
                MisfireReason = reason
            };

            return(result);
        }
Exemplo n.º 2
0
        public static ShotResult CreateHit(IShip ship, bool reportSunkenShip = false)
        {
            var result = new ShotResult(true, true);

            if (ship.HasSunk && reportSunkenShip)
            {
                result.SunkenShip = ship;
            }

            return(result);
        }
Exemplo n.º 3
0
        public void ProcessShotResult(Coordinates coords, ShotResult result)
        {
            var field = EnemyBoard.Fields.At(coords.Row, coords.Column);

            switch (result)
            {
            case ShotResult.Hit:
                field.FieldType = FieldType.Hit;
                break;

            case ShotResult.Sunk:
                field.FieldType = FieldType.Hit;
                break;

            default:
                field.FieldType = FieldType.Miss;
                break;
            }
        }