private void DefaultCommand(StringBuilder builder, Doomsday_SecurityTerminal doomsdayTerminal)
 {
     builder.Append($"{"DoomsdayTerminal_ActiveUsers".Translate()}\n");
     foreach (var user in doomsdayTerminal.Users)
     {
         builder.AppendLine($"- {user.Key}");
     }
     builder.AppendLine($"DoomsdayTerminal_AddNewUsers".Translate());
     builder.Append($"DoomsdayTerminal_RemoveUsers".Translate());
 }
Example #2
0
        public override string Invoke()
        {
            Doomsday_SecurityTerminal doomsdayTerminal = Terminal as Doomsday_SecurityTerminal;
            StringBuilder             builder          = new StringBuilder();

            if (string.IsNullOrEmpty(doomsdayTerminal.CurrentUser) || doomsdayTerminal.CurrentUser == "Anonymous")
            {
                builder.AppendLine($"{"DoomsdayTerminal_LoginFirst".Translate()}");
            }
            else
            {
                doomsdayTerminal.CurrentUser = "******";
                doomsdayTerminal.HasAccess   = false;
                builder.AppendLine($"{"DoomsdayTerminal_LogoutOk".Translate()}");
            }

            return(builder.ToString());
        }
        public override string Invoke()
        {
            Doomsday_SecurityTerminal doomsdayTerminal = Terminal as Doomsday_SecurityTerminal;
            StringBuilder             builder          = new StringBuilder();

            if (!string.IsNullOrEmpty(doomsdayTerminal.CurrentUser) && doomsdayTerminal.CurrentUser != "Anonymous")
            {
                builder.AppendLine($"{"DoomsdayTerminal_AlreadyLogged".Translate()}");
            }
            else
            {
                string[] commandParams = doomsdayTerminal.TerminalCommand.Split(' ');
                if (commandParams.Length == 3)
                {
                    if (doomsdayTerminal.Users.ContainsKey(commandParams[1]))
                    {
                        string user     = commandParams[1];
                        string password = doomsdayTerminal.Users[user];
                        if (commandParams[2].ToLower() == password.ToLower())
                        {
                            doomsdayTerminal.CurrentUser = user;
                            doomsdayTerminal.HasAccess   = true;
                            builder.AppendLine($"{"DoomsdayTerminal_LogginSuccess".Translate(user)}");
                        }
                        else
                        {
                            builder.AppendLine($"{"DoomsdayTerminal_LogginFail".Translate()}");
                        }
                    }
                    else
                    {
                        builder.AppendLine($"{"DoomsdayTerminal_LogginFail".Translate()}");
                    }
                }
                else
                {
                    builder.AppendLine($"--> {"DoomsdayTerminal_WrongArguments".Translate()} < --");
                }
            }

            return(builder.ToString());
        }
Example #4
0
        public override string Invoke()
        {
            Doomsday_SecurityTerminal doomsdayTerminal = Terminal as Doomsday_SecurityTerminal;
            StringBuilder             builder          = new StringBuilder();

            if (doomsdayTerminal.HasAccess)
            {
                string[] commandParams = doomsdayTerminal.TerminalCommand.Split(' ');
                if (commandParams.Length >= 2)
                {
                    switch (commandParams[1])
                    {
                    case "dump":
                    {
                        builder.AppendLine($"{"DoomsdayTerminal_HackToolsSecurity".Translate()}");
                        GenerateCode(builder);
                        break;
                    }

                    case "disable":
                    {
                        if (doomsdayTerminal.SecutiyAccess && doomsdayTerminal.Power)
                        {
                            doomsdayTerminal.weapon.SecuritySystemActive = false;
                            Find.LetterStack.ReceiveLetter("SecurityDoomsdayOffTitle".Translate(), "SecurityDoomsdayOff".Translate(), LetterDefOf.PositiveEvent);
                            builder.AppendLine($"{"DoomsdayTerminal_SecurityDisabled".Translate()}");
                        }
                        else
                        {
                            builder.AppendLine($"{"DoomsdayTerminal_SecurityNoPower".Translate()}");
                        }

                        break;
                    }

                    case "energy":
                    {
                        if (doomsdayTerminal.Power)
                        {
                            builder.AppendLine($"{"DoomsdayTerminal_SecurityPowerOk".Translate()}");
                        }
                        else if (doomsdayTerminal.SecutiyAccess)
                        {
                            if (!doomsdayTerminal.ActiveMode)
                            {
                                builder.AppendLine($"{"DoomsdayTerminal_SecurityPowerInfoPassive".Translate()}");
                            }
                            else
                            {
                                builder.AppendLine($"{"DoomsdayTerminal_SecurityPowerInfoActive".Translate()}");
                            }

                            if (commandParams.Length == 3)
                            {
                                switch (commandParams[2])
                                {
                                case "activemode":
                                {
                                    builder.AppendLine($"{"DoomsdayTerminal_ActiveModeEnable".Translate()}");
                                    doomsdayTerminal.ActiveMode = true;
                                    break;
                                }

                                case "shields":
                                {
                                    if (!doomsdayTerminal.ActiveMode)
                                    {
                                        builder.AppendLine($"{"DoomsdayTerminal_ActiveModeReq".Translate()}");
                                    }
                                    else
                                    {
                                        builder.AppendLine($"{"DoomsdayTerminal_ShieldsOff".Translate()}");
                                    }

                                    break;
                                }

                                case "on":
                                {
                                    if (!doomsdayTerminal.ActiveMode)
                                    {
                                        builder.AppendLine($"{"DoomsdayTerminal_ActiveModeReq".Translate()}");
                                    }
                                    else
                                    {
                                        if (!doomsdayTerminal.Power)
                                        {
                                            builder.AppendLine($"{"DoomsdayTerminal_PowerActivating".Translate()}");
                                            doomsdayTerminal.Power = true;
                                        }

                                        builder.AppendLine($"{"DoomsdayTerminal_SecurityPowerOk".Translate()}");
                                    }

                                    break;
                                }
                                }
                            }
                        }
                        else
                        {
                            builder.AppendLine($"--> {"DoomsdayTerminal_NoAccess".Translate()} < --");
                        }

                        break;
                    }

                    default:
                    {
                        if (!doomsdayTerminal.SecutiyAccess)
                        {
                            if (commandParams[1] == doomsdayTerminal.SecurityPassword)
                            {
                                doomsdayTerminal.SecutiyAccess = true;
                                builder.AppendLine($"{"DoomsdayTerminal_SecurityAccessGranted".Translate()}");
                            }
                            else
                            {
                                builder.AppendLine($"{"DoomsdayTerminal_WrongPassword".Translate()}");
                            }
                        }

                        break;
                    }
                    }
                }
                else
                {
                    if (!doomsdayTerminal.SecutiyAccess)
                    {
                        builder.AppendLine($"{"DoomsdayTerminal_SecurityFirst".Translate()}");
                    }
                    else
                    {
                        builder.AppendLine($"{"DoomsdayTerminal_SecurityAccessGranted".Translate()}");
                    }
                }
            }
            else
            {
                builder.AppendLine($"--> {"DoomsdayTerminal_NoAccess".Translate()} < --");
            }

            return(builder.ToString());
        }
        public override string Invoke()
        {
            doomsdayTerminal = Terminal as Doomsday_SecurityTerminal;
            StringBuilder builder = new StringBuilder();

            string[] commandParams = doomsdayTerminal.TerminalCommand.Split(' ');
            if (commandParams.Length > 2)
            {
                if (!string.IsNullOrEmpty(commandParams[2]) || (commandParams.Length == 4 && string.IsNullOrEmpty(commandParams[3])))
                {
                    if (doomsdayTerminal.HasAccess)
                    {
                        switch (commandParams[1])
                        {
                        case "add":
                        {
                            doomsdayTerminal.Users.Add(commandParams[2], commandParams[3]);
                            break;
                        }

                        case "delete":
                        {
                            if (doomsdayTerminal.Users.ContainsKey(commandParams[2]))
                            {
                                string password = doomsdayTerminal.Users[commandParams[2]];
                                if (commandParams[3] == password)
                                {
                                    doomsdayTerminal.Users.Remove(commandParams[2]);
                                }
                                else
                                {
                                    builder.AppendLine($"--> {"DoomsdayTerminal_WrongPassword".Translate()} < --");
                                }
                            }
                            break;
                        }

                        default:
                        {
                            DefaultCommand(builder, doomsdayTerminal);
                            break;
                        }
                        }
                    }
                    else
                    {
                        builder.AppendLine($"--> {"DoomsdayTerminal_WrongArguments".Translate()} < --");
                    }
                }
                else
                {
                    builder.AppendLine($"--> {"DoomsdayTerminal_NoAccess".Translate()} < --");
                }
            }
            else
            {
                DefaultCommand(builder, doomsdayTerminal);
            }

            if (commandParams.Length == 2 && commandParams[1] == "hack")
            {
                builder.AppendLine($"\n\n{"DoomsdayTerminal_UsersHack".Translate()}");
            }
            else
            {
                builder.AppendLine($"\n{"DoomsdayTerminal_HackUsers".Translate()}");
            }

            return(builder.ToString());
        }