Skip to content

Commit

Permalink
Merge branch 'main' into pr/teuswx/3
Browse files Browse the repository at this point in the history
  • Loading branch information
andremaravilha committed May 15, 2024
2 parents 73feae9 + b50c91d commit c0730c2
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 105 deletions.
27 changes: 20 additions & 7 deletions .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Build and Deploy

on:
# Runs on pushes targeting the default branch
# Runs on pushes targeting the main branch
push:
branches:
- main
Expand Down Expand Up @@ -31,25 +31,38 @@ jobs:

- name: Checkout 🛎️
uses: actions/checkout@v3

#- name: Rename image files to lowercase characters only 🔧
# run: |
# sudo apt-get install -y rename
# find ./src/assets/cards/imagens/ -depth -exec rename 's/(.*)\/([^\/]*)/$1\/\L$2/' {} \;

- name: Resize images for production 🔧
run: |
sudo apt-get install -y imagemagick
mogrify -resize 600 ./src/assets/cards/imagens/*[.png,.jpg,.jpeg,.PNG,.JPG,.JPEG]
mogrify -resize 600 -format png ./src/assets/cards/imagens/*[.png,.jpg,.jpeg,.PNG,.JPG,.JPEG]
- name: Remove unnecessary files 🔧
run: |
rm -f ./src/assets/cards/imagens/*.jpg
rm -f ./src/assets/cards/imagens/*.jpeg
rm -f ./src/assets/cards/imagens/*.PNG
rm -f ./src/assets/cards/imagens/*.JPG
rm -f ./src/assets/cards/imagens/*.JPEG
- name: Set up Node 🔧
- name: Set up Node.js 🔧
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 20
cache: 'npm'

- name: Install dependencies 🔧
- name: Install project dependencies 🔧
run: npm install

- name: Build 🔧
- name: Build project 🔧
run: npm run build

- name: Setup Pages 🔧
- name: Setup GitHub Pages 🔧
uses: actions/configure-pages@v3

- name: Upload artifact 🔧
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
"bugs": {
"url": "https://github.com/cefetmg-dv/hepgame/issues"
},
"engines": {
"node": ">=18.0.0"
},
"dependencies": {
"@popperjs/core": "^2.11.7",
"bootstrap": "^5.2.3",
Expand Down
74 changes: 36 additions & 38 deletions src/components/Board.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,50 +8,50 @@
<div class="row">
<div class= "col align-self-center">
<div class= "row mb-5">
<Card :cardId="6" class="deck-card-1" ></Card>
<Carta :carta="6" class="deck-card-1" ></Carta>
</div>

<div class= "row">
<Card :cardId="6" class="deck-card-2" ></Card>
<Carta :carta="6" class="deck-card-2" ></Carta>
</div>
</div>

<!-- Aqui ficam posicionados a mão e o campo do jogador 1 -->

<div class="col-10">
<div class="row justify-content-center mb-2">
<div v-for="(card, index) in player1.cards" :key="index" class="col-1">
<Card :cardId="card.id" class="deck-card-1"></Card>
<div v-for="(carta, idx) in jogador_1.cartas" :key="idx" class="col-1">
<Carta :carta="carta.id" class="deck-card-1"></Carta>
</div>
</div>
<div class="row justify-content-center mb-3">
<div v-for="(card, index) in player1.cards" :key="index" class="col-2">
<Card :cardId="card.id" class="deck-card-1"></Card>
<div v-for="(carta, idx) in jogador_1.cartas" :key="idx" class="col-2">
<Carta :carta="carta.id" class="deck-card-1"></Carta>
</div>
</div>

<!-- Aqui ficam posicionados a mão e o campo do jogador 2-->

<div class="row justify-content-center mb-2">
<div v-for="(card, index) in player2.cards" :key="index" class="col-2">
<Card :cardId="card.id" class="deck-card"></Card>
</div>
<div v-for="(carta, idx) in jogador_2.cartas" :key="idx" class="col-2">
<Carta :carta="carta.id" class="deck-card"></Carta>
</div>
</div>
<div class="row justify-content-center">
<div v-for="(card, index) in player2.cards" :key="index" class="col-1">
<Card :cardId="card.id" class="deck-card"></Card>
</div>
<div v-for="(carta, idx) in jogador_2.cartas" :key="index" class="col-1">
<Carta :carta="carta.id" class="deck-card"></Carta>
</div>
</div>
</div>

<!-- Aqui ficam posicionados os gênios do jogador 1 e 2 -->

<div class= "col align-self-center">
<div class= "row mb-5">
<Card :cardId="6" class="genio-card-1"></Card>
<Carta :carta="6" class="genio-card-1"></Carta>
</div>
<div class= "row ">
<Card :cardId="6" class="genio-card-2 " ></Card>
<Carta :carta="6" class="genio-card-2 " ></Carta>
</div>
</div>

Expand All @@ -65,47 +65,45 @@
<!-- JavaScript -->
<!-- ---------------------------------------------------------------------- -->
<script>
import cardUtils from '@/composables/card-utils.js';
import Card from '@/components/Card.vue';
import hepCartas from '@/lib/hep-cartas.js';
import Carta from '@/components/Carta.vue';
export default {
components: {
Card
Carta
},
data() {
return {
player1: {
name: 'Player 1',
cards: [],
jogador_1: {
nome: 'Jogador 1',
cartas: [],
},
player2: {
name: 'Player 2',
cards: [],
},
//
jogador_2: {
nome: 'Jogador 2',
cartas: [],
}
};
},
created() {
this.player1.cards.push(cardUtils.getCard(1));
this.player1.cards.push(cardUtils.getCard(2));
this.player1.cards.push(cardUtils.getCard(3));
this.player1.cards.push(cardUtils.getCard(4));
this.player1.cards.push(cardUtils.getCard(5));
this.jogador_1.cartas.push(hepCartas.buscarCartaPorId(1));
this.jogador_1.cartas.push(hepCartas.buscarCartaPorId(2));
this.jogador_1.cartas.push(hepCartas.buscarCartaPorId(3));
this.jogador_1.cartas.push(hepCartas.buscarCartaPorId(4));
this.jogador_1.cartas.push(hepCartas.buscarCartaPorId(5));
this.player2.cards.push(cardUtils.getCard(1));
this.player2.cards.push(cardUtils.getCard(2));
this.player2.cards.push(cardUtils.getCard(3));
this.player2.cards.push(cardUtils.getCard(4));
this.player2.cards.push(cardUtils.getCard(5));
this.jogador_2.cartas.push(hepCartas.buscarCartaPorId(1));
this.jogador_2.cartas.push(hepCartas.buscarCartaPorId(2));
this.jogador_2.cartas.push(hepCartas.buscarCartaPorId(3));
this.jogador_2.cartas.push(hepCartas.buscarCartaPorId(4));
this.jogador_2.cartas.push(hepCartas.buscarCartaPorId(5));
},
mounted() {
// TODO
},
methods: {
//função para preencher uma mão
preencher(){
this.player1.cards.push(cardUtils.getCard(this.gerarNumeroAleatorio(1,10)));
preencher() {
this.jogador_1.cartas.push(hepCartas.buscarCartaPorId(this.gerarNumeroAleatorio(1,10)));
},
gerarNumeroAleatorio(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
Expand Down
17 changes: 9 additions & 8 deletions src/components/Card.vue → src/components/Carta.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<!-- HTML -->
<!-- ---------------------------------------------------------------------- -->
<template>
<div class="hep-card">
<img :src="card.imagem" :alt="card.nome" class="rounded">
<div class="hep-carta">
<img :src="dados.imagem" :alt="dados.nome" class="rounded">
</div>
</template>

Expand All @@ -12,23 +12,24 @@
<!-- JavaScript -->
<!-- ---------------------------------------------------------------------- -->
<script>
import cardUtils from '@/composables/card-utils.js';
import hepCartas from '@/lib/hep-cartas.js';
export default {
props: {
cardId: {
carta: {
type: String,
required: true
}
},
data() {
return {
card: null,
dados: null
}
},
methods: {
},
created() {
this.card = cardUtils.getCard(this.cardId);
this.dados = hepCartas.buscarCartaPorId(this.carta);
},
}
</script>
Expand All @@ -38,14 +39,14 @@ export default {
<!-- CSS -->
<!-- ---------------------------------------------------------------------- -->
<style scoped>
.hep-card {
.hep-carta {
margin: 0;
padding: 0;
max-width: 100% !important;
width: 100% !important;
}
.hep-card img {
.hep-carta img {
width: 100%;
height: auto;
}
Expand Down
35 changes: 0 additions & 35 deletions src/composables/card-utils.js

This file was deleted.

84 changes: 84 additions & 0 deletions src/lib/hep-cartas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import fm from 'front-matter';
import { marked } from 'marked';
import DOMPurify from 'dompurify';


const ARQUIVOS = import.meta.glob(`/src/assets/cards/*.md`, { as: 'raw', eager: true });
const URL_CARTA_SEM_IMAGEM = new URL(`/src/assets/card-noimage.png`, import.meta.url).href;
const PATH_IMAGENS = '/src/assets/cards/imagens';

// Arrays que armazenam os dados das cartas
const CARTAS = [];
const GENIOS = [];

// Obtém os dados das cartas a partir dos arquivos .md
for (let key of Object.keys(ARQUIVOS)) {

// Extrai os atributos e o texto da carta
const { attributes, body } = fm(ARQUIVOS[key]);
const carta = {
...attributes,
descricao: DOMPurify.sanitize(marked.parse(body))
};

// Define a URL da imagem da carta
if (carta.imagem) {

// Correção temporária até que os arquivos .md das cartas sejam ajustados
carta.imagem = carta.imagem.substring(0, carta.imagem.lastIndexOf('.'));

carta.imagem = new URL(`${PATH_IMAGENS}/${carta.imagem}.png`, import.meta.url).href;
} else {
carta.imagem = URL_CARTA_SEM_IMAGEM;
}

// Adiciona a carta ao array de cartas
CARTAS.push(carta);

// Adiciona o gênio ao array de gênios
if (carta.genio) {
GENIOS.push(carta);
}
}

// Ordena as cartas em ordem crescente pelo id
CARTAS.sort((a, b) => a.id - b.id);


export default {

/**
* Retorna um array com todas as cartas.
* @returns {Array} Retorna um array com todas as cartas.
*/
buscarCartas() {
return CARTAS;
},

/**
* Retorna um array com as cartas de gênios.
* @returns {Array} Retorna um array com as cartas de gênios.
*/
buscarGenios() {
return GENIOS;
},

/**
* Retorna um array com as cartas do deck de um gênio específico.
* @param {String} genio Nome do deck/gênio.
* @returns {Array} Retorna um array com as cartas do deck.
*/
buscarCartasPorGenio(genio) {
return CARTAS.filter(carta => carta.deck === genio);
},

/**
* Retorna uma carta a partir de seu id.
* @param {Number} id Id da carta.
* @returns {Object} Retorna um objeto com os dados da carta.
*/
buscarCartaPorId(id) {
return CARTAS.find(carta => carta.id === id);
}

};
10 changes: 10 additions & 0 deletions src/lib/hep-game.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import hepCartas from '@/lib/hep-cartas.js';

class Jagador {
constructor(nome, deck) {
this.nome = nome;
this.deck = deck;
this.cartas = [];
this.energia = 1;
}
}
Loading

0 comments on commit c0730c2

Please sign in to comment.