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.
- Python 3
- noise
-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/yyy
Map size for horizontal and vertical axis from 60-999. Defaults are 100x50-d delay
This 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.
Depending on the context the following keys issue the following commands. There are the following contexts:
global
Commands that work no matter the contextcity
Commands that work with citiesunit
Commands that work with units
l
Display the logsg
Give the AI 1 turnn
Give the AI x turnsq
Save and Quit
p
Pause, do nothingb
Build a unita
armyf
fighterp
patrol boatd
destroyers
submarinet
troop transportc
aircraft carrierb
battleshipz
satellite
Num 12346789
Direction to move/attack/load a unitu
Unload a unit from Transport or Carriers
Turn unit into a sentry for 10 roundsw
Set a waypoint for units to move to
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;
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.
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
This contains the blueprint of the terrain. It is a two dimensional array with either the one of the following values:
l
Landw
Waterc
City
A list of positions that are costs. Used for city placement. May be useful later on.
List of cities, per city it stores the following:
location
x/y coordinateside
Eitherplayer
orai
order
What its building or doingstage
How far it is doing this
List of units, per unit it stores the following:
type
The unit-type, army, fighter etcside
Eitherplayer
orai
location
x/y coordinateorder
Standing order for the units (sentry
,waypoint
)stage
a counter or x/y coordinatemoves
How many moves are lefthits
How many hits are left
A map with the Fog of War. Not sure about what has been explored or what is still fog.