示例#1
0
        public ViewCitizenViewModel(Entities.Citizen citizen, IList <Citizen> friends, ICitizenService citizenService, IFriendService friendService)
        {
            var entity = citizen.Entity;

            Info        = new CitizenInfoViewModel(citizen, friendService);
            Avatar      = new ImageViewModel(entity.ImgUrl);
            Name        = entity.Name;
            RegionName  = citizen.Region.Name;
            CountryName = citizen.Region.Country.Entity.Name;

            HitPoints           = citizen.HitPoints;
            Experience          = citizen.Experience;
            Level               = citizen.ExperienceLevel;
            NextLevelExperience = citizenService.CalculateExperienceForNextLevel(citizen.ExperienceLevel);

            Manufacturing = (double)citizen.Manufacturing;
            Raw           = (double)citizen.Raw;
            Selling       = (double)citizen.Selling;
            Construction  = (double)citizen.Construction;

            ExperienceProgress = (int)(Experience / (double)NextLevelExperience * 100.0);

            int militaryRank     = (int)citizen.MilitaryRank;
            int nextMilitaryRank = (MilitaryRankEnumExtensions.CalculateNextMilitaryRankNeeded(militaryRank) ?? militaryRank);

            MilitaryRank             = militaryRank.ConvertToBasicUnits();
            NextMilitaryRank         = nextMilitaryRank.ConvertToBasicUnits();
            NextMilitaryRankProgress = (int)(militaryRank / (double)nextMilitaryRank * 100.0);
            MilitaryRankIconCss      = MilitaryRankEnumExtensions.GetRankCss(MilitaryRankEnumExtensions.GetRankForMilitaryRank(militaryRank));

            Strength = string.Format("{0:0.##}", citizen.Strength);

            Medals = new MedalViewModel(citizen);

            var company = citizen.GetCurrentJob();

            if (company != null)
            {
                Job = new CitizenJobShortViewModel(company);
            }

            Friends = friends
                      .TakeRandom(4)
                      .Select(cit => new ViewCitizenFriendModel(cit))
                      .ToList();

            FriendCount = friends.Count();
        }
示例#2
0
        public CitizenSummaryViewModel(CitizenSummaryInfo info, ICitizenService citizenService)
        {
            Name       = info.Name;
            CitizenID  = info.ID;
            CanWork    = info.CanWork;
            HitPoints  = info.HitPoints;
            Experience = info.Experience;
            Trained    = info.Trained;
            Strength   = info.Strength;
            Avatar     = new ImageViewModel(info.AvatarUrl);
            JobID      = info.JobID;

            EatingSafety = info.EatingSafety;

            CountryMoney = new MoneyViewModel(info.CountryCurrencyID, (decimal)info.CountryMoneyAmount);
            AdminMoney   = new MoneyViewModel(CurrencyTypeEnum.Gold, (decimal)info.GoldAmount);
            CountryID    = info.CountryID;

            NextExperienceLevel = citizenService.CalculateExperienceForNextLevel(info.Level);

            ExperienceProgress = (int)(info.Experience / (double)NextExperienceLevel * 100.0);

            int militaryRank     = (int)info.MilitaryRank;
            int nextMilitaryRank = MilitaryRankEnumExtensions.CalculateNextMilitaryRankNeeded(militaryRank) ?? militaryRank;

            MilitaryRank             = militaryRank.ConvertToBasicUnits();
            NextMilitaryRank         = nextMilitaryRank.ConvertToBasicUnits();
            NextMilitaryRankProgress = (int)(militaryRank / (double)nextMilitaryRank * 100.0);

            UnreadMessages = info.UnreadMessages;
            UnreadWarnings = info.UnreadWarnings;

            if (HitPoints < 90 && info.CanHeal)
            {
                CanHeal = info.CanHeal;

                HealCurrency = CountryMoney.Symbol;
                HospitalID   = info.HospitalID.Value;
                FreeHealing  = info.HealingCost.HasValue == false;
                if (FreeHealing == false)
                {
                    HealCost = (double)info.HealingCost.Value;
                }
            }
        }