Пример #1
0
        public smallRecord UpdateByLocation(Model.Weather p)
        {
            if (p == null)
            {
                throw new ArgumentNullException(nameof(p));
            }

            smallRecord rec = new smallRecord();

            rec.location = new Location();

            var stored = weather.FirstOrDefault(x => x.location.lat == p.location.lat && x.location.lon == p.location.lon &&
                                                x.date == p.date);

            if (stored == null)
            {
                rec.id = -1;
            }
            else
            {
                rec.id             = p.id;
                rec.date           = p.date;
                rec.location.city  = p.location.city;
                rec.location.state = p.location.state;
            }

            weather.RemoveAll(x => x.id == stored.id);
            weather.Add(p);
            return(rec);
        }
Пример #2
0
        public static Weather Create(Model.Weather weather, int turnCount)
        {
            switch (weather)
            {
            case Model.Weather.ClearSkies: return(new ClearSkies(turnCount));

            case Model.Weather.ExtremelyHarshSunlight: return(new ExtremelyHarshSunlight(turnCount));

            case Model.Weather.Fog: return(new Fog(turnCount));

            case Model.Weather.Hail: return(new Hail(turnCount));

            case Model.Weather.HarshSunlight: return(new HarshSunlight(turnCount));

            case Model.Weather.HeavyRain: return(new HeavyRain(turnCount));

            case Model.Weather.MysteriousAirCurrent: return(new MysteriousAirCurrent(turnCount));

            case Model.Weather.Rain: return(new Rain(turnCount));

            case Model.Weather.Sandstorm: return(new Sandstorm(turnCount));

            default: throw new ArgumentException($"Unsupported weather type {weather.ToString()}", "weather");
            }
        }
Пример #3
0
        public SplashScreenViewModel()
        {
            weatherService = WeatherService.Instance;
            FlightService flightService = FlightService.Instance;

            Flight                  = flightService.Flight;
            WeatherBestemming       = weatherService.WeatherBestemming;
            WeatherOrigin           = weatherService.WeatherOrigin;
            Flight.PropertyChanged += Flight_PropertyChanged;
        }
Пример #4
0
        public async void getWeather(String plaats, Model.Weather weather)
        {
            RootObject myWeather = await OpenWeatherMapProxy.GetWeather(plaats);

            string icon = String.Format("ms-appx:///Assets/Weather/{0}.png", myWeather.weather[0].icon);

            weather.Naam        = plaats;
            weather.Temperatuur = ((int)myWeather.main.temp).ToString() + "°";
            weather.Description = myWeather.weather[0].description;
            weather.Icon        = new BitmapImage(new Uri(icon, UriKind.Absolute));
        }
Пример #5
0
        public bool Create(Model.Weather p)
        {
            if (p == null)
            {
                throw new ArgumentNullException(nameof(p));
            }

            if (weather.Any(x => x.id == p.id))
            {
                return(false);
            }

            weather.Add(p);
            return(true);
        }
Пример #6
0
        public Battle(Random rng, IInputProvider inputProvider, Model.Weather weather, IEnumerable <Team> teams)
        {
            if (teams == null)
            {
                throw new ArgumentNullException("teams");
            }
            if (teams.ContainsNull())
            {
                throw new ArgumentException("A BattleTeam in a Battle cannot be null");
            }
            if (teams.ContainsDuplicates())
            {
                throw new ArgumentException("A battle cannot contain duplicate teams");
            }
            if (teams.AnyOverlaps())
            {
                throw new ArgumentException("2 or more teams contain overlapping trainers");
            }
            if (teams.Count() < 2)
            {
                throw new ArgumentException("There must be at least 2 teams in a battle");
            }

            //Going to attempt to not enforce this
            //if (teams.Any(x => x.SlotCount != teams[0].SlotCount)) throw new ArgumentException("All teams must have the same number of slots for the battle");

            Teams              = new List <Team>(teams).AsReadOnly();
            InputProvider      = inputProvider;
            RNG                = rng;
            SurroundingWeather = weather;

            effects = new List <Effect>();
            Effects = (effects as List <Effect>).AsReadOnly();

            actionRequests = new List <Request>();

            MessageQueue = new Messaging.Queue();
            MessageQueue.AddSubscriber(this);

            ActionComparer = new Actions.Comparer(RNG);
            currentState   = State.START;
            TurnCounter    = 1;

            CurrentWeather = SurroundingWeather;

            BattleArgs = new EventArgs(this);
        }
Пример #7
0
        public void Update(Model.Weather p)
        {
            if (p == null)
            {
                throw new ArgumentNullException(nameof(p));
            }

            var stored = weather.FirstOrDefault(x => x.id == p.id);

            if (stored == null)
            {
                throw new KeyNotFoundException($"An object of a type '{nameof(Model.Weather)}' with the key '{p.id}' not found");
            }

            weather.RemoveAll(x => x.id == stored.id);
            weather.Add(Mapper.Map <Model.Weather>(p));
        }
Пример #8
0
 static void AnalyseWeather(Model.Weather weather)
 {
     AnalyseCurrent(weather.Current);
     AnalyseForecast(weather.Forecast);
 }
Пример #9
0
 public Battle(Random rng, IInputProvider inputProvider, Model.Weather weather, params Team[] teams) : this(rng, inputProvider, weather, teams as IEnumerable <Team>)
 {
 }
Пример #10
0
 public Battle(IInputProvider inputProvider, Model.Weather weather, IEnumerable <Team> teams) : this(new Random(), inputProvider, weather, teams)
 {
 }
Пример #11
0
 public static ViewModel.CommonCityView ConvertToCommonCityView(Model.UserCity city, Model.WeatherType type, Model.Weather weather)
 {
     ViewModel.CommonCityView view = new ViewModel.CommonCityView();
     view.CityId   = city.CityId;
     view.CityName = city.CityName;
     view.TodayPic = (weather == null || type == null) ? null : type.TodayPic;
     view.Temp     = weather == null ? null : weather.today.temperature;
     return(view);
 }
Пример #12
0
 public WeatherChange(Model.Weather weather, int turnCount)
 {
     Weather   = weather;
     TurnCount = turnCount;
 }
Пример #13
0
 private WeatherService()
 {
     WeatherBestemming = new Model.Weather();
     WeatherOrigin     = new Model.Weather();
 }