Messages modularizated

This commit is contained in:
2021-11-23 22:09:56 -03:00
parent bc60fefd3c
commit a3054c953e
2 changed files with 113 additions and 161 deletions

162
index.js
View File

@@ -1,116 +1,7 @@
const inquirer = require('inquirer')
const colors = require('colors')
const messagesList = {
welcome: {
english: 'Welcome to the Rock Paper and Scissors CLI game!',
spanish: '¡Bienvenido al juego de Piedra Papel o Tijeras desde la consola!'
},
gameTitle: {
english: 'Rock Paper and Scissors CLI game',
spanish: 'Piedra Papel o Tijeras desde la consola'
},
play: {
english: 'Select one option:',
spanish: 'Selecciona una opción'
},
options: {
english: ['Rock', 'Paper', 'Scissors'],
spanish: ['Piedra', 'Papel', 'Tijeras']
},
resultTitle: {
english: 'Results:',
spanish: 'Resultados:'
},
tie: {
english: ' - The result is a draw! GG',
spanish: ' - Empate! Bien Jugado.'
},
victory: {
english: ' - You win!',
spanish: ' - Ganaste!'
},
defeat: {
english: ' - You lost...',
spanish: ' - Perdiste...'
},
computerSelectionTitle: {
english: 'Computer selection:',
spanish: 'Selección de la computadora:'
},
computerSelection: {
english: ' - Computer selection is ',
spanish: ' - La selección de la computadora es '
},
stats: {
title: {
english: 'Stats:',
spanish: 'Estadisticas:'
},
victory: {
english: ' - Victory count: ',
spanish: ' - Victorias: '
},
consecutiveVictory: {
english: ' - Consecutive victory count: ',
spanish: ' - Victorias consecutivas: ',
},
defeat: {
english: ' - Defeat count: ',
spanish: ' - Derrotas: ',
},
},
playAgain: {
title: {
english: 'Do you wanna play again?',
spanish: '¿Quieres jugar otra vez?'
},
options: {
english: ['Yes', 'No'],
spanish: ['Sí', 'No']
}
},
thanksForPlay: {
english: 'Thanks for playing! Francisco Pessano',
spanish: 'Gracias por jugar! Francisco Pessano'
}
}
const messagesList = require('./scripts/messagesList.js')
victoryCount = 0
consecutiveVictoryCount = 0
@@ -184,57 +75,6 @@ function gameLogic(languageSelection) {
console.log(messagesList.tie[languageSelection].bold.yellow)
}
// if (computerSelection === 'Rock') {
// if (userSelection === 'Paper') {
// victoryMessage()
// return
// }
// if (userSelection === 'Scissors') {
// defeatMessage()
// return
// }
// return
// }
// if (computerSelection === 'Paper') {
// if (userSelection === 'Rock') {
// defeatMessage()
// return
// }
// if (userSelection === 'Scissors') {
// victoryMessage()
// return
// }
// return
// }
// if (computerSelection === 'Scissors') {
// if (userSelection === 'Rock') {
// victoryMessage()
// return
// }
// if (userSelection === 'Paper') {
// defeatMessage()
// return
// }
// return
// }
switch (computerSelection) {
case 'Rock':

112
scripts/messagesList.js Normal file
View File

@@ -0,0 +1,112 @@
const messagesList = {
welcome: {
english: 'Welcome to the Rock Paper and Scissors CLI game!',
spanish: '¡Bienvenido al juego de Piedra Papel o Tijeras desde la consola!'
},
gameTitle: {
english: 'Rock Paper and Scissors CLI game',
spanish: 'Piedra Papel o Tijeras desde la consola'
},
play: {
english: 'Select one option:',
spanish: 'Selecciona una opción'
},
options: {
english: ['Rock', 'Paper', 'Scissors'],
spanish: ['Piedra', 'Papel', 'Tijeras']
},
resultTitle: {
english: 'Results:',
spanish: 'Resultados:'
},
tie: {
english: ' - The result is a draw! GG',
spanish: ' - Empate! Bien Jugado.'
},
victory: {
english: ' - You win!',
spanish: ' - Ganaste!'
},
defeat: {
english: ' - You lost...',
spanish: ' - Perdiste...'
},
computerSelectionTitle: {
english: 'Computer selection:',
spanish: 'Selección de la computadora:'
},
computerSelection: {
english: ' - Computer selection is ',
spanish: ' - La selección de la computadora es '
},
stats: {
title: {
english: 'Stats:',
spanish: 'Estadisticas:'
},
victory: {
english: ' - Victory count: ',
spanish: ' - Victorias: '
},
consecutiveVictory: {
english: ' - Consecutive victory count: ',
spanish: ' - Victorias consecutivas: ',
},
defeat: {
english: ' - Defeat count: ',
spanish: ' - Derrotas: ',
},
},
playAgain: {
title: {
english: 'Do you wanna play again?',
spanish: '¿Quieres jugar otra vez?'
},
options: {
english: ['Yes', 'No'],
spanish: ['Sí', 'No']
}
},
thanksForPlay: {
english: 'Thanks for playing! Francisco Pessano',
spanish: 'Gracias por jugar! Francisco Pessano'
}
}
module.exports = messagesList