Giter Club home page Giter Club logo

trk21's People

Contributors

terryebdon avatar

trk21's Issues

Move game space management out of the Trek class

There's a lot of Quadrant and Galaxy manipulation in Trek. This has resulted
in a very large class that can be confusing. Creating new QuadrantManagement
and GalaxyManagement classes would simplify the things.
GameSpaceManagement

Simplify and clarify Trek.positionKlingons()

Trek.positionKlingons() is badly named. It does far more than its name implies, and the actual positioning of enemies occurs in trek.positionEnemy(). The commented-out code should also be removed.

Space storm damage to device 6, damage control, stack dumps

This looks like an off-by-one error:

assert key > 0 && key < devices.size()
       |   |   |  |   | |       |
       6   true|  6   | |       6

at net.ebdon.trk21.DamageControl.inflictDamage(DamageControl.groovy:121)

i.e. it should be <= device.size(). It would be better to use a Range for
this, e.g.

assert key in 1..devices.size()

Torpedo fire

Firing a torpedo should:

  1. Display a track until either:
  • it hits the target, or
  • it leaves the sector.
  1. Remove the target from the game if the torpedo hits it, where a target can be any game object, i.e.
  • An enemy ship.
  • A star base.
  • A star.
  1. Tell the user they've won the game when the last target is destroyed.

Note: Some of these items may be implemented as part of issue #3.

TrekTest.testGame() is too slow.

The testGame() method is very slow, e.g. nearly two and a quarter seconds on an old laptop.
See also issue #18, as I suspect it has the same cause. i.e. Trek is a sub-class of LoggingBase.

image

New feature: Navigation Computer

When "test playing" the game it would save time if the tester could bypass the guess-work required to navigate to a particular sector or quadrant, without resorting to a scientific calculator. A "cheat" or "wizard" mode should be implemented to allow access to this feature. it should be possible to enable and disable the feature via cofinguration.

Localise all user interaction

Most interaction is localised, but there are some significant ommisions. Resolving these will require some changes to the UI interface classes. The test classes will also need changes, to consistently verify resource bundle usage and not depend on unlocalised messages.

Damage map should be a private member of DamageControl.

DamageControl holds a reference to the Trek.damage map. This map is directly referenced by:

  • Trek.spaceStorm()
  • Trek.setCourse()
  • Trek.longRangeScan()
  • TrekLongRangeScanTest.testScanDamaged()

The damage map should be a private member of DamageControl.

Common log settings for test and main

A separate log configuration for test was added by issue #16. The two log configurations are now completely independent of each other. However some configuration is now duplicated, e.g. the log file location and file pattern. It should be possible to move common configuration into a single file.

Reduce JaCoCo impact on build times

The JaCoCo plugin was applied to the build to address issue #19 - Report test coverage. While this works well it is extremely slow. This is apparently due to the instrumentation and analysis (particularly the latter), even when a HTML report is not generated.

Unit tests without JaCoCo plugin

C:\projects\Trk21>gradlew test --rerun-tasks

> Task :test
BUILD SUCCESSFUL in 55s
5 actionable tasks: 5 executed

Unit tests with JaCoCo plugin

C:\projects\Trk21>gradlew test --rerun-tasks

> Task :test
BUILD SUCCESSFUL in 2m 7s
5 actionable tasks: 5 executed

Should it be possible to run out of energy while docked?

When docked the star base will always protect the ship from enemy fire and top-up the ship's energy. Under which circumstances should a docked ship's energy be exhausted?

  STARDATE:  2608        CONDITION: DOCKED
  QUADRANT: 5 - 7           SECTOR: 5 - 7
    ENERGY:  3000  PHOTON TORPEDOS: 10
  KLINGONS:    19

Command: p
  Number of units to fire: 3000
  Phasers locked in on target. Energy available 3000
  1137 unit hit on Enemy ship No. 1 at sector 3 - 2
  Enemy ship destroyed!
  3000 unit hit on Enemy ship No. 2 at sector 6 - 8
  Enemy ship destroyed!
  987 unit hit on Enemy ship No. 3 at sector 8 - 1
  Enemy ship destroyed!
  It is stardate 2608

 Your ship has been destroyed after 8 years.
 Your civilisation will be conquered.
 There are still 16 enemy ships.
 You are dead.

Don't use ClasspathResourceManager for localisation

The Language resource bundle is located via ClasspathResourceManager. This should not be needed; it would be better to use ResourceBundle.getBundle

It's possible that the existing code is not respecting the user's locale settings. ๐Ÿž

See also: #33

Should ship be 'blocked' by a star base?

Trying to travel through a star base is shown as an impact. Stopping next to a base is docking. But the ship is always docked after an impact. This is possibly confusing.

  ---------------
  . . . . * . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . *
  . E . . . . . B
  . . . . . . . .
  ---------------
  STARDATE:  2414        CONDITION: GREEN
  QUADRANT: 2 - 7           SECTOR: 2 - 7
    ENERGY:   877  PHOTON TORPEDOS: 10
  KLINGONS:    21

Command: c
  Course (1-8.99999): 1
  Warp Factor (0-12): 1
  Ship blocked by base at sector [7, 8] == 8 - 7
  ---------------
  . . . . * . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . *
  . . . . . . E B
  . . . . . . . .
  ---------------
  STARDATE:  2415        CONDITION: DOCKED
  QUADRANT: 2 - 7           SECTOR: 7 - 7
    ENERGY:  3000  PHOTON TORPEDOS: 10
  KLINGONS:    21

Auto Short-Range Scan required after course moves.

The original code performs a short range scan after a course move. My Groovy code does not do this automatically; it should.

Output from original code, running on an emulated PDP-11 via SIMH V39-0

COMMAND? C
COURSE (1-8.99999)? 1
WARP FACTOR (0-12)? 3


---------------
* . * . . . . .
. . . . . . . .
. . E * . . . .
. . . . . . . .
. . . . . . . .
. . B * . . . .
. . . . . . . .
. . . . . . . .
---------------

STARDATE: 3501           CONDITION: YELLOW
QUADRANT: 4 - 6          SECTOR: 3 - 3
ENERGY: 2976             PHOTON TORPEDOS: 10
KLINGONS: 21

COMMAND? ^C

Ready

TrekCalendarTest.testTick() is too slow

This test just adds one to an integer and checks the result against TrekCalendar.tick(). Why does a simple test, involving only integer addition and comparison, take nearly 3.5 seconds to run?

image

Short Range Sensors are never disabled

When short range sensors are damaged they still responds to an 'S' command, and still display output following course moves.

Command: c
  Course (1-8.99999): 1
  Warp Factor (0-12): .5
  *** Space Storm, device.S.R..SENSORS damaged ***
  ---------------
  . . . . . . . E
  . B . . . . . *
  . . . . . * . .
  . . * . . . . .
  . . . . . . . .
  . . . * . . . .
  . . . . . . . .
  . . . . . . . .
  ---------------
  STARDATE:  2812        CONDITION: YELLOW
  QUADRANT: 7 - 2           SECTOR: 8 - 1
    ENERGY:  2064  PHOTON TORPEDOS: 10
  KLINGONS:    33

Command: c
  Course (1-8.99999): 5
  Warp Factor (0-12): .75
  Repair systems are working on damage to device.S.R..SENSORS, state improved to -3
  ---------------
  . E . . . . . .
  . B . . . . . *
  . . . . . * . .
  . . * . . . . .
  . . . . . . . .
  . . . * . . . .
  . . . . . . . .
  . . . . . . . .
  ---------------
  STARDATE:  2813        CONDITION: DOCKED
  QUADRANT: 7 - 2           SECTOR: 2 - 1

Prefer Groovy assertions to JUnit assertions

Most of the existing unit tests use JUnit style asserts It would be better to use Grovvy's power assertions as:

  1. Power assertion provide more informative error messages.
  2. It reduces coupling to JUnit.

Use a class/enum for FederationShip condition

Currently the ship's condition is held in a string member variable which is assigned with / checked against various hard-coded values. This makes localisation awkward and requires additional code to check that only allowed values are used. replacing the string with a class / enum would simplify the code. This is also a prerequisite for issues #33 and #37.

Phaser fire

Firing a phaser should:

  1. Reduce the target's available energy by the hit amount.
  2. Remove the target from the game if it's energy <= 0.
  3. Inform the user of the weapon's effectiveness.
  4. Tell the user they've won the game when the last target is destroyed.

Note: Some of these items may be deferred until torpedo firing is implemented, or moved into their own enhancement.

Separate log configurations for test and main.

Changing log levels has a dramatic effect on the run time of a gradle check command. e.g. on an old & slow laptop it can vary between 28 seconds, at ERROR level, and over 4 minutes, at TRACE level. Separating the test and main log configuration will resolve this.

Log performance and noisiness should also be reviewed, under a separate issue. It would also good to use common logging configuration between test and main where possible; another issue will be raised for this.

Add tests for long range scans

Currently Trek.longRangeScan() is difficult to test. It might be better to move it into Galaxy, or a dedicated class.

Trek.isValid() is overly complex

Trek.isValid() is overly complex. It should be simpler and clearer.
Note: There is a similar problem in FederationShip.isValid().

JaCoCo shows a complexity of 24. See the JaCoCo report for the current values.

image

The repeated use of != null should be eliminated by using the ?. operator. isValid() should be replaced by valid. Screen shot is from the JaCoCo detail report.

image

Build fails with Java 17 and Gradle 7.4.1

FAILURE: Build failed with an exception.

* Where:
Build file 'O:\projects\Trk21\build.gradle' line: 52

* What went wrong:
A problem occurred evaluating root project 'trk21'.
> Could not find method compile() for arguments [{group=org.apache.logging.log4j, name=log4j-api, version=2.11.2}] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

Report test-coverage

There are currently 58 implemented tests, but test coverage is patchy. Implementing code-coverage reporting would provide a bench-mark.

Better logging of ship's energy changes

Energy use should be easier to determine from the log. With the log at level debug and using a filter of (fire)|(energy)|(unit), with the Atom language-log package, I can see course changes correctly modifying energy levels, but changes due to damage / enemy-fire are less obvious.

Enemy fleet should not counter-attack when the ship is docked

While docked the ship should be protected from all enemy attacks, but this is not always the case. The enemy fleet will attack under two conditions:

  1. Immediately before executing a user-requested maneuver.
  2. As a counter-attack in response to phaser fire or a torpedo launch.

In scenario 1 the ship is protected, and this prevents the fleet from attacking. A check in Trek.enemyAttacksBeforeShipCanMove() enables this protection.

In scenario 2 the battle computer initiates a fleet counter-attack without asking the ship if it is protected. This is a bug. A fix is required in Battle.enemyCounterAttacks().

image

"Using key: [x,y]" debug messages appear in game output

The message appears every time a short-range scan is performed:

Using key: [8, 4]
  ---------------
  . . . . . . . .
  . . . . . . . .
  . . . . . . . *
  . . . . . . . .
  . . . . . . . .
  * . . . . . . .
  . * . . . . . .
  . E . . . . . .
  ---------------
  STARDATE:  3600        CONDITION: YELLOW
  QUADRANT: 4 - 8           SECTOR: 2 - 8
    ENERGY:  3000  PHOTON TORPEDOS: 10
  KLINGONS:    23

Looks like the culprit is line 38 in Galaxy.groovy.

Replace TrekMock & FederationShipMock with MockFor

  • RpositionerTestBase references TrekMock
  • TrekMock references FederationShipMock

It should be relatively easy to eliminate the FederationShipMock class. Getting
rid of TrekMock may be more difficult, due to the coupling between trek and
Repositioner.

Minimum warp factor should be 0.125, not 0.25

  1. Maximum warp factor is reduced to 0.2 when the engines are damaged. But ShipVector rejects any WarpFactor < 0.25. As the ship is only repaired during course moves this prevents the ship from ever moving again.
  2. A warp factor of 0.25 moves the ship by 2 sectors (horizontally or vertically, less for diagonals.) To cross one sector a warp factor of 0.125 is required. i,e, it's currently not possible to make these short moves.
Command: s
  ---------------
  . . * . . . . .
  . . . . . . . .
  . . . . E . . *
  . . . . . B . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  ---------------
  STARDATE:  3116        CONDITION: DOCKED
  QUADRANT: 4 - 5           SECTOR: 5 - 3
    ENERGY:  3000  PHOTON TORPEDOS: 10
  KLINGONS:    17

Command: c
  Course (1-8.99999): 7
  Warp Factor (0-12): .2

Command: s
  ---------------
  . . * . . . . .
  . . . . . . . .
  . . . . E . . *
  . . . . . B . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  . . . . . . . .
  ---------------
  STARDATE:  3116        CONDITION: DOCKED
  QUADRANT: 4 - 5           SECTOR: 5 - 3
    ENERGY:  3000  PHOTON TORPEDOS: 10
  KLINGONS:    17

Command:

Update Groovy to version 4.0.6

Trk21 is build with Groovy version 2.5.8,, the latest Groovy release is 4.0.6. This is not a "drop-in" replacement, as some Groovy classes have changed or moved. e.g. AntBuilder. New versions of Jacoco and CodeNarc will be required. Also the Gradlew wrapper will have to be updated.

From: build.gradle:

    implementation 'org.codehaus.groovy:groovy-all:2.5.8'

Depends on issue #48.

Can't enter a warp factor of 0.2 when the engines are damaged.

This is odd as the code looks OK, from a quick glance. (Ignore the hard-coded messages and keys, they're logged as seperate issues.)

image

Despite the above test a warp factor of .2 is rejected:

image

This may be related to issue #6 - Minimum warp factor should be 0.125, not 0.25, though that issue is closed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.