asyncmeonov / Uni-UniversityDominationA4

Repository for last assessed part of York University SEPR module 2017-2018
https://starmix.devsprime.com/Projects/4
1 stars 0 forks source link

Rework codebase #7

Closed asyncmeonov closed 6 years ago

asyncmeonov commented 6 years ago

Codebase requires general re-writing to detangle the acquired spaghetti code.

A non-exhaustive list of refactoring tasks

  1. Exchange getters/setters for properties
  2. Re-implement Memento pattern
  3. Standardise code documentation. Current docs contain signatures of people who implemented particular code snippets, which is made redundant by the existence of git blame
luvies commented 6 years ago

Side note, because the refactor will likely involve the moving of a lot of code (to organise it better), git blame will not track the blame from before properly. Taking this into account, do we still want to remove the blame comments?

asyncmeonov commented 6 years ago

I find neither a practical, nor a deliverable-related usage of these comments. They are also sometimes put in summary tags which I personally find highly off-putting. I'd say into the trash they go.

asyncmeonov commented 6 years ago

Some methods/properties are never referenced (e.g. this one in the minigame, both GetSaves and DeleteFile (I haven't seen any "display list of saved games" functionality, did they leave it for us to implement ?) and the Unit property for colour)

luvies commented 6 years ago

The vector one seems really useless, it might have been for the minigame (since that's the only place it's really dealing with vectors), the others might have a use (although they will need adjusting I think when we bring things up)

luvies commented 6 years ago

We also need to remove the reliance on PlayerPrefs, since it is used for things like controls and game options, not game state data.

luvies commented 6 years ago

Because the current system is a tangled mess, it makes working on it very difficult, even more so with adding the new features that we need. I have come up with a proposal on a restructuring of the code base to move logic around and simplify the entire system:

luvies commented 6 years ago

We need to nail down what stats and effect we are planning to add (or could add, if we could add an effect, we should implement the ability to) so we know how to implement the effects in general. Things like 'bonus attack/defence' or bonus range (within constraints, e.g. controlled sectors only).

luvies commented 6 years ago

I'm starting work on the rework, meaning all code is subject to change. Part of this pass will include adding in the basic foundations for #17. Since I will be altering how we manage the game, I will be including some data in this comment as a reference.

Player Colours

luvies commented 6 years ago

The core rework is now done. The minigame, effect system, and saving/loading have not been reworked yet, however this is next. The effect system (#17) is the next highest priority, as it is now the basis on how a lot of the internals will work. This includes the landmark bonuses and minigame reward. By doing this, we can simplify and generalise much of the things that happen to players, allowing for a more powerful effect system.

luvies commented 6 years ago

Commit c2af184 has implemented the memento pattern, with some following doing some further tweaks to implement it fully. The doc point in the main comment is done as well, since the complete rework will have removed most, if not all, of those comments.

The final items left to do is the minigame logic (since it needs to be altered to work with the effect reward system), main menu logic (since it also needs to be brought in line with the new code), saving/loading logic (since, now the memento pattern is done, it can be implemented), and fixing the unit tests (since they are still trying to test the old code).

luvies commented 6 years ago

The saving/loading logic (3e95cb0) and main menu code (6d2533b) have been implemented/brought up, meaning that only the minigame and unit tests are left.

luvies commented 6 years ago

The game now runs, albeit with bugs. I haven't checked the main menu or the minigame yet, and all the unit tests are excluded from the builds, but it's progress.

luvies commented 6 years ago

The rework is now mostly done. All that's left is testing it to find any remaining bugs, and to fix all the unit tests. Testing can be done by all of us, but I'll work on the unit tests soon.

luvies commented 6 years ago

The minigame has be reworked to play better. More info in #3.

luvies commented 6 years ago

As of b07c455, the unit tests have been completely rewritten to work with the new codebase. I've also added more fixtures to tests parts of the code that now have more logic in and are worth testing, meaning overall coverage is greater.

The only things I haven't tested are the events in Game and the propagation of them, however this is difficult to test and can be mostly tested via gameplay testing. I have also tested the raising of events lower down (in sector and unit), meaning that it's just the propagation and handling by Game that isn't tested, however this shouldn't be difficult to test via gameplay.

Thanks to this final rewrite, the rework is now complete. All future development will be focused on extending the game to accommodate the new requirements and design.

luvies commented 6 years ago

Oh, saving/loading aren't tested either at the moment, however gameplay testing has ensured correctness up till now.