public ActionResult GiveMeVoting() { var citizen = citizenRepository.GetById(SessionHelper.LoggedCitizen.ID); foreach (var cong in citizen.Congressmen.ToList()) { cong.LastVotingDay = GameHelper.CurrentDay - 1; } citizenRepository.SaveChanges(); return(RedirectToHome()); }
public ActionResult GiveMeHealth() { ICitizenRepository citizenRepository = DependencyResolver.Current.GetService <ICitizenRepository>(); var citizen = citizenRepository.GetById(SessionHelper.LoggedCitizen.ID); citizen.HitPoints = 100; citizen.Worked = false; citizenRepository.SaveChanges(); return(RedirectToHome()); }
private void processCitizens() { var citizens = citizenRepository.GetAll().ToList(); for (int i = 0; i < citizens.Count; ++i) { var citizen = citizens[i]; if (citizen.Worked == false) { citizen.DayWorkedRow = 0; } citizen.Worked = false; if (citizen.HasFood()) { var bread = citizen.GetBestBread(); equipmentRepository.RemoveEquipmentItem(citizen.Entity.EquipmentID.Value, bread.ProductID, bread.Quality); citizen.AddHealth(bread.Quality * 2); } else { citizen.HitPoints -= 10; if (citizen.HitPoints < 0) { citizen.HitPoints = 0; } } citizen.Trained = false; citizen.UsedHospital = false; citizen.DrankTeas = 0; using (NoSaveChanges) walletService.AddMoney(citizen.Entity.WalletID, new structs.Money((int)CurrencyTypeEnum.Gold, 0.5m)); } citizenRepository.SaveChanges(); }
public Citizen CreateCitizen(RegisterInfo info) { var entity = entitiesService.CreateEntity(info.Name, EntityTypeEnum.Citizen); entity.Equipment.ItemCapacity = 25; var country = countriesRepository.GetById(info.CountryID); Citizen citizen = new Citizen() { BirthDay = configurationRepository.GetCurrentDay(), CreationDate = DateTime.Now, CitizenshipID = info.CountryID, Email = info.Email, RegionID = info.RegionID, Verified = true, PlayerTypeID = (int)info.PlayerType, ID = entity.EntityID, HitPoints = 100 }; using (NoSaveChanges) SetPassword(citizen, info.Password); var currency = Persistent.Countries.GetCountryCurrency(country); walletService.AddMoney(entity.WalletID, new Money(currency, 50)); walletService.AddMoney(entity.WalletID, new Money(GameHelper.Gold, 5)); equipmentService.GiveItem(ProductTypeEnum.Bread, 5, 1, entity.Equipment); citizenRepository.Add(citizen); citizenRepository.SaveChanges(); Money citizenFee = new Money(Persistent.Currencies.GetById(country.CurrencyID), country.CountryPolicy.CitizenFee); if (walletService.HaveMoney(country.Entity.WalletID, citizenFee)) { Transaction feeTransaction = new Transaction() { Arg1 = "Citizen Fee", Arg2 = info.Name, DestinationEntityID = citizen.ID, Money = citizenFee, SourceEntityID = country.ID, TransactionType = TransactionTypeEnum.CitizenFee }; transactionService.MakeTransaction(feeTransaction); } else { string citMessage = "Your country did not have enough money to give you birth starting money."; warningService.AddWarning(citizen.ID, citMessage); var citLink = EntityLinkCreator.Create(citizen.Entity); string countryMessage = $"You did not have enough money to give birth starting money to {citLink}."; warningService.AddWarning(country.ID, countryMessage); } string welcomeMessage = country.GreetingMessage; var thread = messageService.CreateNewThread(new List <int> { citizen.ID, country.ID }, "Welcome message"); var smp = new SendMessageParams() { AuthorID = country.ID, Content = welcomeMessage, Date = DateTime.Now, Day = GameHelper.CurrentDay, ThreadID = thread.ID }; messageService.SendMessage(smp); return(citizen); }