Example #1
0
 public static Condition <TData> MoreThanNBatteries(int n)
 => new Condition <TData>(nameof(MoreThanNBatteries), $"there {(n == 1 ? "is" : "are")} more than {n} {(n == 1 ? "battery" : "batteries")} on the bomb",
                          (p, d) => {
     var s = p.User.GetPredicate("BombBatteryCount").ToLower();
     if (s == "unknown")
     {
         return(ConditionResult.Unknown("NeedBatteryCount"));
     }
     return(ConditionResult.FromBool(int.Parse(s) > n));
 });
Example #2
0
        private static ConditionResult CheckPort(RequestProcess process, PortType portType)
        {
            switch (process.User.GetPredicate("BombPort" + portType).ToLower())
            {
            case "true": return(ConditionResult.FromBool(true));

            case "false": return(ConditionResult.FromBool(false));

            default: return(ConditionResult.Unknown("NeedPort" + portType));
            }
        }
Example #3
0
        public static Condition <TData> SerialNumberIsOdd()
        => new Condition <TData>(nameof(SerialNumberIsOdd), $"the last digit of the serial number is odd",
                                 (p, d) => {
            switch (p.User.GetPredicate("BombSerialNumberIsOdd").ToLower())
            {
            case "true": return(ConditionResult.FromBool(true));

            case "false": return(ConditionResult.FromBool(false));

            default: return(ConditionResult.Unknown("NeedSerialNumberIsOdd"));
            }
        });
Example #4
0
        public static Condition <TData> SerialNumberStartsWithLetter()
        => new Condition <TData>(nameof(SerialNumberStartsWithLetter), $"the serial number starts with a letter",
                                 (p, d) => {
            switch (p.User.GetPredicate("BombSerialNumberStartsWithLetter").ToLower())
            {
            case "true": return(ConditionResult.FromBool(true));

            case "false": return(ConditionResult.FromBool(false));

            default: return(ConditionResult.Unknown("NeedSerialNumberStartsWithLetter"));
            }
        });
Example #5
0
        public static Condition <TData> EmptyPortPlate()
        => new Condition <TData>(nameof(EmptyPortPlate), $"there is an empty port plate present on the bomb",
                                 (p, d) => {
            switch (p.User.GetPredicate("BombPortEmptyPlate").ToLower())
            {
            case "true": return(ConditionResult.FromBool(true));

            case "false": return(ConditionResult.FromBool(false));

            default: return(ConditionResult.Unknown("NeedEmptyPortPlate"));
            }
        });
Example #6
0
        public static Condition <TData> IndicatorLit(string label)
        => new Condition <TData>(nameof(IndicatorLit), $"there is a lit indicator with label {label}",
                                 (p, d) => {
            switch (p.User.GetPredicate("BombIndicatorLit" + label).ToLower())
            {
            case "true": return(ConditionResult.FromBool(true));

            case "false": return(ConditionResult.FromBool(false));

            default: return(ConditionResult.Unknown("NeedIndicatorLit " + label));
            }
        });