Ejemplo n.º 1
0
        public ActionResult Book(int Id)
        {
            var tamas = _tamagotchiRepository.GetAll().Where(e => e.Alive && e.Room == null && e.Money >= _roomRepository.Get(Id).Cost);

            ViewBag.Tamagotchis = new SelectList(tamas, "Id", "Name", _roomRepository.Get(Id).Tamagotchi);

            return(View(new BookingViewModel(_roomRepository.Get(Id))));
        }
Ejemplo n.º 2
0
        public ActionResult Index()
        {
            List <TamagotchiModel> AllTamagotchis      = _tamagotchiRepository.GetAll();
            List <TamagotchiModel> AliveTamagotchis    = AllTamagotchis.Where(t => t.Levend == 1).ToList();
            List <TamagotchiModel> DeadTamagotchis     = AllTamagotchis.Where(t => t.Levend == 0).ToList();
            List <TamagotchiModel> RoomlessTamagotchis = new List <TamagotchiModel>(AliveTamagotchis);

            _hotelkamerRepository.GetAll().Where(t => t.Tamagotchis.Count > 0).ToList().ForEach((h) =>
            {
                foreach (var objTamagotchi in h.Tamagotchis)
                {
                    for (int i = 0; i < RoomlessTamagotchis.Count; i++)
                    {
                        if (RoomlessTamagotchis[i].Id == objTamagotchi.Id)
                        {
                            RoomlessTamagotchis.Remove(RoomlessTamagotchis[i]);
                            i--;
                        }
                    }
                }
            });

            if (TempData["NachtComplete"] != null)
            {
                ViewBag.NachtComplete = TempData["NachtComplete"];
            }

            return(View(new HomeIndexModel()
            {
                AllTamagotchis = AllTamagotchis,
                AliveTamagotchis = AliveTamagotchis,
                DeadTamagotchis = DeadTamagotchis,
                RoomlessTamagotchis = RoomlessTamagotchis
            }));
        }
Ejemplo n.º 3
0
        public void TestCreateTamagotchi()
        {
            var tama = new Tamagotchi
            {
                Name = "Kevin"
            };

            _service.CreateTamagotchi(tama);

            Assert.IsTrue(_repo.GetAll().Any(t => t.Name == "Kevin"));
        }
Ejemplo n.º 4
0
        public List <Tamagotchi> GetAllTamagotchi()
        {
            var allTamagotchis = new List <Tamagotchi>();

            var gameStatuses = new List <IGameRule>
            {
                new SleepDeprivation(),
                new Starvation(),
                new Munchies(),
                new Crazy()
            };

            _repo.GetAll().ForEach(t =>
            {
                var tamagotchi = new Tamagotchi(t);
                gameStatuses.ForEach(g => g.Execute(tamagotchi));

                allTamagotchis.Add(tamagotchi);
            });

            return(allTamagotchis);
        }
Ejemplo n.º 5
0
 // GET: Tamagotchi
 public ActionResult Index()
 {
     _tamagotchiRepo.ForceRefresh();
     return(View(_tamagotchiRepo.GetAll().OrderByDescending(x => x.Alive)));
 }
Ejemplo n.º 6
0
 // GET: Tamagotchis
 public ActionResult Index()
 {
     return(View(_tamagotchiRepository.GetAll()));
 }
        public void StartNight()
        {
            foreach (TamagotchiViewModel t in _tamagotchiRepository.GetAll())
            {
                if (t.HotelRoom != null)
                {
                    switch (t.HotelRoom.Type)
                    {
                    case HotelRoomType.Restroom:
                        t.Pennies -= 10;
                        if (t.Health + 20 <= 100)
                        {
                            t.Health += 20;
                        }
                        else
                        {
                            t.Health = 100;
                        }
                        if (t.Boredom + 10 <= 100)
                        {
                            t.Boredom += 10;
                        }
                        else
                        {
                            t.Boredom = 100;
                        }
                        _tamagotchiRepository.SetChanged(t);
                        break;

                    case HotelRoomType.Gameroom:
                        t.Pennies -= 20;
                        t.Boredom  = 0;
                        _tamagotchiRepository.SetChanged(t);
                        break;

                    case HotelRoomType.Workroom:
                        Random r             = new Random(DateTime.Now.GetHashCode());
                        int    penniesRandom = r.Next(10, 60);
                        t.Pennies += penniesRandom;
                        if (t.Boredom + 20 <= 100)
                        {
                            t.Boredom += 20;
                        }
                        else
                        {
                            t.Boredom = 100;
                        }
                        _tamagotchiRepository.SetChanged(t);
                        break;

                    case HotelRoomType.Fightroom:
                        break;     // Gets handled at a later stage

                    case HotelRoomType.Quidditch:
                        break;     // Gets handled at a later stage
                    }
                }
                else // Homeless Tamagotchi
                {
                    if (t.Health - 20 >= 0)
                    {
                        t.Health -= 20;
                    }
                    else
                    {
                        t.Health = 0;
                    }
                    if (t.Boredom + 20 <= 100)
                    {
                        t.Boredom += 20;
                    }
                    else
                    {
                        t.Boredom = 10;
                    }
                    _tamagotchiRepository.SetChanged(t);
                }
            }
            foreach (HotelRoomViewModel h in _hotelRoomRepository.GetAll())
            {
                if (h.Type == HotelRoomType.Fightroom)
                {
                    Random r           = new Random(DateTime.Now.GetHashCode());
                    int    winnerIndex = r.Next(0, h.Tamagotchi.Count);
                    for (int i = 0; i < h.Tamagotchi.Count; i++)
                    {
                        if (i == winnerIndex)
                        {
                            h.Tamagotchi[i].Pennies += 20;
                            h.Tamagotchi[i].Level   += 1;
                        }
                        else
                        {
                            h.Tamagotchi[i].Pennies -= 20;
                            if (h.Tamagotchi[i].Health - 30 >= 0)
                            {
                                h.Tamagotchi[i].Health -= 30;
                            }
                            else
                            {
                                h.Tamagotchi[i].Health = 0;
                                h.Tamagotchi[i].Alive  = false;
                            }
                        }
                    }
                }
                else if (h.Type == HotelRoomType.Quidditch)
                {
                    Random r = new Random(DateTime.Now.GetHashCode());
                    bool   snitchAlreadyCatched = false;
                    foreach (TamagotchiViewModel t in h.Tamagotchi)
                    {
                        bool scored        = r.Next(0, 100) > 60;
                        bool damaged       = r.Next(0, 100) > 30;
                        bool catchedSnitch = false;
                        if (snitchAlreadyCatched == false)
                        {
                            catchedSnitch = r.Next(0, 100) > 5;
                        }

                        if (scored)
                        {
                            t.Pennies += 10;
                            t.Level++;
                        }
                        if (damaged)
                        {
                            t.Health -= 30;
                        }
                        if (catchedSnitch)
                        {
                            t.Pennies += 150;
                            t.Level++;
                        }
                    }
                }
                _hotelRoomRepository.SetChanged(h);
            }
            foreach (TamagotchiViewModel t in _tamagotchiRepository.GetAll())
            {
                if (t.Boredom >= 70)
                {
                    t.Health -= 20;
                }
                if (t.Health == 0)
                {
                    t.Alive = false;
                }
                t.Age++;
                t.Level++;
                t.LeaveRoom();
                _tamagotchiRepository.SetChanged(t);
            }
        }
Ejemplo n.º 8
0
        public void Start()
        {
            System.Console.Title = AppName;

            while (true)
            {
                System.Console.Clear();
                WriteHeader();
                WriteLine(WelcomeMessage);

                WriteLine();

                if (!_repo.HasData())
                {
                    ShowConnectionError();
                    return;
                }

                WriteLine(HelpMessage);
                WriteLine();

                string input = AskForInput();

                switch (input)
                {
                case "view":
                    input = StartView();
                    break;

                case "add":
                    input = StartAddView();
                    break;

                case "wereami":
                case "wai":
                case "w":
                    WriteLine(_repo.WhereAmI());
                    AskForInput("Press any button to continue");
                    break;

                case "clean":
                case "c":
                    WriteLine("Removing all dead Tamagotchis, this might take some time.", ConsoleColor.Red);
                    WriteLine();

                    var allCount  = _repo.TamagotchiCount();
                    var perPage   = _repo.TamagotchiPerPage();
                    int pagecount = allCount / perPage;

                    for (int i = 0; i < allCount; i += perPage)
                    {
                        var all = _repo.GetAll(i);
                        if (all.Count() <= 0)
                        {
                            break;
                        }

                        if (all.Any(t => t.HasDied))
                        {
                            foreach (var item in all.Where(t => t.HasDied))
                            {
                                Write(".", ConsoleColor.Red);
                                _repo.Remove(item.Name);
                            }

                            allCount  = _repo.TamagotchiCount();
                            perPage   = _repo.TamagotchiPerPage();
                            pagecount = allCount / perPage;

                            i = 0;
                        }
                    }
                    break;

                case "purge":
                case "p":
                    WriteLine("Removing all Tamagotchis, this might take some time.", ConsoleColor.Red);
                    WriteLine();

                    while (_repo.TamagotchiCount() != 0)
                    {
                        var all = _repo.GetAll(0);

                        foreach (var item in all)
                        {
                            Write(".", ConsoleColor.Red);
                            _repo.Remove(item.Name);
                        }
                    }
                    break;

                case "bulk":
                case "b":
                    WriteLine("Bulk adding Tamagotchis", ConsoleColor.Red);
                    int amount = 0;
                    int.TryParse(AskForInput("amount > "), out amount);
                    if (amount <= 0)
                    {
                        break;
                    }

                    var prefix = AskForInput("prefix > ");
                    if (string.IsNullOrWhiteSpace(prefix))
                    {
                        break;
                    }

                    for (int i = 0; i < amount; i++)
                    {
                        Write(".", ConsoleColor.Red);
                        _repo.Add($"{prefix} {i}");
                    }

                    break;

                default:
                    WriteLine("Command not recognized.", ConsoleColor.Red);
                    AskForInput("Press any button to continue");
                    break;
                }

                if (input == "quit")
                {
                    return;
                }
            }
        }
Ejemplo n.º 9
0
        public NightController(ITamagotchiRepository tamagotchiRepository)
        {
            _tamagotchiRepository = tamagotchiRepository;

            _tamagotchis = _tamagotchiRepository.GetAll();
        }
Ejemplo n.º 10
0
 public IEnumerable <TamagotchiContract> GetAllTamagotchi(int start)
 {
     return(repo.GetAll(start, TamgotchiPerPage).Select(t => new TamagotchiContract(t)));
 }
 public RoomViewModel GetRoomViewModel(int id)
 {
     return(new RoomViewModel {
         Room = _roomRepository.Get(id), AmountOfTamagotchisOptions = RoomSizeOptions.SizeOptions, Tamagotichis = _tamagotchiRepository.GetAll().Where(t => t.CurrentRoom == null).ToList()
     });
 }
Ejemplo n.º 12
0
        public static void ChangeProperties(ITamagotchiRepository tamagotchiRepository)
        {
            foreach (var t in tamagotchiRepository.GetAll())
            {
                t.Level++;

                // Standaard mutaties
                if (t.Boredom >= 70)
                {
                    t.Health -= 20;
                }

                if (t.Health <= 0)
                {
                    t.Alive = false;
                }

                if (t.CurrentRoom != null)
                {
                    // Kamer afhankelijke mutaties
                    switch (t.CurrentRoom.Type)
                    {
                    case "Chillroom":
                        t.Cents   -= 10;
                        t.Health  += 20;
                        t.Boredom += 10;
                        break;

                    case "Gameroom":
                        t.Cents  -= 10;
                        t.Boredom = 0;
                        break;

                    case "Workroom":
                        Random r            = new Random();
                        int    amountEarned = r.Next(10, 60);
                        t.Cents   += amountEarned;
                        t.Boredom += 20;
                        break;

                    case "Fightroom":
                        PickRandomWinner(tamagotchiRepository.GetAll());
                        break;

                    case "DateRoom":
                        t.Cents   -= 10;
                        t.Boredom -= 30;
                        t.Health  += 10;
                        break;

                    default:
                        // Geen kamer
                        t.Health  -= 20;
                        t.Boredom += 20;
                        break;
                    }
                }

                if (t.Health > 100)
                {
                    t.Health = 100;
                }
                if (t.Boredom > 100)
                {
                    t.Boredom = 100;
                }

                tamagotchiRepository.Update(t);
            }
        }
Ejemplo n.º 13
0
        // GET: Tamagotchis
        public ActionResult Index()
        {
            var tamagotchi = _tamagotchiRepository.GetAll();

            return(View(tamagotchi));
        }