Exemplo n.º 1
0
    public static int Mutation(char symbol, SysadminModule module)
    {
        if (symbol >= '1' && symbol <= '9')
        {
            return(symbol - '0');
        }
        switch (symbol)
        {
        case 'T': return(module.startingTimeInMinutes);

        case 'F': return(module.recoveredNodesCount);

        case 'B': return(module.BombInfo.GetBatteryCount());

        case 'I': return(module.BombInfo.GetIndicators().Count());

        case 'K':
            return(module.BombInfo.IsTwoFactorPresent() ?
                   module.BombInfo.GetTwoFactorCodes().Select((code) => code % 10).Max() :
                   module.BombInfo.GetSolvedModuleIDs().Count());

        case 'R': return(Mathf.FloorToInt(module.BombInfo.GetTime() / 60f));

        case 'M': return(module.BombInfo.GetModuleIDs().Count);

        case 'S': return(module.BombInfo.GetSerialNumberNumbers().Min());

        case 'E': return(module.BombInfo.GetStrikes());

        default: throw new UnityException("Invalid symbol");
        }
    }
Exemplo n.º 2
0
    public static int CalculateValue(Vector2Int errorCodeIndex, SysadminModule module)
    {
        string instructions = lastColumn[errorCodeIndex.y];

        Debug.Log(instructions);
        int a = Mutation(instructions[0], module);

        if (instructions.Length == 1)
        {
            return(a);
        }
        int b = Mutation(instructions[4], module);

        return(instructions[2] == '+' ? a + b : a - b);
    }
Exemplo n.º 3
0
    public static string ValidRecoveryCode(Vector2Int errorCodeIndex, SysadminModule module)
    {
        int value = CalculateValue(errorCodeIndex, module) % 10;

        if (value < 0)
        {
            value = 10 + value;
        }
        Debug.LogFormat("[Sysadmin #{0}] Recovering value for error code {1}: {2}", module.moduleId,
                        data[errorCodeIndex.y][errorCodeIndex.x], value);
        List <string> codes = new List <string>();

        for (int i = 1; i <= ERROR_CODE_ROWS_COUNT; i++)
        {
            string code = data[(errorCodeIndex.y + i) % ERROR_CODE_ROWS_COUNT][errorCodeIndex.x];
            if (code.Contains((char)(value + '0')))
            {
                codes.Add(code);
            }
        }
        return(codes.Select((c) => c[0]).Join(""));
    }