Esempio n. 1
0
 public CharacterViewModel(Character character)
 {
     PlayerId = character.Player.Id;
     Player = character.Player;
     CharacterName = character.Name;
     SelectedRace = character.Race.Id;
     SelectedSkills = character.Skills.Select(x => x.Id).ToList();
     SelectedCategories = character.Categories.Select(x => x.Id).ToList();
     CharacterId = character.Id;
     NbPresences = character.Presences.Count;
     SelectedLegacySkills = character.Legacy.LegacySkills.Select(x => x.Id).ToList();
 }
Esempio n. 2
0
        public DebriefingViewModel(Character character)
        {
            Gold = character.GoldPiecesFromInfluence();
            Ressources = character.RessourceFromInfluence();

            var bonuses = character.Skills.SelectMany(x => x.Bonus).Select(x => x.Bonus).ToList();

            var categories = character.Categories.Select(x => x.Id);

            bonuses.AddRange(character.Race.Skills
                .Where(x => x.Category == null || categories.Contains(x.Category.Id))
                .SelectMany(x => x.Bonus).Select(x=> x.Bonus));

            Minors = bonuses.Count(x => x == Bonus.ThreeMinor)*3 + bonuses.Count(x => x == Bonus.ExtraMinor) ;
            Majors = bonuses.Count(x => x == Bonus.TwoMajor)*3 + bonuses.Count(x => x == Bonus.ExtraMajor);
        }
Esempio n. 3
0
 public void UpdateFrom(Character character)
 {
 }
Esempio n. 4
0
        public ActionResult Create(CharacterViewModel data)
        {
            if (!ModelState.IsValid)
                return View(data);

            var year = _session.Set<Year>().First(x => x.Current);

            var player = _session.SingleById<Player>(data.PlayerId);

            var skills = _session.Set<Skill>()
                .Where(x => data.SelectedSkills.Contains(x.Id))
                .ToList();

            var legacySkills = _session.Set<LegacySkill>()
                .Where(x => data.SelectedLegacySkills.Contains(x.Id))
                .ToList();

            var race = _session.SingleById<Race>(data.SelectedRace);

            var categories = _session.Set<Category>()
                .Where(x => data.SelectedCategories.Contains(x.Id))
                .ToList();

            var legacyTrees = new List<LegacyTree>();
            if (legacySkills.Any())
            {
                legacyTrees = _session.Set<LegacyTree>()
                    .Where(x => x.Skills
                        .Any(y => data.SelectedLegacySkills.Contains(y.Id)))
                    .ToList();
            }
            else
            {
                legacyTrees = categories.SelectMany(x => x.Legacies).ToList();
            }

            var currentEvent = year.Events.First(x => x.NextEvent);
            _session.Attach(currentEvent);

            var character = new Character
            {
                Player = player,
                Name = data.CharacterName,
                Race = race,
                Categories = categories,
                Skills = skills,
                Legacy = new Legacy
                {
                    LegacySkills = legacySkills,
                    LegacyAvailable = legacyTrees
                },
                Year = year,
                Presences = new List<Event> { currentEvent },
                Influence = 1 + (race.Skills.SelectMany(x => x.Bonus).Select(w => w.Bonus).Count(x => x == Bonus.ExtraInfluence) * 3),
                Experience = 1 + (race.Skills.SelectMany(x => x.Bonus).Select(w => w.Bonus).Count(x => x == Bonus.ExtraXP) * 5)
            };

            _session.Add(character);
            currentEvent.Attendees.Add(character);
            _session.Commit();

            return View("Debriefing", new DebriefingViewModel(character));
        }