feat: Implement card data management with multiple decks
- Added card-data.js file to define four different decks (Player default, Warrior, Mage, Archer) - Each deck contains 10 creature cards with randomized attack, shield, and health values - Updated index.html to load the new card data script before main.js - Modified main.js to initialize player deck using predefined deck1 instead of generating random cards - Removed old deck generation code from main.js
This commit is contained in:
parent
282c30eba4
commit
8e8bc514ad
|
|
@ -29,7 +29,10 @@
|
||||||
<!-- Load Phaser 3 from CDN -->
|
<!-- Load Phaser 3 from CDN -->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/phaser@3.70.0/dist/phaser.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/phaser@3.70.0/dist/phaser.min.js"></script>
|
||||||
|
|
||||||
|
<!-- Card data scripts -->
|
||||||
|
<script src="src/card-data.js"></script>
|
||||||
|
|
||||||
<!-- Game script -->
|
<!-- Game script -->
|
||||||
<script src="src/main.js" type="module"></script>
|
<script src="src/main.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,61 @@
|
||||||
|
// Card data definitions for different decks
|
||||||
|
// Each deck contains 10 cards with attack, shield, health and required-army-size attributes
|
||||||
|
|
||||||
|
// Deck 1 - Player's default deck (will be assigned to player)
|
||||||
|
window.deck1 = [
|
||||||
|
{ id: 1, number: 1, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 2, number: 2, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 3, number: 3, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 4, number: 4, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 5, number: 5, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 6, number: 6, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 7, number: 7, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 8, number: 8, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 9, number: 9, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 10, number: 10, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 }
|
||||||
|
];
|
||||||
|
|
||||||
|
// Deck 2 - Warrior deck
|
||||||
|
window.deck2 = [
|
||||||
|
{ id: 1, number: 1, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 2, number: 2, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 3, number: 3, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 4, number: 4, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 5, number: 5, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 6, number: 6, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 7, number: 7, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 8, number: 8, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 9, number: 9, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 10, number: 10, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 }
|
||||||
|
];
|
||||||
|
|
||||||
|
// Deck 3 - Mage deck
|
||||||
|
window.deck3 = [
|
||||||
|
{ id: 1, number: 1, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 2, number: 2, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 3, number: 3, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 4, number: 4, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 5, number: 5, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 6, number: 6, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 7, number: 7, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 8, number: 8, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 9, number: 9, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 10, number: 10, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 }
|
||||||
|
];
|
||||||
|
|
||||||
|
// Deck 4 - Archer deck
|
||||||
|
window.deck4 = [
|
||||||
|
{ id: 1, number: 1, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 2, number: 2, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 3, number: 3, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 4, number: 4, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 5, number: 5, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 6, number: 6, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 7, number: 7, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 8, number: 8, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 9, number: 9, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 },
|
||||||
|
{ id: 10, number: 10, type: 'creature', attack: Math.floor(Math.random() * 5) + 1, shield: Math.floor(Math.random() * 5) + 1, health: Math.floor(Math.random() * 5) + 1, requiredArmySize: 1 }
|
||||||
|
];
|
||||||
|
|
||||||
|
// Make all decks available globally for the game
|
||||||
|
window.allDecks = [window.deck1, window.deck2, window.deck3, window.deck4];
|
||||||
13
src/main.js
13
src/main.js
|
|
@ -141,17 +141,8 @@ function create() {
|
||||||
currentPlayer: 'player'
|
currentPlayer: 'player'
|
||||||
};
|
};
|
||||||
|
|
||||||
// Create a 10-card deck with numbers 1-10
|
// Assign the first deck (deck1) to the player
|
||||||
this.gameState.playerDeck = [];
|
this.gameState.playerDeck = [...window.deck1];
|
||||||
for (let i = 1; i <= 10; i++) {
|
|
||||||
this.gameState.playerDeck.push({
|
|
||||||
id: i,
|
|
||||||
number: i,
|
|
||||||
type: 'creature', // placeholder type
|
|
||||||
attack: Math.floor(Math.random() * 5) + 1, // random attack value
|
|
||||||
health: Math.floor(Math.random() * 5) + 1 // random health value
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// Shuffle the deck using Fisher-Yates algorithm (using Phaser's scope)
|
// Shuffle the deck using Fisher-Yates algorithm (using Phaser's scope)
|
||||||
shuffleDeck(this.gameState.playerDeck);
|
shuffleDeck(this.gameState.playerDeck);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue