How do I legally make an open-source version of a closed-source game? [closed]
You can't copy it to be open-source. Even if the source were leaked, that is illegal. You can, however, follow in the footsteps of FreeCiv or Doom3. FreeCiv is based on Civilization, and is an open-source version. Doom3 is also open-source but requires the use of official game data for full operation or you must provide your own assets for models. Either way the engine is free, open source, and available to all. FreeCiv includes no game data since both the original and FreeCiv generate maps dynamically. The requirements to release your version are as follows:
Any patents related to the original must have expired. You can use a patent search such as Google Patent Search. Simply type your query as if it were a regular Google search, and under one or two web results, patents will be shown.
The program you are writing does not use strong cryptography that is restricted by the US government.(Or if it were downloaded in some countries, you could be considered an arms dealer) You may also register with the US Bureau of Industry and Security, which is a part of the US Department of Commerce, although the legal paperwork may be very difficult to file without professional legal counsel. Also see the BIS FAQ on encryption.
Your version does not use images or other files (such as sound files) from the original version.
Your version includes some (at least minor) changes.
You did not use, directly, or as an idea on how to write your version, any of the source of the original if it had been leaked.
You do not utilize the source's trademarks.
Do note that you have to code it, package it, and put it in a PPA or the repositories. This may be very difficult. There is no way to just copy-paste some magic from the old version. Please read the disclaimer below prior to doing anything to make your version, and for more guidance about the actual stages of coding, visit Game Development and Stack Overflow.
Legal disclaimer: This is not meant to be legal advice. The author of this answer, Ask Ubuntu, Stack Exchange, Inc, their representatives, agents, and/or any affiliated parties will not be responsible for any damages, incidental, or consequential, that may arise due to the use of these guidelines. These guidelines are based on US laws and regulations. Laws and regulations in your area may differ so check with a lawyer or local authorities.
Age of Empires II can usually be run on Ubuntu and other GNU/Linux systems without too many problems, using Wine.
Disclosure: I am not a lawyer.
As for the general question, if your goal is to create free open-source software that facilitates playing a proprietary game, and you have programming skills, typically there is no legal impediment to writing a replacement game engine. (You may potentially fall afoul of software patents, but no more so than in any other major programming project to produce software for performing tasks that existing software already performs.) If you do this, then someone can install your engine, and then, if they have the artistic data (maps, "worlds", sounds, and so forth) from the game, they can play the game.
Developing a game engine for an existing game is a non-trivial task, and usually there will be differences between the way it behaves and the way the original game ran, though they might be slight. But the main thing you should realize is that the game data, representing the "world" of the game, will still be proprietary, and generally unlawful to redistribute. So people will still have to have a copy of the game (or at least certain files from it), to play it using your engine.
One example of a game where this was done is Jazz Jackrabbit, which can be played with the OpenJazz game engine.
Another example (where it was actually the original developer that released the GNU/Linux version of the game engine as free open source software) is DOOM (and since then, most of Id Software's game engines have eventually been released as FOSS, sometimes with slight modifications for patent reasons). There are a number of community projects that have enhanced the original DOOM engine, allowing for more complex maps, enhanced graphics, and a more three-dimensional gameplay experience.
Given the limitations and that writing a game engine from scratch (plus testing it and fixing bugs) is a significant task, you might decide to make your own game instead.
Disclaimer: This answer is for informational purposes only and not for the purpose of providing legal advice. You should contact an attorney to obtain advice with respect to any particular issue or problem.