Exemplo n.º 1
0
        public Animal BuyRandomAnimal(string name, AnimalsStore store)
        {
            if (!this.state.IsStoreAccessible(store))
            {
                throw new Exception("This store is not yet aviable for your level. Middle level store is aviable on level 3, " +
                                    "Premium level store is aviable on level 10");
            }
            ApplicationRepository.GetMoneyFromrUser(user, store.GetAnimalCost());
            NotifyObservers(ActionType.MoneyChanged, user.Money);
            int    randomNumber = new Random().Next(0, 3);
            Animal animal;

            if (randomNumber == 0)
            {
                animal = store.GetBird(name, user);
            }
            else if (randomNumber == 1)
            {
                animal = store.GetMammal(name, user);
            }
            else
            {
                animal = store.GetFish(name, user);
            }
            animals.Add(animal);
            CheckLevel(animals.Count);
            return(animal);
        }
Exemplo n.º 2
0
 public bool IsStoreAccessible(AnimalsStore store)
 {
     if (store is PremiumStore)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
        public static ObservableCollection <Animal> GetAnimalsForUser(User user)
        {
            var dbAnimals = user.Animals;
            ObservableCollection <Animal> animals = new ObservableCollection <Animal>();

            foreach (DatabaseAnimal animal in dbAnimals)
            {
                animals.Add(AnimalsStore.GetAnimalFromDatabaseRecord(animal, user));
            }
            return(animals);
        }
Exemplo n.º 4
0
 public bool IsStoreAccessible(AnimalsStore store)
 {
     return(true);
 }