Start single player

Single player mode started with errors.
DESCOMENTAR MENSAGENS NO VUE!
master
Paulo Vieira 2017-12-27 11:53:35 +00:00
parent 6f3aa429cc
commit 79ab5fefa9
10 changed files with 41 additions and 145 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
laravel/.DS_Store vendored

Binary file not shown.

Binary file not shown.

View File

@ -8357,7 +8357,7 @@ button.close {
}
.board {
max-width: 276px;
max-width: 375px;
margin: 0 auto;
border-style: solid;
border-width: 0px 0 0 0px;
@ -8380,4 +8380,3 @@ button.close {
padding: 0;
border-style: none;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 302 B

BIN
laravel/public/img/41.png Executable file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 302 B

View File

@ -46768,7 +46768,7 @@ exports = module.exports = __webpack_require__(2)(undefined);
// module
exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
exports.push([module.i, "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n", ""]);
// exports
@ -46807,16 +46807,15 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
/* harmony default export */ __webpack_exports__["default"] = ({
data: function data() {
return {
title: 'Memory',
showSuccess: false,
showFailure: false,
successMessage: '',
failMessage: '',
title: 'Memory Game',
//showSuccess: false,
//showFailure: false,
//successMessage: '',
//failMessage: '',
currentValue: 1,
gameEnded: false,
player1User: undefined,
player2User: undefined,
board: [0, 0, 0, 0, 0, 0, 0, 0, 0]
board: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
};
},
methods: {
@ -46827,18 +46826,18 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
clickPiece: function clickPiece(index) {
if (this.board[index] || this.gameEnded) return;
this.board[index] = this.currentValue;
this.successMessage = this.currentPlayer + ' has Played';
this.showSuccess = true;
this.currentValue = this.currentValue == 1 ? 2 : 1;
//this.successMessage = this.currentPlayer+' has Played';
//this.showSuccess = true;
this.currentValue = 1;
this.checkGameEnded();
},
restartGame: function restartGame() {
console.log('restartGame');
this.board = [0, 0, 0, 0, 0, 0, 0, 0, 0];
this.showSuccess = false;
this.showFailure = false;
this.successMessage = '';
this.failMessage = '';
this.board = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
//this.showSuccess= false;
//this.showFailure= false;
//this.successMessage= '';
//this.failMessage= '';
this.currentValue = 1;
this.gameEnded = false;
},
@ -46849,19 +46848,9 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
return this.board[0] == value && this.board[1] == value && this.board[2] == value || this.board[3] == value && this.board[4] == value && this.board[5] == value || this.board[6] == value && this.board[7] == value && this.board[8] == value || this.board[0] == value && this.board[3] == value && this.board[6] == value || this.board[1] == value && this.board[4] == value && this.board[7] == value || this.board[2] == value && this.board[5] == value && this.board[8] == value || this.board[0] == value && this.board[4] == value && this.board[8] == value || this.board[2] == value && this.board[4] == value && this.board[6] == value;
},
checkGameEnded: function checkGameEnded() {
if (this.hasRow(1)) {
this.successMessage = this.playerName(1) + ' won the Game';
this.showSuccess = true;
this.gameEnded = true;
}
if (this.hasRow(2)) {
this.successMessage = this.playerName(2) + ' won the Game';
this.showSuccess = true;
this.gameEnded = true;
}
if (this.isBoardComplete()) {
this.successMessage = 'The Game ended in a Tie';
this.showSuccess = true;
//this.successMessage = this.playerName(1) + ', you win!';
//this.showSuccess = true;
this.gameEnded = true;
}
return false;
@ -46881,30 +46870,13 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
// ----------------------------------------------------------------------------------------
playerName: function playerName(playerNumber) {
console.log(playerNumber);
console.log(this.player1User);
if (this.player1User != undefined && playerNumber == 1) {
return this.player1User.name;
}
if (this.player2User != undefined && playerNumber == 2) {
return this.player2User.name;
}
return 'Player ' + playerNumber;
}
},
computed: {
currentPlayer: function currentPlayer() {
console.log(this.currentValue);
console.log(this.playerName(this.currentValue));
return this.playerName(this.currentValue);
}
},
mounted: function mounted() {
if (this.$root.$data.player1) {
this.player1User = this.$root.$data.player1;
}
if (this.$root.$data.player2) {
this.player2User = this.$root.$data.player2;
}
}
});
@ -46922,54 +46894,10 @@ var render = function() {
_vm._v(" "),
_c("br"),
_vm._v(" "),
_c("h2", [_vm._v("Current Player : " + _vm._s(_vm.currentPlayer))]),
_vm._v(" "),
_c("br")
]),
_vm._v(" "),
_c("div", { staticClass: "game-zone-content" }, [
_vm.showSuccess
? _c("div", { staticClass: "alert alert-success" }, [
_c(
"button",
{
staticClass: "close-btn",
attrs: { type: "button" },
on: {
click: function($event) {
_vm.showSuccess = false
}
}
},
[_vm._v("×")]
),
_vm._v(" "),
_c("strong", [
_vm._v(_vm._s(_vm.successMessage) + "     "),
_c(
"a",
{
directives: [
{
name: "show",
rawName: "v-show",
value: _vm.gameEnded,
expression: "gameEnded"
}
],
on: {
click: function($event) {
$event.preventDefault()
_vm.restartGame($event)
}
}
},
[_vm._v("Restart")]
)
])
])
: _vm._e(),
_vm._v(" "),
_c(
"div",
{ staticClass: "board" },

View File

@ -3,15 +3,15 @@
<div>
<h3 class="text-center">{{ title }}</h3>
<br>
<h2>Current Player : {{ currentPlayer }}</h2>
<!-- <h2>Current Player : {{ currentPlayer }}</h2> -->
<br>
</div>
<div class="game-zone-content">
<div class="alert alert-success" v-if="showSuccess">
<!--<div class="alert alert-success" v-if="showSuccess">
<button type="button" class="close-btn" v-on:click="showSuccess=false">&times;</button>
<strong>{{ successMessage }} &nbsp;&nbsp;&nbsp;&nbsp;<a v-show="gameEnded" v-on:click.prevent="restartGame">Restart</a></strong>
<strong>{{ successMessage }} &nbsp;&nbsp;&nbsp;&nbsp;<a v-show="gameEnded" v-on:click.prevent="restartGame">Restart</a></strong>
</div>
-->
<div class="board">
<div v-for="(piece, key) of board" >
<img v-bind:src="pieceImageURL(piece)" v-on:click="clickPiece(key)">
@ -26,16 +26,15 @@
export default {
data: function(){
return {
title: 'Memory',
showSuccess: false,
showFailure: false,
successMessage: '',
failMessage: '',
title: 'Memory Game',
//showSuccess: false,
//showFailure: false,
//successMessage: '',
//failMessage: '',
currentValue: 1,
gameEnded:false,
player1User: undefined,
player2User: undefined,
board: [0,0,0,0,0,0,0,0,0]
board: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
}
},
methods: {
@ -46,18 +45,18 @@
clickPiece: function(index) {
if(this.board[index] || this.gameEnded) return;
this.board[index] = this.currentValue;
this.successMessage = this.currentPlayer+' has Played';
this.showSuccess = true;
this.currentValue = (this.currentValue == 1)? 2 : 1;
//this.successMessage = this.currentPlayer+' has Played';
//this.showSuccess = true;
this.currentValue = 1;
this.checkGameEnded();
},
restartGame:function(){
console.log('restartGame');
this.board= [0,0,0,0,0,0,0,0,0];
this.showSuccess= false;
this.showFailure= false;
this.successMessage= '';
this.failMessage= '';
this.board= [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
//this.showSuccess= false;
//this.showFailure= false;
//this.successMessage= '';
//this.failMessage= '';
this.currentValue= 1;
this.gameEnded= false;
},
@ -75,19 +74,9 @@
((this.board[2]==value) && (this.board[4]==value) && (this.board[6]==value));
},
checkGameEnded: function(){
if (this.hasRow(1)) {
this.successMessage = this.playerName(1) + ' won the Game';
this.showSuccess = true;
this.gameEnded = true;
}
if (this.hasRow(2)) {
this.successMessage = this.playerName(2) + ' won the Game';
this.showSuccess = true;
this.gameEnded = true;
}
if (this.isBoardComplete()) {
this.successMessage = 'The Game ended in a Tie';
this.showSuccess = true;
//this.successMessage = this.playerName(1) + ', you win!';
//this.showSuccess = true;
this.gameEnded = true;
}
return false;
@ -107,30 +96,13 @@
// ----------------------------------------------------------------------------------------
playerName: function(playerNumber){
console.log(playerNumber);
console.log(this.player1User);
if(this.player1User != undefined && playerNumber == 1){
return this.player1User.name;
}
if(this.player2User != undefined && playerNumber == 2){
return this.player2User.name;
}
return 'Player '+playerNumber;
}
},
computed:{
currentPlayer: function(){
console.log(this.currentValue);
console.log(this.playerName(this.currentValue));
return this.playerName(this.currentValue);
}
},
mounted(){
if(this.$root.$data.player1){
this.player1User = this.$root.$data.player1;
}
if(this.$root.$data.player2 ){
this.player2User = this.$root.$data.player2;
}
}
}
</script>

View File

@ -18,10 +18,10 @@
.board{
max-width: 276px;
margin: 0 auto;
border-style: solid;
border-width: 0px 0 0 0px;
border-style: solid;
border-width: 0px 0 0 0px;
border-color: black;
div{
display: inline-block;
border-style: solid;
@ -39,6 +39,3 @@
border-style: none;
}
}