예제 #1
0
 public void ExceptionsTest()
 {
     Assert.Throws <HivemindException>(() => HivemindException.GangerNotFoundException(-1));
     Assert.Throws <HivemindException>(() => HivemindException.NoSuchInjuryException(-1));
     Assert.Throws <HivemindException>(() => HivemindException.NoSuchGangHouse());
     Assert.Throws <HivemindException>(() => HivemindException.InvalidUsernameOrPassword());
 }
예제 #2
0
        private void AuthenticateUser(Entities.Login user, Entities.Login userFromDatabase)
        {
            if (user == null || user.Email == null || userFromDatabase == null)
            {
                HivemindException.InvalidUsernameOrPassword();
            }

            if (!BCrypt.Net.BCrypt.Verify(user.Password, userFromDatabase.Password))
            {
                HivemindException.InvalidUsernameOrPassword();
            }
        }
예제 #3
0
        /// <summary>
        /// Get a user by ID
        /// </summary>
        /// <param name="userGuid">User GUID</param>
        /// <returns>User</returns>
        public Contracts.User GetUser(string userGuid)
        {
            if (string.IsNullOrEmpty(userGuid))
            {
                HivemindException.InvalidUsernameOrPassword();
            }

            var user         = _userProvider.GetUserByGuid(userGuid);
            var userContract = user.ToContract();

            GetUserGangs(ref userContract);

            return(userContract);
        }
예제 #4
0
        /// <summary>
        /// Gets the effect of a given injury
        /// </summary>
        /// <param name="injuryId">Injury ID</param>
        /// <returns>A function that alters a ganger based on injury criteria</returns>
        public Func <Ganger, Ganger> GetInjuryEffect(int injuryId)
        {
            switch ((InjuryEnum)injuryId)
            {
            case InjuryEnum.Dead:
                return(HasDied);

            case InjuryEnum.MultipleInjuries:
                return(NoStatsEffect);

            case InjuryEnum.ChestWound:
                return(HasChestWound);

            case InjuryEnum.LegWound:
                return(HasLegWound);

            case InjuryEnum.ArmWound:
                return(HasArmWound);

            case InjuryEnum.HeadWound:
                return(HasHeadWound);

            case InjuryEnum.BlindedInOneEye:
                return(HasBlindedInOneEye);

            case InjuryEnum.PartiallyDeafened:
                return(HasPartiallyDeafened);

            case InjuryEnum.ShellShock:
                return(HasShellShock);

            case InjuryEnum.HandInjury:
                return(HasHandInjury);

            case InjuryEnum.OldBattleWound:
                return(HasOldBattleWound);

            case InjuryEnum.FullRecovery:
                return(NoStatsEffect);

            case InjuryEnum.BitterEnmity:
                return(HasBitterEnmity);

            case InjuryEnum.Captured:
                return(IsCaptured);

            case InjuryEnum.HorribleScars:
                return(HasHorribleScars);

            case InjuryEnum.ImpressiveScars:
                return(HasImpressiveScars);

            case InjuryEnum.SporeSickness:
                return(SporeSickness);

            case InjuryEnum.SurvivesAgainstTheOdds:
                return(HasSurvivedAgainstTheOdds);
            }

            HivemindException.NoSuchInjuryException(injuryId);
            return(null);
        }
예제 #5
0
        private IEnumerable <SkillType> GetGangSkill(GangerType type, GangHouse house)
        {
            SkillType[] skillList = new SkillType[0];
            switch (house)
            {
            case GangHouse.CAWDOR:
                switch (type)
                {
                case GangerType.JUVE:
                    skillList = new[] { SkillType.COMBAT, SkillType.FEROCITY };
                    break;

                case GangerType.GANGER:
                    skillList = new[] { SkillType.COMBAT, SkillType.FEROCITY, SkillType.AGILITY };
                    break;

                case GangerType.HEAVY:
                    skillList = new[] { SkillType.FEROCITY, SkillType.MUSCLE, SkillType.SHOOTING, SkillType.TECHNO };
                    break;

                case GangerType.LEADER:
                    skillList = new[] { SkillType.AGILITY, SkillType.COMBAT, SkillType.FEROCITY, SkillType.MUSCLE, SkillType.SHOOTING, SkillType.TECHNO };
                    break;
                }
                break;

            case GangHouse.ESCHER:
                switch (type)
                {
                case GangerType.JUVE:
                    skillList = new[] { SkillType.AGILITY, SkillType.COMBAT };
                    break;

                case GangerType.GANGER:
                    skillList = new[] { SkillType.AGILITY, SkillType.COMBAT, SkillType.STEALTH };
                    break;

                case GangerType.HEAVY:
                    skillList = new[] { SkillType.AGILITY, SkillType.MUSCLE, SkillType.SHOOTING, SkillType.TECHNO };
                    break;

                case GangerType.LEADER:
                    skillList = new[] { SkillType.AGILITY, SkillType.COMBAT, SkillType.FEROCITY, SkillType.SHOOTING, SkillType.STEALTH, SkillType.TECHNO };
                    break;
                }
                break;

            case GangHouse.DELAQUE:
                switch (type)
                {
                case GangerType.JUVE:
                    skillList = new[] { SkillType.SHOOTING, SkillType.STEALTH };
                    break;

                case GangerType.GANGER:
                    skillList = new[] { SkillType.AGILITY, SkillType.SHOOTING, SkillType.STEALTH };
                    break;

                case GangerType.HEAVY:
                    skillList = new[] { SkillType.MUSCLE, SkillType.STEALTH, SkillType.SHOOTING, SkillType.TECHNO };
                    break;

                case GangerType.LEADER:
                    skillList = new[] { SkillType.AGILITY, SkillType.COMBAT, SkillType.FEROCITY, SkillType.SHOOTING, SkillType.STEALTH, SkillType.TECHNO };
                    break;
                }
                break;

            case GangHouse.GOLIATH:
                switch (type)
                {
                case GangerType.JUVE:
                    skillList = new[] { SkillType.FEROCITY, SkillType.MUSCLE };
                    break;

                case GangerType.GANGER:
                    skillList = new[] { SkillType.FEROCITY, SkillType.MUSCLE, SkillType.COMBAT };
                    break;

                case GangerType.HEAVY:
                    skillList = new[] { SkillType.MUSCLE, SkillType.COMBAT, SkillType.SHOOTING, SkillType.TECHNO };
                    break;

                case GangerType.LEADER:
                    skillList = new[] { SkillType.COMBAT, SkillType.FEROCITY, SkillType.MUSCLE, SkillType.SHOOTING, SkillType.STEALTH, SkillType.TECHNO };
                    break;
                }
                break;

            case GangHouse.ORLOCK:
                switch (type)
                {
                case GangerType.JUVE:
                    skillList = new[] { SkillType.FEROCITY, SkillType.SHOOTING };
                    break;

                case GangerType.GANGER:
                    skillList = new[] { SkillType.COMBAT, SkillType.FEROCITY, SkillType.SHOOTING };
                    break;

                case GangerType.HEAVY:
                    skillList = new[] { SkillType.COMBAT, SkillType.MUSCLE, SkillType.SHOOTING, SkillType.TECHNO };
                    break;

                case GangerType.LEADER:
                    skillList = new[] { SkillType.AGILITY, SkillType.COMBAT, SkillType.FEROCITY, SkillType.SHOOTING, SkillType.STEALTH, SkillType.TECHNO };
                    break;
                }
                break;

            case GangHouse.VAN_SAAR:
                switch (type)
                {
                case GangerType.JUVE:
                    skillList = new[] { SkillType.SHOOTING, SkillType.TECHNO };
                    break;

                case GangerType.GANGER:
                    skillList = new[] { SkillType.COMBAT, SkillType.SHOOTING, SkillType.TECHNO };
                    break;

                case GangerType.HEAVY:
                    skillList = new[] { SkillType.COMBAT, SkillType.MUSCLE, SkillType.SHOOTING, SkillType.TECHNO };
                    break;

                case GangerType.LEADER:
                    skillList = new[] { SkillType.AGILITY, SkillType.COMBAT, SkillType.FEROCITY, SkillType.SHOOTING, SkillType.STEALTH, SkillType.TECHNO };
                    break;
                }
                break;

            default:
                HivemindException.NoSuchGangHouse();
                break;
            }
            return(skillList);
        }
예제 #6
0
        /// <summary>
        /// Get a gang skill for advance rolls.
        /// </summary>
        /// <param name="type">Ganger type</param>
        /// <param name="house">Gang house</param>
        /// <returns>List of skill types to choose from.</returns>
        public IEnumerable <SkillType> GetGangSkill(GangerType type, GangHouse house)
        {
            SkillType[] skillList = new SkillType[0];
            switch (house)
            {
            case GangHouse.Cawdor:
                switch (type)
                {
                case GangerType.Juve:
                    skillList = new[] { SkillType.Combat, SkillType.Ferocity };
                    break;

                case GangerType.Ganger:
                    skillList = new[] { SkillType.Combat, SkillType.Ferocity, SkillType.Agility };
                    break;

                case GangerType.Heavy:
                    skillList = new[] { SkillType.Ferocity, SkillType.Muscle, SkillType.Shooting, SkillType.Techno };
                    break;

                case GangerType.Leader:
                    skillList = new[] { SkillType.Agility, SkillType.Combat, SkillType.Ferocity, SkillType.Muscle, SkillType.Shooting, SkillType.Techno };
                    break;
                }

                break;

            case GangHouse.Escher:
                switch (type)
                {
                case GangerType.Juve:
                    skillList = new[] { SkillType.Agility, SkillType.Combat };
                    break;

                case GangerType.Ganger:
                    skillList = new[] { SkillType.Agility, SkillType.Combat, SkillType.Stealth };
                    break;

                case GangerType.Heavy:
                    skillList = new[] { SkillType.Agility, SkillType.Muscle, SkillType.Shooting, SkillType.Techno };
                    break;

                case GangerType.Leader:
                    skillList = new[] { SkillType.Agility, SkillType.Combat, SkillType.Ferocity, SkillType.Shooting, SkillType.Stealth, SkillType.Techno };
                    break;
                }

                break;

            case GangHouse.Delaque:
                switch (type)
                {
                case GangerType.Juve:
                    skillList = new[] { SkillType.Shooting, SkillType.Stealth };
                    break;

                case GangerType.Ganger:
                    skillList = new[] { SkillType.Agility, SkillType.Shooting, SkillType.Stealth };
                    break;

                case GangerType.Heavy:
                    skillList = new[] { SkillType.Muscle, SkillType.Stealth, SkillType.Shooting, SkillType.Techno };
                    break;

                case GangerType.Leader:
                    skillList = new[] { SkillType.Agility, SkillType.Combat, SkillType.Ferocity, SkillType.Shooting, SkillType.Stealth, SkillType.Techno };
                    break;
                }

                break;

            case GangHouse.Goliath:
                switch (type)
                {
                case GangerType.Juve:
                    skillList = new[] { SkillType.Ferocity, SkillType.Muscle };
                    break;

                case GangerType.Ganger:
                    skillList = new[] { SkillType.Ferocity, SkillType.Muscle, SkillType.Combat };
                    break;

                case GangerType.Heavy:
                    skillList = new[] { SkillType.Muscle, SkillType.Combat, SkillType.Shooting, SkillType.Techno };
                    break;

                case GangerType.Leader:
                    skillList = new[] { SkillType.Combat, SkillType.Ferocity, SkillType.Muscle, SkillType.Shooting, SkillType.Stealth, SkillType.Techno };
                    break;
                }

                break;

            case GangHouse.Orlock:
                switch (type)
                {
                case GangerType.Juve:
                    skillList = new[] { SkillType.Ferocity, SkillType.Shooting };
                    break;

                case GangerType.Ganger:
                    skillList = new[] { SkillType.Combat, SkillType.Ferocity, SkillType.Shooting };
                    break;

                case GangerType.Heavy:
                    skillList = new[] { SkillType.Combat, SkillType.Muscle, SkillType.Shooting, SkillType.Techno };
                    break;

                case GangerType.Leader:
                    skillList = new[] { SkillType.Agility, SkillType.Combat, SkillType.Ferocity, SkillType.Shooting, SkillType.Stealth, SkillType.Techno };
                    break;
                }

                break;

            case GangHouse.VanSaar:
                switch (type)
                {
                case GangerType.Juve:
                    skillList = new[] { SkillType.Shooting, SkillType.Techno };
                    break;

                case GangerType.Ganger:
                    skillList = new[] { SkillType.Combat, SkillType.Shooting, SkillType.Techno };
                    break;

                case GangerType.Heavy:
                    skillList = new[] { SkillType.Combat, SkillType.Muscle, SkillType.Shooting, SkillType.Techno };
                    break;

                case GangerType.Leader:
                    skillList = new[] { SkillType.Agility, SkillType.Combat, SkillType.Ferocity, SkillType.Shooting, SkillType.Stealth, SkillType.Techno };
                    break;
                }

                break;

            default:
                HivemindException.NoSuchGangHouse();
                break;
            }

            return(skillList);
        }
예제 #7
0
        /// <summary>
        /// Determine injury
        /// </summary>
        /// <param name="roll">Dice roll</param>
        /// <returns>List of injuries</returns>
        public IEnumerable <Injury> DetermineInjury(int?roll)
        {
            if (!roll.HasValue)
            {
                roll = _diceRoller.RollD66();
            }

            switch (roll.Value)
            {
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.Dead) });

            case 21:
                var injuries = new List <Injury>();
                injuries.Add(_injuryManager.GetInjury((int)InjuryEnum.MultipleInjuries));
                var extraInjuries = _diceRoller.RollDie();
                for (int i = 0; i < extraInjuries; i++)
                {
                    injuries.Add(DetermineInjury(_diceRoller.MultipleInjuriesRoll()).FirstOrDefault());
                }

                return(injuries);

            case 22:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.ChestWound) });

            case 23:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.LegWound) });

            case 24:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.ArmWound) });

            case 25:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.HeadWound) });

            case 26:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.BlindedInOneEye) });

            case 31:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.PartiallyDeafened) });

            case 32:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.ShellShock) });

            case 33:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.HandInjury) });

            case 34:
            case 35:
            case 36:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.OldBattleWound) });

            case 41:
            case 42:
            case 43:
            case 44:
            case 45:
            case 46:
            case 51:
            case 52:
            case 53:
            case 54:
            case 55:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.FullRecovery) });

            case 56:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.BitterEnmity) });

            case 61:
            case 62:
            case 63:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.Captured) });

            case 64:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.HorribleScars) });

            case 65:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.ImpressiveScars) });

            case 66:
                return(new[] { _injuryManager.GetInjury((int)InjuryEnum.SurvivesAgainstTheOdds) });

            default:
                HivemindException.NoSuchInjuryException(roll.Value);
                return(new Injury[] { });
            }
        }
예제 #8
0
        public IEnumerable <Injury> DetermineInjury(int?roll)
        {
            if (!roll.HasValue)
            {
                roll = DiceRoller.RollD66();
            }

            switch (roll.Value)
            {
            case 11:
            case 12:
            case 13:
            case 14:
            case 15:
            case 16:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.DEAD) });

            case 21:
                var injuries = new List <Injury>();
                injuries.Add(_injuryFactory.GetInjury((int)InjuryEnum.MULTIPLE_INJURIES));
                var extraInjuries = DiceRoller.RollDie();
                for (int i = 0; i < extraInjuries; i++)
                {
                    injuries.Add(DetermineInjury(DiceRoller.MultipleInjuriesRoll()).FirstOrDefault());
                }
                return(injuries);

            case 22:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.CHEST_WOUND) });

            case 23:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.LEG_WOUND) });

            case 24:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.ARM_WOUND) });

            case 25:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.HEAD_WOUND) });

            case 26:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.BLINDED_IN_ONE_EYE) });

            case 31:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.PARTIALLY_DEAFENED) });

            case 32:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.SHELL_SHOCK) });

            case 33:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.HAND_INJURY) });

            case 34:
            case 35:
            case 36:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.OLD_BATTLE_WOUND) });

            case 41:
            case 42:
            case 43:
            case 44:
            case 45:
            case 46:
            case 51:
            case 52:
            case 53:
            case 54:
            case 55:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.FULL_RECOVERY) });

            case 56:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.BITTER_ENMITY) });

            case 61:
            case 62:
            case 63:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.CAPTURED) });

            case 64:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.HORRIBLE_SCARS) });

            case 65:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.IMPRESSIVE_SCARS) });

            case 66:
                return(new[] { _injuryFactory.GetInjury((int)InjuryEnum.SURVIVES_AGAINST_THE_ODDS) });

            default:
                HivemindException.NoSuchInjuryException(roll.Value);
                return(new Injury[] { });
            }
        }