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.
112 lines
3.4 KiB
112 lines
3.4 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>JSDoc: Source: components/GridCell.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/GridCell.component.js</h1>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
<article>
|
|
<pre class="prettyprint source linenums"><code>import {Component} from '../../lib/vues6.js'
|
|
import {GridCellState} from '../module/util.js'
|
|
|
|
const template = `
|
|
<div
|
|
class="game-board-cell-component"
|
|
@click="on_click"
|
|
@mouseover="on_hover($event)"
|
|
@mouseleave="on_mouse_leave"
|
|
v-bind:class="{ disabled: render === GridCellState.Disabled, available: render === GridCellState.Available,
|
|
ship: render == GridCellState.Ship, damaged: render == GridCellState.Damaged, sunk: render == GridCellState.Sunk,
|
|
missed: render == GridCellState.Missed, ghost: has_ghost_ship }"
|
|
>
|
|
|
|
</div>
|
|
`
|
|
|
|
/**
|
|
* A component which represents a single, programmable grid cell.
|
|
* @extends Component
|
|
*/
|
|
class GridCellComponent extends Component {
|
|
static get selector() { return 'app-game-cell' }
|
|
static get template() { return template }
|
|
|
|
/** Properties that can be passed into this component. */
|
|
static get props() {
|
|
return [
|
|
'render',
|
|
'has_ghost_ship',
|
|
]
|
|
}
|
|
|
|
/** Make the "GridCellState" enum available in the template. */
|
|
GridCellState = GridCellState
|
|
|
|
/**
|
|
* Fire a click event.
|
|
*/
|
|
on_click() {
|
|
this.$emit('click')
|
|
}
|
|
|
|
/**
|
|
* Fire a hover event.
|
|
* @param $event
|
|
*/
|
|
on_hover($event) {
|
|
this.$emit('hover', $event)
|
|
}
|
|
|
|
/**
|
|
* Fire a "hoverchange" event.
|
|
*/
|
|
on_mouse_leave() {
|
|
this.$emit('hoverchange')
|
|
}
|
|
}
|
|
|
|
export default GridCellComponent
|
|
</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>
|