File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change 22 <div >
33 <div class =" battle-board" >
44 <div class =" title" >BATTLESHIP</div >
5- <div class =" boards-container" >
5+
6+ <div v-if =" winner" class =" end-game-message" :class =" winner" >
7+ {{ winner }} wins !!!
8+ </div >
9+
10+ <div v-else class =" boards-container" >
611 <PlayBoard
712 title =" Player"
813 :rows-count =" 10"
@@ -45,6 +50,7 @@ export default {
4550 },
4651 gameStarted: false ,
4752 humanCanPlay: false ,
53+ winner: null ,
4854 };
4955 },
5056 methods: {
@@ -53,6 +59,7 @@ export default {
5359 this .setAssets (this .IAAssets );
5460 this .gameStarted = true ;
5561 this .humanCanPlay = true ;
62+ this .winner = null ;
5663 },
5764 setAssets (target ) {
5865 const targetRandomAssets = generateRandomAssets ();
@@ -66,6 +73,9 @@ export default {
6673 this .IAAssets .boardCells ,
6774 this .IAAssets .boats ,
6875 );
76+ if (this .IAAssets .boats .aliveShipsCount === 0 ) {
77+ this .winner = " Player" ;
78+ }
6979
7080 if (isHumanShotAccepted) {
7181 this .humanCanPlay = false ;
@@ -76,6 +86,9 @@ export default {
7686 this .playerAssets .boardCells ,
7787 this .playerAssets .boats ,
7888 );
89+ if (this .playerAssets .boats .aliveShipsCount === 0 ) {
90+ this .winner = " IAAssets" ;
91+ }
7992 this .humanCanPlay = true ;
8093 }
8194 }
You can’t perform that action at this time.
0 commit comments