Code Monkey home page Code Monkey logo

superstartrek's Introduction

superstartrek

>>>>Click to play<<<<

Super Star Trek revived as an HTML 5 app.

A mobile friendly web remake of Super Star Trek

Screenshot 1

Screenshot 2

Developing

Important note: the main development branch is gh-pages

GWT devmode configuration for Eclipse: -startupUrl index.html -war target/sst -noserver -style PRETTY -XmethodNameDisplayMode ONLY_METHOD_NAME superstartrek.sst-dev

Build locally: mvn install

Software architecture

This chapter records random considerations regarding software architecture.

Why GWT?

The first edition of SST was written with plain Javascript and jquery, but suffered from bugs, memory leaks, bad cross browser compatibility and bad performance. It didn't have unit- or integration tests and as the game logic became more complex the Javascript language features didn't help with design.

The Google Web Toolkit is a Java-to-Javascript compiler which performs advanced code optimisations, abstracts browser differences away at compile- rather than run-time and grants all the benefits of a statically typed language (which the game logic greatly benefits from). Also, the main developer of this project is more familiar with the Java ecosystem than the Javascript ecosystem.

Why a PWA?

Progressive Web Apps run on all major browser platforms and can be installed as native applications offline on mobile phones and desktop computers. They are written in HTML and Javascript and thus do not require platform-specific binary deployment packages. All this greatly improves user access to the game and reduces development and maintenance effort.

Why did superstartrek not stick to the original user interface?

The original user interface was conceived in the 70s and optimised for terminals with keyboards. The game falls clearly into the strategy genre and thus is best played with either a mouse or a touch screen. Also, because it is 50 years later now and technology and user expectations have changed. The graphically, map-centred UI of superstartrek is more intuitive and easier to interact with on mobile devices.

The Model-View-Presenter-Controller pattern

The MVPC design pattern is better suited for UI-driven applications than the MVC pattern.

Views are thin, dumb wrappers around the client UI API; in this case the browser DOM. They are meant to be simple because, as having dependencies on the browser API, they can not be unit tested easily (without introducing another framework). Views don't try to abstract any domain concepts, instead they export underlying technology concepts to their public APIs. That is why views in superstartrek often have methods like addCssToCell(css, id) which require the caller to be aware of styling semantics. Views register listeners to DOM events such as onClick and call presenter methods. Views implement one interaction element only, such as a widget or a screen. Views do not implement multiple screens or widgets.

Presenters implement domain logic and deal with controllers and views, so they are aware of both view APIs and the underlying technology semantics and domain concepts. Since presenters don't rely on any technology APIs they can be easily unit tested when provided with mocked dependencies. Presenters implement a single domain activity such as the short range scanner or the context menu. Presenters expose callback methods for the view to invoke when a DOM event occurs.

Controllers take care of overarching concerns, mainly control transitions between presenters. superstartrek has two controllers, the GameController which starts the game and observes game-over conditions and the PWA controller which deals with technical topics such as version updates and caching.

Events

Domain events extends the Event class and represent events that happen in the game such as a Klingon firing or the Enterprise consuming energy. Presenters register listeners and broadcast events with the EventBus. An event-based design has the benefit of decoupling events from actions, so that the component which generates an event isn't concerned with who reacts to it. Also event-based code is easier to unit test. The main drawback are unintended side effects when a component modifies, as a reaction to an event, shared data structures - other components accessing those data structures may change behaviour based on the change in the shared data structures which makes the event processing order important.

UIHandler

The, ill named, UIHandler implements repeatedly used functionality for user interaction. Currently it simplifies the registration and consumption of click events. TThe UIHandler listens for click events on the document level, so no special per-element setup is required. The view registers a data-uih attribute on a DOM element (this can be done directly in the HTML template) with a key (string value). When that element is clicked, the UIHandler fires an Events.INTERACTION event with the data-uih value as a parameter. If the data-uih attribute is empty, the element's ID is used. A useful convention: if the data-uih value is of the form string_number_number then the UIHandler.parseCoordinatesFromTag can be used to convert the number pair into a Point instance.

superstartrek's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

superstartrek's Issues

Highscore

Compute a score out of klingons neutralised divided by time.

Remember state

When the browser is closed, the current state should be saved. When the web page is opened again, the saved state should be restored.

fix srs

srs doesn't colour Klingon quadrants correctly of they have just been explored

Crew combat

Crew should be another scalar property which suffers damage from enemy fire. Low values impede the ship's operations. Crew can be replenished at star bases. When shields are low (eg. < 10%), Klingons should beam over from nearby raiders, killing crew.

Raiders should suffer penalties when losing crew due to failed boarding attempts.

adjust reactor output

#42 reduced base consumption, which leaves enough reactor output to always warp and travel at full speed, even when phasers were fired.

update app menu

App menu should include "check for updates". Disable auto update check

Pre load SVG

even with the pwa primed, there is a noticeable flicker when icons are viewed for the first time.

About screen

About & credits screen:

  • title
  • version
  • URL
  • author
  • libraries
  • licences

Energy budget for starship

The core reactor's energy output reactor should dictate "rounds" instead of a fixed amount of moves. The way to do it:

  1. Define energy output (energy/time) for ship reactor. That is the round's budget.
  2. Every action consumes energy by reducing the available budget.
  3. Only actions are possible which consume less than the remaining budget

Some implications are:

  • It's possible to perform multiple actions in the same round (i.e. fire phasers twice, fire phasers and move, all of that + torpedos)
  • Shields consume budget, hence keeping shields high reduces firepower and maneuverability

Klingon damage model

Klingon raiders should also implement a damage model:

  • impulse drive should sustain damage and immobilise raiders
  • disruptors should sustain damage and become inoperational
  • if a raider is not destroyed before Enterprise leaves the sector, then the raider is repaired

LRS click nowhere

steps: LRS, click on a sector title (e.g. capella) instead of a sector. This will show a blank page with hash #undefined.

update check fails

  1. button should be disabled while checking
  2. show error message of update check fails

Losing the game

  1. Losing the game should trigger a technical, semantic event
  2. It should not be possible to play the game anymore after it was lost. Only the option to restart it should be available

Detect collision during navigation

Current behavior:
When navigating inside a quadrant it is possible to move over or onto sector which contains already an object (star, starbase, enemy ship).

Expected behavior:
Movement should cease in front of the object obstructing movement in the direction of movement

Opportunistic saving

currently the game progress is saved at the beginning of each turn. saving should be offloaded to a timer that checks flags and saves only when the game is idle

AI for enemy ships

Implement AI for enemy raiders:

  • Raider fires at us on sight
  • Raider positions itself if it has no clear line of fire

Phasers balancing

Current behavior: when shooting a raider out of immediate vicinity with low-intensity phasers the raider blows up.
Expected behavior: since low-intensity phasers are 25 energy units and a raider has 100 HP, only light damage should be inflicted

Implement damage model

Implement damage system for our starship. Damage is caused:

  • randomly
  • as a result of enemy fire
  • by nearby explosions (when firing on enemy raiders or accidentally hitting a starbase)

Afflicted damage affects:

  • quadrant overview
  • short range scan
  • long range scan
  • navigation
  • warp drives
  • shields
  • computer
  • photon torpedos
  • energy reserves

Winning condition

Upon destruction of the last raider the game should terminate with a winning message

Repairs at starbase

When docking at a federation starbase options should be given to:

  • refuel energy
  • stock on photon torpedos
  • conduct repairs

which require an appropriate number of turns

Smarter PWA caching

The local cache competes with regular resource loading, often downloading resources twice (once for the app and once into the cache). This ticket implements a conditional sequence:

  1. defer application initialisation
  2. feature-detect if caching and service workers are supported
  3. if (2) true, initialise cache and continue deferred application initialisation
  4. if (2) not true then immediately continue deferred application initialisation

Minor repairs while moving

During warp travel and navigation (even in battle), minor repairs could take place. These repairs don't reduce score.

Klingon swarms

currently Klingons are placed randomly into a quadrant. the generator should create swarms of defined strength and composition.

Implement near range scan

Implement near range scan that shows overview (enemy raiders / federation starbases / stars) of neighboring quadrants

Better status indicator

The status report button currently shows remaining antimatter. It should show a composite "health score", consisting of antimatter reserves, engine health and reactor capacity.

More nuanced star map

Most sectors are boring; make sure sectors have personalities:

  • empty sectors with few or no stars
  • sectors with many stars
  • star bases with few stars
  • klingons form swarms

Implement round count

A round indicator for rounds (stardays) that have passed and the remaining amount of rounds. The following actions consume rounds:

  • navigation inside a quadrant
  • warping between quadrants
  • firing weapons
  • docking to a federation starbase

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.