Reconquering Empyre
About
This is a (shoddy written) python3 port of VMS Empire using ncurses. This is my 1st big project (the other one is relatively small), so there is going to be a lot of SNAFU and stuff.
Requirements
- Python 3
- noise
Startup parameters
-f [1,2,3,4]Determine the Fog of War- 1: See the full map and all the units.
- 2: See the full map but only friendly units
- 3 (default): Map is unexplored but once discovered all units will remain visible.
- 4: Map is unexplored and the only units visible are units within visual range of friendly units
-m xxx/yyyMap size for horizontal and vertical axis from 60-999. Defaults are 100x50-d delayThis option controls the length of time the computer will delay after printing informational messages at the top of the screen. delay is specified in seconds. The default value is 2 which allows the user two seconds to read a message.
Keys
Depending on the context the following keys issue the following commands. There are the following contexts:
globalCommands that work no matter the contextcityCommands that work with citiesunitCommands that work with units
Global
lDisplay the logsgGive the AI 1 turnnGive the AI x turnsqSave and Quit
City
pPause, do nothingbBuild a unitaarmyffighterppatrol boatddestroyerssubmarinettroop transportcaircraft carrierbbattleshipzsatellite
Unit
Num 12346789Direction to move/attack/load a unituUnload a unit from Transport or CarriersTurn unit into a sentry for 10 roundswSet a waypoint for units to move to
Notes
Combat
if (irand (2) == 0) /* defender hits? */
att_obj->hits -= piece_attr[def_obj->type].strength;
else def_obj->hits -= piece_attr[att_obj->type].strength;
}
| Piece | You | Enemy | Moves | Hits | Str | Cost |
|---|---|---|---|---|---|---|
| Army | A | a | 1 | 1 | 1 | 5(6) |
| Fighter | F | f | 8 | 1 | 1 | 10(12) |
| Patrol Boat | P | p | 4 | 1 | 1 | 15(18) |
| Destroyer | D | d | 2 | 3 | 1 | 20(24) |
| Submarine | S | s | 2 | 2 | 3 | 20(24) |
| Troop Transport | T | t | 2 | 1 | 1 | 30(36) |
| Aircraft Carrier | C | c | 2 | 8 | 1 | 30(36) |
| Battleship | B | b | 2 | 10 | 2 | 40(48) |
| Satellite | Z | z | 10 | -- | -- | 50(60) |
Other details: http://www.catb.org/~esr/vms-empire/vms-empire.html
typedef struct piece_attr {
char sname; /* eg 'C' */
char name[20]; /* eg "aircraft carrier" */
char nickname[20]; /* eg "carrier" */
char article[20]; /* eg "an aircraft carrier" */
char plural[20]; /* eg "aircraft carriers" */
char terrain[4]; /* terrain piece can pass over eg "." */
uchar build_time; /* time needed to build unit */
uchar strength; /* attack strength */
uchar max_hits; /* number of hits when completely repaired */
uchar speed; /* number of squares moved per turn */
uchar capacity; /* max objects that can be held */
long range; /* range of piece */
} piece_attr_t;
Gamestate format
The gamestate is a variable that tells the program the state of the game. It is updated constantly and through the Pickle to store the game to a file. I should make it save as a JSON at some point in case people want to create programs other than python to play from savegames.
gamestate['metadata']
This contains metadata about the game, what parameters was used to feed the Perlin Noise generator, size of the map, rounds etc
- width - width of the map
- height - height of the map
- coast_percentage - the percentage of cities that are coastal cities
- scale
- base
- octaves
- persistence
- lucnarity
- xoffset
- yoffset
- turn - who's turn it is, either AI or player
- round - int
gamestate['terrain']
This contains the blueprint of the terrain. It is a two dimensional array with either the one of the following values:
lLandwWatercCity
gamestate['coast']
A list of positions that are costs. Used for city placement. May be useful later on.
gamestate['cities']
List of cities, per city it stores the following:
locationx/y coordinatesideEitherplayeroraiorderWhat its building or doingstageHow far it is doing this
gamestate['units']
List of units, per unit it stores the following:
typeThe unit-type, army, fighter etcsideEitherplayerorailocationx/y coordinateorderStanding order for the units (sentry,waypoint)stagea counter or x/y coordinatemovesHow many moves are lefthitsHow many hits are left
gamestate['fog']
A map with the Fog of War. Not sure about what has been explored or what is still fog.