Example #1
0
        public static void AddMindControl(Player attacker, Player victim, int formSourceId)
        {
            IMindControlRepository mcRepo     = new EFMindControlRepository();
            IPlayerRepository      playerRepo = new EFPlayerRepository();
            var dbVictim = playerRepo.Players.FirstOrDefault(p => p.Id == victim.Id);

            var mc = mcRepo.MindControls.FirstOrDefault(m => m.VictimId == victim.Id && m.MasterId == attacker.Id && m.FormSourceId == formSourceId);

            if (mc == null)
            {
                mc = new MindControl
                {
                    TurnsRemaining = 6,
                    MasterId       = attacker.Id,
                    VictimId       = victim.Id,
                    FormSourceId   = formSourceId
                };
            }
            else
            {
                mc.TurnsRemaining = 6;
            }



            mcRepo.SaveMindControl(mc);

            dbVictim.MindControlIsActive = true;
            playerRepo.SavePlayer(dbVictim);
        }
Example #2
0
        public static void AddCommandUsedToMindControl(Player master, Player victim, int formSourceId)
        {
            IMindControlRepository mcRepo = new EFMindControlRepository();
            var mc = mcRepo.MindControls.FirstOrDefault(m => m.MasterId == master.Id && m.VictimId == victim.Id && m.FormSourceId == formSourceId);

            mc.TimesUsedThisTurn++;
            mcRepo.SaveMindControl(mc);
        }
Example #3
0
        public static bool ClearPlayerMindControlFlagIfOn(Player player)
        {
            IMindControlRepository mcRepo     = new EFMindControlRepository();
            IPlayerRepository      playerRepo = new EFPlayerRepository();

            if (mcRepo.MindControls.Any(m => m.VictimId == player.Id))
            {
                return(false);
            }
            var dbPlayer = playerRepo.Players.FirstOrDefault(p => p.Id == player.Id);

            if (dbPlayer == null)
            {
                return(false);
            }
            dbPlayer.MindControlIsActive = false;
            playerRepo.SavePlayer(dbPlayer);
            return(true);
        }
Example #4
0
        public static IEnumerable <MindControlViewModel> GetAllMindControlVMsWithPlayer(Player player)
        {
            IMindControlRepository mcRepo = new EFMindControlRepository();
            var mcs = mcRepo.MindControls.Where(m => m.MasterId == player.Id || m.VictimId == player.Id).ToList();

            var output = new List <MindControlViewModel>();

            foreach (var mc in mcs)
            {
                var addme = new MindControlViewModel
                {
                    MindControl      = mc,
                    Victim           = PlayerProcedures.GetPlayerFormViewModel(mc.VictimId),
                    Master           = PlayerProcedures.GetPlayerFormViewModel(mc.MasterId),
                    TypeFriendlyName = GetMCFriendlyName(mc.FormSourceId),
                };
                output.Add(addme);
            }
            return(output);
        }
Example #5
0
        public static IEnumerable <MindControl> GetAllMindControlledByPlayer(Player player)
        {
            IMindControlRepository mcRepo = new EFMindControlRepository();

            return(mcRepo.MindControls.Where(m => m.MasterId == player.Id));
        }
Example #6
0
        public static bool PlayerIsMindControlledWithType(Player player, int formSourceId)
        {
            IMindControlRepository mcRepo = new EFMindControlRepository();

            return(mcRepo.MindControls.Any(p => p.VictimId == player.Id && p.FormSourceId == formSourceId));
        }
Example #7
0
        public static IEnumerable <MindControl> GetMindControlsBetweenPlayers(Player master, Player victim)
        {
            IMindControlRepository mcRepo = new EFMindControlRepository();

            return(mcRepo.MindControls.Where(m => m.MasterId == master.Id && m.VictimId == victim.Id));
        }