Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Suggestion] Cancel Deletion #172

Open
M4GO opened this issue Sep 25, 2021 · 3 comments
Open

[Suggestion] Cancel Deletion #172

M4GO opened this issue Sep 25, 2021 · 3 comments

Comments

@M4GO
Copy link

M4GO commented Sep 25, 2021

hello you can add support to cancel deletion of characters in account page

@M4GO M4GO changed the title [Suggestion] Undelete Character [Suggestion] Cancel Deletion Sep 25, 2021
@Leesneaks
Copy link
Collaborator

Leesneaks commented Sep 27, 2021

This is something I had started working on in my bootstrap theme but due to health I stopped on all of my projects.
I'm slowly coming back now so will look at updating this into the Dev version when I get some more time.

image

I planned on shrinking it down and tidying it up more

@gaamelu
Copy link

gaamelu commented Feb 15, 2022

@Leesneaks, do you still plan to continue this?

@gesior
Copy link

gesior commented May 30, 2024

Players often delete character to unlock it's name. So 'delete' action should change name of character and 'undelete' should change it back.

// code from other AAC

Delete player code - allows anyone to delete character:

                $i = 0;
                $nameCheckPlayer = new Player();
                $nameCheckPlayer->find($player->generateDeletedName($i));
                while ($nameCheckPlayer->isLoaded()) {
                    $i++;
                    $nameCheckPlayer->find($player->generateDeletedName($i));
                }

                $player->setName($player->generateDeletedName($i));

Undelete code - allows undelete only if no one else is using character name already:

    $undeletePlayerName = $player->generateUndeletedName();

    $testUndeletePlayerName = new Player($undeletePlayerName, Player::LOADTYPE_NAME);
    if ($testUndeletePlayerName->isLoaded()) {
        echo Website::messageError('Cannot undelete <b>' . htmlspecialchars($player->getName()) . '</b>!<br />' .
            'Player with name <b>' . htmlspecialchars($undeletePlayerName) . '</b> already exists.<br />' .
            'It must be renamed or deleted before you can undelete this character.');
        return;
    }

player.php class code to generate delete/undelete names: allows players to delete character with name X -> create new character with name X -> delete new character X -> create another character with name X and so on (expects real delete from database to take 7+ days, but allows to use player name just after deletion; also expects no [ in normal character names):

    public function generateDeletedName($i)
    {
        if (substr($this->getName(), 0, 3) === '[D]')
            throw new RuntimeException('Cannot generate delete name for deleted character.');
        return '[D][' . $i . ']' . $this->getName();
    }

    public function generateUndeletedName()
    {
        if (substr($this->getName(), 0, 3) !== '[D]' || stripos($this->getName(), ']', 3) === false)
            throw new RuntimeException('Cannot generate undelete name for not deleted character.');

        return substr($this->getName(), stripos($this->getName(), ']', 3) + 1);
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants