Imperialism Remake Developer Manual¶
Current development in Python using PyQt5.
Contents:
Coding¶
Conventions¶
Note
Currently only as unordered list. Improve (regarding contribution and origin of material).
- Each (significant) submission will be reviewed by another team member who might modify it further.
- Tests have to be programmed for all major parts. Tests have to be performed regularly.
- Code that syntax errors should never be submitted.
- Doc comments have to be added for all methods / classes / modules at submission level. At the latest when the code has matured extensive documentation is a must.
- Always add the GPLv3+ header to new files. Also add name and creation year. They indicate your consent to the open source license.
- Task driven development with short tasks is preferred.
- If chats are conducted, the log will be archived online. Any private information will be deleted before.
- Everything is conducted in the most simple and straightforward way. If a well supported/mature library is available, which is not too complex or overpowered on it’s own, we will always prefer it to coding self.
- Minor tasks will have minor priority. Top priority is always to make the game running, everything else comes later.
- We will not sacrifice clarity for a fast hack. A hack that works somehow but cannot be sufficiently explained or a hack that requires cumbersome or unmotivated modifications should be rejected and the code should be redesigned instead.
Wisdom¶
- Do not import QtWebEngineWidgets before importing QtCore, app will not exit properly on Windows with PyQt5
State¶
Short overview of the functionality of the game at current version 0.2.2.
It shows a start screen with sensitive areas (help center, game lobby, preferences, editor, exit)
It plays some background music (can be muted in the preferences)
It displays some html pages (context sensitive) when clicking on the help center or on the little question marks in dialogs
- The manual has to be built with tools/build_documentation.py before
- The help is displayed in a browser on the running system, an implementation using QtWebEngine is available but not switched on
The preferences dialog has a toolbar with placeholder icons (not made yet, see the tooltips for meaning) switching the widget below and some basic stuff to configure
The editor screen allows to load the one scenario that is included (core/Europe1814.scenario), also a new scenario cac be created and an overview about the nations and provinces can be seen (as a list in the dialogs shown when clicking on the placeholder icons in the toolbar), set terrain (context menu on the map) might not work yet, graphics like borders, rivers, terrain is very crude, navigating the mini map with updates of the map should work
The game lobby offers four tabs controlled by placeholder icons (start single player scenario inbuilt, load single player scenario, server game lobby, start multiplayer scenario)
- Clicking on Europe1814 in the first tab shows a scenario preview which allows to select a nation and clicking on “start selected scenario” should show the main game screen but so far shows only a non-functional skeleton
Internally there is a client-server infrastructure which communicates over TCP/IP as well as a scenario class which hold terrain, nations and provinces and allows to manipulate them
Algorithms¶
Note
Just some keywords.
- Map graphics (semi procedural)
- Railroad/Resource connection test
- Trade logic
- Battle logic
- AI (Diplomacy, Economy, Military)
Scenario¶
Introduction¶
Server Scenario¶
Scenario Editor¶
Scenarios can be edited completely with the scenario editor. Game rules are soft coded. Game logic must of course be somewhat hard coded but we try to allow as much freedom as possible.
During development, need to update between versions!
Scenario parameters * Name of scenario * Description of scenario * Date (year, season), Turns, … * Map (see Map parameters) * Major country description * State of industry, work force, army, specialists for each country * State of research, diplomatic relations, gold for each country
Map parameters * Name * Size * Distribution of terrain, resources, infrastructure * Borders, Provinces, Name of provinces * Countries (Major, Minor)
Client Scenario¶
Scenario File Format¶
Game data is stored in zipped YAML (JSON like) files. We have scenarios. Saved games are also valid scenarios. There is automatic saving. Upon starting (loading) a scenario, some parameters can be changed, but not all.
Adjustable parameters of stored save games upon load: * Player nation * Difficulty level of AI opponents
If a scenario file refers to sub-files, store a hash value to make sure the referred file is the valid one.
During development, need to update between versions!
Network¶
Introduction¶
We use a thin client, that has little to no knowledge about the game mechanics. Communication with the server is via TCP and messages. Messages are simple data structures that are being sent between client and server. They can also be seen as updates or events. The underlying library Qt signals new messages which are then serialized/deserialized (zipped/unzipped). Internally messages are handled by setting listeners to channels.
The server listens on a port, each client is connected to the server by a connection. However clients could be disconnect(ed) during the process, so we must allow re-connection.
Server¶
- Upon start the server binds to a port, then listens for incoming connections.
- Every new connection is assigned a temporary status.A validation message is sent (regularly) which invalidates the state. If correct return comes, status is kept valid.
- Client should send ID (for re-connecting) or request to get new ID.
Client¶
source¶
imperialism_remake package¶
Subpackages¶
imperialism_remake.base package¶
Submodules¶
imperialism_remake.base.constants module¶
imperialism_remake.base.network module¶
imperialism_remake.base.switches module¶
Global switches (and default values).
-
imperialism_remake.base.switches.
DEBUG_MODE
= True¶ global switch for DEBUG MODE
-
imperialism_remake.base.switches.
FILE_EXISTENCE_CHECK
= False¶ global switch for checking existence if files in constants (not needed if we are creating these files)
imperialism_remake.base.tools module¶
Module contents¶
Package base
Very basic functions needed from packages client and server. May only rely on package lib.
imperialism_remake.client package¶
Submodules¶
imperialism_remake.client.audio module¶
imperialism_remake.client.client module¶
imperialism_remake.client.editor module¶
imperialism_remake.client.game module¶
imperialism_remake.client.graphics module¶
imperialism_remake.client.lobby module¶
imperialism_remake.client.preferences module¶
imperialism_remake.client.server_monitor module¶
Submodules¶
imperialism_remake.start module¶
Starts the application (a client and a server). Start in project root folder and with ‘–debug’ as parameter if wished.
imperialism_remake.version module¶
Current version (short and full names).
Module contents¶
Package imperialism_remake
Documentation created on Jan 23, 2018