Tutorial/Getting the Files

## Downloading from the VillageWars Website

Download Python and the VillageWars installer from the website with this url: https://villagewars.pythonanywhere.com/download. Currently VillageWars is only available for Windows. The villagewars installer should be named `villagewars-installer.py`. You can run this with the version of python you installed. To do this, you should be able to double click it, but in case that doesn't work, you can also use the command prompt with:

```
C:\Users\myusername>py -m program
```

Replace "program" with the program in question. It can either be in the working directory, or you can use backslashes or forwards slashes to show the folder it's in. You can also replace "py" with the name of the interpreter, which is usually *py* or *python*.

## Finding the Python Interpreter's Name

Python is installed under a name, usually `py` or `python`. Try typing each of these into the command prompt after installing python with the link provided on the download page[1].

```
C:\Users\myusername>py
Python 3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
```

(I use python 3.9.6, but any python 3 should work.)

If you see something like this, then that means python was successfully installed under that name. (If you typed *py*, then it would be `py`, if you typed *python*, then it would be `python`). Remember that name as the interpreter name for later on in this tutorial. If it opens the Microsoft store, or it displays the following, then it probably doesn't use the name you just provided it with.

```
C:\Users\myusername>python
'python' is not recognized as an internal or external command,
operable program or batch file.
```

If neither *python* nor *py* nor *python3* work, then you should make sure that python is actually installed.

## Running `villagewars-installer.py`

When you run `villagewars-installer.py`, either by double-clicking it or by using the command prompt, you will be prompted to answer a few questions. As a reminder, to use the command prompt to run `villagewars-installer.py`, then what you will type will look like this:

```
C:\Users\myusername>chdir Downloads
C:\Users\myusername\Downloads>py -m villagewars-installer.py
```

Most of the time you can double click it though, or do *Open With > Python*.

### Python Interpreter

This one's easy. It's what we just figured out in the sections above. Usually it will be either *py* or *python*. Here's what that would look like:

```
3.9.13 (main, Aug 25 2022, 23:51:50) [MSC v.1916 64 bit (AMD64)]
Please input your preferred python interpreter: (leave blank for "python") py

```

In this example I put `py`, but you can put `python` too if that was your interpreter.

### Automated Package Installation

After this step, the installer will install three python third-party modules that are required for the installation.

```
Installing necessary packages...

Collecting requests
  Downloading requests-2.26.0-py2.py3-none-any.whl (62 kB)
Installing collected packages: requests
Successfully installed requests-2.26.0

Collecting zipfile2
  Downloading zipfile2-2.26.0-py2.py3-none-any.whl (62 kB)
Installing collected packages: zipfile2
Successfully installed zipfile2-2.26.0

Collecting progress-bar
  Downloading progress-bar-2.26.0-py2.py3-none-any.whl (62 kB)
Installing collected packages: progress-bar
Successfully installed progress-bar-2.26.0

Press enter to continue

```

Note that something might prompt you to install a newer version of pip. You do not need to do this unless you would like to. After this step you should have all the packages needed to install VillageWars. Now all you have to do is press enter.

### System Path

Now there's a step that is only to be used when python doesn't end up with the correct system path. Most of the time you can ignore it and move on to the next step.

```
Please enter where the path that these packages were installed to: (if you don't know, leave blank)
> (left blank)
Invalid path. Skipping...

```

If you get an import error when you run VillageWars later, then see this tutorial on how to set the system path.

### Location

The program now asks us where to install VillageWars. I recommend on your Desktop, but this is your decision. Some PCs even have a Saved Games folder.

```
Please enter where to install VillageWars:
C:\Users\myusername\(Type here) ex: OneDrive\Desktop
Set up the directory successfully

```

### Downloading the actual game

You must now wait a little bit of time. It will display the following, but bear in mind that the progress bar goes directly from 0% to 100%. This bug will likely be fixed shortly.

```
Requested files
  Downloading VillageWars: [                     0.0%                      ]

```

When it's finished it will look like this:

```
Requested files
  Downloading VillageWars: [====================100.0%=====================]
Download successful!

  Extracting: [===========================100.0%===========================]
Extraction successful!

Unlinking zipped folder...

Successfully Unlinked!

Setting default python interpreter...

Set!

VillageWars successfully installed to C:\Users\myusername\OneDrive\Desktop

Press enter to exit

```

At this stage you can copy the directory if you want, but what you need to do is finished. Press enter or the X button to close the program. Now you have the source code for VillageWars!

## Running `main.py`

The next step is to run `main.py`. This python file runs the game client, so this is what you want to double-click on to play. If you're missing some modules to play the game, it will invite you to the setup prompt. Don't worry, you won't always be prompted this much. This is what it will look like at first:

```
pygame 2.5.1 (SDL 2.28.2, Python 3.9.13)
Hello from the pygame community. https://www.pygame.org/contribute.html
Running python version 3.9.6

Welcome to VillageWars!

I hope you enjoy playing it!

Would you to set preferences? (y/n)
>

```

Most of the setup process is pretty self-explanatory, so follow the instructions and you should be good.

### Preferences

Preferences are optional. Type "y" to set them, or "n" if you would rather not. As of 1.7.1, the preferences only include the name of the python interpreter (remember, either `py` or `python`), the name of the map you prefer, and an appending to the system path. The default (*grass*) has been the only map available until 1.6.9. You can try out the other two (*pink* and *snow*) to change things up a bit. Note that these only cosmetically change the game, and only for you. If you connect to a server, the other people won't see your map. (See this tutorial for making a custom map!)
If you don't choose to set the preferences, it will provide you with a link to Tutorial/Setting Preferences.
Here's an example of setting preferences:

```
Would you like to set preferences? (y/n)
> y

What would you like your map's theme to be? (please enter one of "grass" (default), "pink", or "snow")
> grass

Map set to "grass"

Do you have a prefered python interpreter? (default is "python", but may vary)
> python

Interpreter set to "python"

```

In the next step of the preferences (appending to the system path), you can usually input "n" to say that you don't want to add anything to the system path, and that it's good as it is. If you happen to need to add something, (maybe because you read the tutorial at Tutorial/Setting the System Path), then you can type "y" or "s".

```
Would you like to specify a missing system path? (type y for yes, n for no, and s to see what is already on the system path)
> n

Ok, on to the next step.

```

### Installing third-party modules

The next step is to guide the setup process through installing the required third-party modules. Some of these you will have already installed with `villagewars-installer.py`, but you will need to install some more here. You will be asked whether you would like to install these, but you must enter "y" if you would like to play. Without these modules the game can't be run.
This is the total list of packages required for VillageWars:

* `pygame`
* `requests`
* `beautifulsoup4`
* `pymsgbox`
* `pyperclip`
* `progress_bar`
* `send2trash`
* `zipfile2`
* `websockets`

`requests`, `progress_bar` and `zipfile2` should already be installed. You don't need to do any work besides press enter when it tells you to. Here's an example.

```
You are missing a few elements necessary to start VillageWars.
Would you like these elements to be installed? (y/n)
> y

You are missing the following third-party modules from VillageWars:

beautifulsoup4
pyperclip
websockets

Press enter to install beautifulsoup4
Collecting beautifulsoup4
  Downloading beautifulsoup4-2.26.0-py2.py3-none-any.whl (62 kB)
Installing collected packages: beautifulsoup4
Successfully installed beautifulsoup4-2.26.0

Press enter to install pyperclip
Collecting pyperclip
  Downloading pyperclip-2.26.0-py2.py3-none-any.whl (62 kB)
Installing collected packages: pyperclip
Successfully installed pyperclip-2.26.0

Press enter to install websockets
Collecting websockets
  Downloading websockets-2.26.0-py2.py3-none-any.whl (62 kB)
Installing collected packages: websockets
Successfully installed websockets-2.26.0

Press enter to continue

```

### Downloading `version_info.json`

If you don't have `version_info.json` (it doesn't come with the download, so you probably don't), then it will ask you to press enter to download it. Go ahead and download it.

```
You're missing the version information documents that let you update VillageWars. Hold on while those documents are fetched.

Press enter to continue

Collecting version_info.json

  Downloading:: [==========================100.0%==========================]
Successfully downloaded version information

Successfully installed all necessary elements

```

### Refreshing your files

There you go. It might ask you if you want your files to be refreshed. It doesn't matter whether you answer yes or no, because you shouldn't have any to refresh (the download should be clean). Just make sure you put "y" or "n", don't just leave it blank or you'll have to start over. And then you're done! Here's what it should look like:

```
Would you like your files to be refreshed? (Replace out-of-date files) (y/n)
> y

Nevermind, you don't have any files to refresh.

You're ready to play VillageWars!

Press enter to continue to VillageWars
pygame 2.5.1 (SDL 2.28.2, Python 3.9.6)
Hello from the pygame community. https://www.pygame.org/contribute.html
Running VillageWars version 1.7.1

```

The VillageWars screen should open up and you're ready to go. If ever you would like to make changes to this setup, you can re-run it with the `setup.py` file within the `src` folder. After running `main.py` once, then other times you run it you won't have to go through all the installing again.

Here are some other tutorials that might interest you now:

* Tutorial/Connecting to a Server
* Tutorial/Playing the Game
* Tutorial/Starting a Server
* Tutorial/Setting the System Path