You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eecs448-project-1/documentation/generated/components_ScoreBoard.compo...

161 lines
5.4 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Source: components/ScoreBoard.component.js</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Source: components/ScoreBoard.component.js</h1>
<section>
<article>
<pre class="prettyprint source linenums"><code>import {Component} from '../../lib/vues6.js'
import game_service from '../services/GameState.service.js'
import {Player, GameState} from '../module/util.js'
const template = `
&lt;div class="app-scoreboard-component">
&lt;table class="scoreboard_table" style="width:50%">
&lt;tr class="scoreboard_rows">
&lt;th class="scoreboard_table_empty">&lt;/th>
&lt;th class="scoreboard_table_header" colspan="3">scoreboard&lt;/th>
&lt;/tr>
&lt;tr class="scoreboard_header_scoreProgress">
&lt;th class="scoreboard_table_empty">&lt;/th>
&lt;td class="scoreboard_data">score&lt;/td>
&lt;td class="scoreboard_data">progress&lt;/td>
&lt;/tr>
&lt;tr class="scoreboard_rows_score&amp;progress">
&lt;td class="scoreboard_player">{{ current_player === Player.One ? '➜ ' : '' }}Player 1{{ winning_player === Player.One ? ' ★' : '' }}&lt;/td>
&lt;td class="scoreboard_data">{{player_one_score}}&lt;/td>
&lt;td class="scoreboard_data">{{player_one_progress * 100}}%&lt;/td>
&lt;/tr>
&lt;tr class="scoreboard_lastRow">
&lt;td class="scoreboard_player">{{ current_player === Player.Two ? '➜ ' : '' }}Player 2{{ winning_player === Player.Two ? ' ★' : '' }}&lt;/td>
&lt;td class="scoreboard_data">{{player_two_score}}&lt;/td>
&lt;td class="scoreboard_data">{{player_two_progress * 100}}%&lt;/td>
&lt;/tr>
&lt;/table>
&lt;/div>
`
/**
* A component which represents the programmable scoreboard.
* @extends Component
*/
class ScoreBoardComponent extends Component {
static get selector() { return 'app-scoreboard' }
static get template() { return template }
static get props() { return [] }
/**
* The score of player one.
* @type {number}
*/
player_one_score = 0
/**
* The score of player two.
* @type {number}
*/
player_two_score = 0
/**
* The progress of player one, as a decimal.
* @type {number}
*/
player_one_progress = 0
/**
* The progress of player two, as a decimal.
* @type {number}
*/
player_two_progress = 0
/**
* The current player.
* @type {string|undefined}
*/
current_player = undefined
/**
* The winning player.
* @type {string|undefined}
*/
winning_player = undefined
Player = Player
/**
* Called when the component is initialized.
* @return {Promise&lt;void>}
*/
async vue_on_create() {
game_service.on_state_change(() => {
this.update()
})
this.update()
}
/**
* Fetch new data from the game service.
*/
update() {
// here is where you should fetch the data from the game service and update variables on the class
this.player_one_score = game_service.get_player_score(Player.One)
this.player_two_score = game_service.get_player_score(Player.Two)
this.player_one_progress = game_service.get_progress(Player.One)
this.player_two_progress = game_service.get_progress(Player.Two)
if ( game_service.get_game_state() !== GameState.PlayerVictory )
this.current_player = game_service.get_current_player()
else {
this.current_player = undefined
this.winning_player = game_service.get_current_player()
}
}
}
export default ScoreBoardComponent
</code></pre>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-errors.html">errors</a></li><li><a href="module-lang.html">lang</a></li><li><a href="module-sounds.html">sounds</a></li><li><a href="module-util.html">util</a></li></ul><h3>Classes</h3><ul><li><a href="GameBoardComponent.html">GameBoardComponent</a></li><li><a href="GameStateService.html">GameStateService</a></li><li><a href="GridCellComponent.html">GridCellComponent</a></li><li><a href="module-errors.InvalidAdvanceStateError.html">InvalidAdvanceStateError</a></li><li><a href="module-errors.InvalidMissileFireAttemptError.html">InvalidMissileFireAttemptError</a></li><li><a href="module-errors.InvalidShipPlacementError.html">InvalidShipPlacementError</a></li><li><a href="module-sounds-Sound.html">Sound</a></li><li><a href="ScoreBoardComponent.html">ScoreBoardComponent</a></li><li><a href="TopLevelComponent.html">TopLevelComponent</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 3.6.5</a> on Sat Sep 12 2020 16:40:09 GMT-0500 (Central Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>