User prompt
rebalance enemy skill attacks and add enemy types
User prompt
Rebalance skills and finalize features
User prompt
result text is blocked, move it down
User prompt
Skills with large amounts of coins should have a higher potential power. and a low minimum
User prompt
Coins are now inside skill buttons, move coin results lower down
User prompt
Still cannot tell difference between enemy and player coins, coins overlap text. Add P for player coins and E for enemy coins
User prompt
doesnt seem to work, redo ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
I cannt tell difference between enemy and player coins Add player and enemy columns
User prompt
Enemy Turn plan is blocked by other text. make sound effects and difference between enemy and player coins ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Theres a problem, when you select skills text appears on top of skill button, but skill button is below a card, making it hard to read
User prompt
Make it so that even if coin fails post clash win minimum power number still deals damage and battle text is blocked
User prompt
Cannot read outcome, revamp button and card locations
User prompt
Revamp skill names, powers, numbers, and visuals ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Expand Skill buttons to let skill buttons actually cover up the text
User prompt
Make assets more appealing. Balance skills and rename skills. Make it so that after someone wins a clash they roll their own skill coins again, one coin = one attack, meaning if a enemy wins and has 3 coins, each coin is 1 attack, and if all three coins are successful a strong attack is dealt. Also add live numbers ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Show enemy’s planned skill, add enemy skills and minimum power and max power
User prompt
show skill’s max clash power and minimum power, as well as clash numbers during fight
User prompt
Make 3 classes player can choose from before fighting, then assign the 6 already made skills to each 2 skill slot for class. Make spearman, samurai, and knife master
User prompt
Two skills are overlapping space them. Add hp system to vary from 80-100. Add up to 6 skills a player can obtain in the 2 skill slots
User prompt
Refine hp and skill button assests to make them more visually appealing
User prompt
Make the text easier to see and make the game clash combat slower ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Redo Coin logic. a skill should itself contain coins to roll, not a skill plus coins to roll.
User prompt
make assests larger
Code edit (1 edits merged)
Please save this source code
User prompt
Coin Clash Combat
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var AttackButton = Container.expand(function (text) { var self = Container.call(this); var buttonBg = self.attachAsset('attackButton', { anchorX: 0.5, anchorY: 0.5 }); buttonBg.tint = 0xff4444; var buttonText = new Text2(text, { size: 70, fill: '#ffffff' }); buttonText.anchor.set(0.5, 0.5); buttonText.x = 0; buttonText.y = 0; self.addChild(buttonText); self.setText = function (newText) { buttonText.setText(newText); }; self.down = function (x, y, obj) { if (gameState === 'ready') { // Add press effect tween(buttonBg, { scaleX: 0.95, scaleY: 0.95, tint: 0xcc3333 }, { duration: 150, easing: tween.easeOut, onFinish: function onFinish() { tween(buttonBg, { scaleX: 1.0, scaleY: 1.0, tint: 0xff4444 }, { duration: 150, easing: tween.bounceOut }); } }); performBattle(); } }; return self; }); var ClassButton = Container.expand(function (className, description, skills) { var self = Container.call(this); var buttonBg = self.attachAsset('classButton', { anchorX: 0.5, anchorY: 0.5 }); var classText = new Text2(className, { size: 50, fill: '#000000' }); classText.anchor.set(0.5, 0.5); classText.x = 0; classText.y = -30; self.addChild(classText); var descText = new Text2(description, { size: 30, fill: '#000000' }); descText.anchor.set(0.5, 0.5); descText.x = 0; descText.y = 30; self.addChild(descText); self.className = className; self.skills = skills; self.down = function (x, y, obj) { if (gameState === 'selectClass') { selectedClass = self; startGame(); } }; return self; }); var CoinButton = Container.expand(function (coinCount) { var self = Container.call(this); var buttonBg = self.attachAsset('coinButton', { anchorX: 0.5, anchorY: 0.5 }); var coinText = new Text2(coinCount.toString(), { size: 80, fill: '#000000' }); coinText.anchor.set(0.5, 0.5); coinText.x = 0; coinText.y = 0; self.addChild(coinText); self.coinCount = coinCount; self.down = function (x, y, obj) { if (gameState === 'selectCoins') { selectedCoins = self.coinCount; gameState = 'ready'; readyButton.alpha = 1; } }; return self; }); var EnemyCard = Container.expand(function () { var self = Container.call(this); var cardBg = self.attachAsset('enemyCard', { anchorX: 0.5, anchorY: 0.5 }); var nameText = new Text2('ENEMY', { size: 60, fill: '#000000' }); nameText.anchor.set(0.5, 0.5); nameText.x = 0; nameText.y = -140; self.addChild(nameText); var healthBorder = self.attachAsset('healthBarBorder', { anchorX: 0.5, anchorY: 0.5 }); healthBorder.x = 0; healthBorder.y = -60; var healthBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBg.x = 0; healthBg.y = -60; var healthBar = self.attachAsset('healthBar', { anchorX: 0.5, anchorY: 0.5 }); healthBar.x = 0; healthBar.y = -60; var healthText = new Text2('100/100', { size: 48, fill: '#000000' }); healthText.anchor.set(0.5, 0.5); healthText.x = 0; healthText.y = -60; self.addChild(healthText); self.updateHealth = function (current, max) { healthText.setText(current + '/' + max); var healthPercent = current / max; healthBar.scaleX = healthPercent; healthBar.x = -250 + 250 * healthPercent; }; return self; }); var FlippingCoin = Container.expand(function () { var self = Container.call(this); var coinGraphic = self.attachAsset('coin', { anchorX: 0.5, anchorY: 0.5 }); self.isFlipping = false; self.result = null; self.flip = function (callback, isPlayer) { self.isFlipping = true; self.result = Math.random() < 0.5 ? 'heads' : 'tails'; // Play different sound based on player/enemy if (isPlayer === true) { LK.getSound('playerCoinFlip').play(); } else if (isPlayer === false) { LK.getSound('enemyCoinFlip').play(); } else { LK.getSound('coinFlip').play(); } // Add initial scale and brightness effect tween(coinGraphic, { scaleX: 1.3, scaleY: 1.3, tint: 0xffffff }, { duration: 100, easing: tween.easeOut }); tween(coinGraphic, { rotation: Math.PI * 6, scaleX: 1.0, scaleY: 1.0 }, { duration: 1800, easing: tween.easeOut, onFinish: function onFinish() { self.isFlipping = false; if (self.result === 'heads') { coinGraphic.tint = 0x00ff66; // Success sparkle effect tween(coinGraphic, { scaleX: 1.4, scaleY: 1.4 }, { duration: 200, easing: tween.easeOut, onFinish: function onFinish() { tween(coinGraphic, { scaleX: 1.0, scaleY: 1.0 }, { duration: 300, easing: tween.bounceOut }); } }); } else { coinGraphic.tint = 0xff3366; // Failure shake effect tween(coinGraphic, { x: coinGraphic.x + 10 }, { duration: 100, easing: tween.easeInOut, onFinish: function onFinish() { tween(coinGraphic, { x: coinGraphic.x - 10 }, { duration: 100, easing: tween.easeInOut }); } }); } if (callback) callback(self.result); } }); }; return self; }); var PlayerCard = Container.expand(function () { var self = Container.call(this); var cardBg = self.attachAsset('playerCard', { anchorX: 0.5, anchorY: 0.5 }); var nameText = new Text2('PLAYER', { size: 60, fill: '#000000' }); nameText.anchor.set(0.5, 0.5); nameText.x = 0; nameText.y = -140; self.addChild(nameText); var healthBorder = self.attachAsset('healthBarBorder', { anchorX: 0.5, anchorY: 0.5 }); healthBorder.x = 0; healthBorder.y = -60; var healthBg = self.attachAsset('healthBarBg', { anchorX: 0.5, anchorY: 0.5 }); healthBg.x = 0; healthBg.y = -60; var healthBar = self.attachAsset('healthBar', { anchorX: 0.5, anchorY: 0.5 }); healthBar.x = 0; healthBar.y = -60; var healthText = new Text2('100/100', { size: 48, fill: '#000000' }); healthText.anchor.set(0.5, 0.5); healthText.x = 0; healthText.y = -60; self.addChild(healthText); self.updateHealth = function (current, max) { healthText.setText(current + '/' + max); var healthPercent = current / max; healthBar.scaleX = healthPercent; healthBar.x = -250 + 250 * healthPercent; }; return self; }); var SkillButton = Container.expand(function (skillName, basePower, coinCount) { var self = Container.call(this); var buttonBorder = self.attachAsset('skillButtonBorder', { anchorX: 0.5, anchorY: 0.5 }); var buttonBg = self.attachAsset('skillButton', { anchorX: 0.5, anchorY: 0.5 }); var minPower = basePower; var maxPower = basePower + coinCount * 2; var skillText = new Text2(skillName + ' (Power: ' + minPower + '-' + maxPower + ', Coins: ' + coinCount + ')', { size: 50, fill: '#000000' }); skillText.anchor.set(0.5, 0.5); skillText.x = 0; skillText.y = 0; self.addChild(skillText); self.skillName = skillName; self.basePower = basePower; self.coinCount = coinCount; self.minPower = minPower; self.maxPower = maxPower; self.selected = false; self.setSelected = function (selected) { self.selected = selected; if (selected) { buttonBg.tint = 0x00ff88; buttonBorder.tint = 0xff8800; tween(buttonBorder, { scaleX: 1.08, scaleY: 1.08 }, { duration: 200, easing: tween.easeOut }); // Add pulsing glow effect tween(buttonBg, { alpha: 0.7 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { tween(buttonBg, { alpha: 1 }, { duration: 800, easing: tween.easeInOut, onFinish: function onFinish() { if (self.selected) { self.setSelected(true); // Continue pulsing } } }); } }); } else { buttonBg.tint = 0x27ae60; buttonBorder.tint = 0x1e8449; buttonBg.alpha = 1; tween(buttonBorder, { scaleX: 1.0, scaleY: 1.0 }, { duration: 200, easing: tween.easeOut }); } }; self.down = function (x, y, obj) { if (gameState === 'selectSkill') { selectedSkill = self; skill1Button.setSelected(false); skill2Button.setSelected(false); self.setSelected(true); gameState = 'ready'; readyButton.alpha = 1; } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x34495e }); /**** * Game Code ****/ // Game state variables var gameState = 'selectClass'; var playerMaxHealth = 80 + Math.floor(Math.random() * 21); // 80-100 HP var enemyMaxHealth = 80 + Math.floor(Math.random() * 21); // 80-100 HP var playerHealth = playerMaxHealth; var enemyHealth = enemyMaxHealth; // Class definitions with their specific skills var playerClasses = [{ name: 'Spearman', description: 'Master of reach and precision', skills: [{ name: 'Dragon Thrust', power: 8, coins: 2 }, { name: 'Storm Barrage', power: 4, coins: 3 }] }, { name: 'Samurai', description: 'Legendary blade master', skills: [{ name: 'Moonlit Severance', power: 12, coins: 1 }, { name: 'Thousand Cuts', power: 3, coins: 4 }] }, { name: 'Knife Master', description: 'Shadow assassin supreme', skills: [{ name: 'Twin Fang Strike', power: 7, coins: 2 }, { name: 'Void Execution', power: 15, coins: 1 }] }]; // Player skills will be assigned after class selection var playerSkills = []; var selectedClass = null; // Enemy skills - each skill now contains its own coins var enemySkills = [{ name: 'Abyssal Corruption', power: 5, coins: 3 }, { name: 'Crimson Talons', power: 8, coins: 2 }, { name: 'Nightmare Howl', power: 6, coins: 2 }, { name: 'Infernal Rampage', power: 11, coins: 1 }, { name: 'Chaos Flurry', power: 3, coins: 4 }, { name: 'Shadow Lunge', power: 9, coins: 1 }]; // Current selection var selectedSkill = null; // Create class selection UI var classSelectionTitle = new Text2('Choose Your Class', { size: 80, fill: '#000000' }); classSelectionTitle.anchor.set(0.5, 0.5); classSelectionTitle.x = 1024; classSelectionTitle.y = 400; game.addChild(classSelectionTitle); var classButtons = []; for (var i = 0; i < playerClasses.length; i++) { var classButton = new ClassButton(playerClasses[i].name, playerClasses[i].description, playerClasses[i].skills); classButton.x = 1024; classButton.y = 700 + i * 300; classButtons.push(classButton); game.addChild(classButton); } // Game UI elements (will be created after class selection) var playerCard = null; var enemyCard = null; var skill1Button = null; var skill2Button = null; var readyButton = null; var statusText = null; var enemySkillText = null; // Battle result area var battleResultText = new Text2('', { size: 60, fill: '#000000' }); battleResultText.anchor.set(0.5, 0.5); battleResultText.x = 1024; battleResultText.y = 1450; game.addChild(battleResultText); // Coin flip display area var coinFlipContainer = new Container(); coinFlipContainer.x = 1024; coinFlipContainer.y = 1500; game.addChild(coinFlipContainer); // Live damage numbers container var liveNumbersContainer = new Container(); liveNumbersContainer.x = 1024; liveNumbersContainer.y = 1800; game.addChild(liveNumbersContainer); function showLiveDamageNumber(damage, x, y, isPlayer) { var damageText = new Text2('-' + damage, { size: 100, fill: isPlayer ? '#ff0066' : '#ff6600' }); damageText.anchor.set(0.5, 0.5); damageText.x = x; damageText.y = y; damageText.alpha = 0; damageText.scaleX = 0.5; damageText.scaleY = 0.5; liveNumbersContainer.addChild(damageText); // Pop in effect tween(damageText, { alpha: 1, scaleX: 1.2, scaleY: 1.2 }, { duration: 300, easing: tween.bounceOut, onFinish: function onFinish() { // Scale back and float up tween(damageText, { scaleX: 1.0, scaleY: 1.0, y: y - 120, alpha: 0 }, { duration: 1200, easing: tween.easeOut, onFinish: function onFinish() { liveNumbersContainer.removeChild(damageText); } }); } }); } function startGame() { // Assign skills based on selected class playerSkills = selectedClass.skills; // Hide class selection UI classSelectionTitle.alpha = 0; for (var i = 0; i < classButtons.length; i++) { classButtons[i].alpha = 0; } // Create game UI elements playerCard = game.addChild(new PlayerCard()); playerCard.x = 1024; playerCard.y = 600; enemyCard = game.addChild(new EnemyCard()); enemyCard.x = 1024; enemyCard.y = 300; // Skills selection - positioned below player card with more spacing skill1Button = game.addChild(new SkillButton(playerSkills[0].name, playerSkills[0].power, playerSkills[0].coins)); skill1Button.x = 1024; skill1Button.y = 950; skill2Button = game.addChild(new SkillButton(playerSkills[1].name, playerSkills[1].power, playerSkills[1].coins)); skill2Button.x = 1024; skill2Button.y = 1130; // Attack button readyButton = game.addChild(new AttackButton('BATTLE!')); readyButton.x = 1024; readyButton.y = 1350; readyButton.alpha = 0.5; // Status text - positioned between player card and skill buttons statusText = new Text2('Choose your skill', { size: 70, fill: '#000000' }); statusText.anchor.set(0.5, 0.5); statusText.x = 1024; statusText.y = 850; game.addChild(statusText); // Enemy skill display text - positioned higher to avoid blocking enemySkillText = new Text2('', { size: 50, fill: '#000000' }); enemySkillText.anchor.set(0.5, 0.5); enemySkillText.x = 1024; enemySkillText.y = 150; game.addChild(enemySkillText); // Initialize health displays playerCard.updateHealth(playerHealth, playerMaxHealth); enemyCard.updateHealth(enemyHealth, enemyMaxHealth); // Change game state gameState = 'selectSkill'; } // Battle logic function performBattle() { if (!selectedSkill) return; gameState = 'battle'; statusText.setText('Battle in progress...'); readyButton.alpha = 0.5; // Player's turn var playerBasePower = selectedSkill.basePower; var playerCoins = selectedSkill.coinCount; // Enemy's turn (AI) var enemySkillIndex = Math.floor(Math.random() * enemySkills.length); var enemySkill = enemySkills[enemySkillIndex]; var enemyBasePower = enemySkill.power; var enemyCoins = enemySkill.coins; var enemyMinPower = enemyBasePower; var enemyMaxPower = enemyBasePower + enemyCoins * 2; // Display enemy's planned skill enemySkillText.setText('Enemy plans: ' + enemySkill.name + ' (Power: ' + enemyMinPower + '-' + enemyMaxPower + ', ' + enemyCoins + ' coins)'); // Clear previous coins coinFlipContainer.removeChildren(); // Flip player coins var playerSuccessfulFlips = 0; var playerCoinsFlipped = 0; for (var i = 0; i < playerCoins; i++) { var coin = new FlippingCoin(); coin.x = (i - (playerCoins - 1) / 2) * 100; coin.y = -50; coinFlipContainer.addChild(coin); // Set player coin color var coinGraphic = coin.getChildAt(0); coinGraphic.tint = 0x4CAF50; // Green for player coins LK.setTimeout(function (coinRef) { return function () { coinRef.flip(function (result) { if (result === 'heads') { playerSuccessfulFlips++; } playerCoinsFlipped++; if (playerCoinsFlipped === playerCoins) { // All player coins flipped, now flip enemy coins flipEnemyCoins(); } }, true); }; }(coin), i * 800); } function flipEnemyCoins() { var enemySuccessfulFlips = 0; var enemyCoinsFlipped = 0; for (var i = 0; i < enemyCoins; i++) { var coin = new FlippingCoin(); coin.x = (i - (enemyCoins - 1) / 2) * 100; coin.y = 50; coinFlipContainer.addChild(coin); // Set enemy coin color var coinGraphic = coin.getChildAt(0); coinGraphic.tint = 0xF44336; // Red for enemy coins LK.setTimeout(function (coinRef) { return function () { coinRef.flip(function (result) { if (result === 'heads') { enemySuccessfulFlips++; } enemyCoinsFlipped++; if (enemyCoinsFlipped === enemyCoins) { // All coins flipped, resolve battle resolveBattle(playerBasePower, playerSuccessfulFlips, playerCoins, enemyBasePower, enemySuccessfulFlips, enemyCoins, enemySkill.name); } }, false); }; }(coin), i * 800 + 3000); } } } function resolveBattle(playerBasePower, playerSuccessfulFlips, playerCoins, enemyBasePower, enemySuccessfulFlips, enemyCoins, enemySkillName) { var playerTotalPower = playerBasePower + playerSuccessfulFlips * 2; var enemyTotalPower = enemyBasePower + enemySuccessfulFlips * 2; var resultText = 'CLASH RESULTS:\n'; resultText += 'Player: ' + playerBasePower + ' base + ' + playerSuccessfulFlips + '/' + playerCoins + ' heads = ' + playerTotalPower + '\n'; resultText += 'Enemy: ' + enemyBasePower + ' base + ' + enemySuccessfulFlips + '/' + enemyCoins + ' heads = ' + enemyTotalPower + '\n'; if (playerTotalPower > enemyTotalPower) { // Player wins - roll attack coins resultText += 'Player wins! Rolling ' + playerCoins + ' attack coins...\n'; rollAttackCoins(playerCoins, true, function (successfulAttacks) { var totalDamage = Math.max(playerBasePower, successfulAttacks); if (successfulAttacks === playerCoins) { totalDamage += 2; // Bonus damage for all successful resultText += 'Perfect attacks! +2 bonus damage!\n'; } enemyHealth -= totalDamage; resultText += 'Enemy takes ' + totalDamage + ' damage (' + successfulAttacks + '/' + playerCoins + ' successful attacks)!'; // Show live damage number showLiveDamageNumber(totalDamage, 0, -100, false); LK.getSound('attack').play(); LK.getSound('victory').play(); // Flash enemy red tween(enemyCard, { tint: 0xff0000 }, { duration: 800, onFinish: function onFinish() { tween(enemyCard, { tint: 0xffffff }, { duration: 800 }); } }); battleResultText.setText(resultText); finalizeBattle(); }); } else if (enemyTotalPower > playerTotalPower) { // Enemy wins - roll attack coins resultText += 'Enemy wins with ' + enemySkillName + '! Rolling ' + enemyCoins + ' attack coins...\n'; rollAttackCoins(enemyCoins, false, function (successfulAttacks) { var totalDamage = Math.max(enemyBasePower, successfulAttacks); if (successfulAttacks === enemyCoins) { totalDamage += 2; // Bonus damage for all successful resultText += 'Perfect attacks! +2 bonus damage!\n'; } playerHealth -= totalDamage; resultText += 'Player takes ' + totalDamage + ' damage (' + successfulAttacks + '/' + enemyCoins + ' successful attacks)!'; // Show live damage number showLiveDamageNumber(totalDamage, 0, 100, true); LK.getSound('damage').play(); LK.getSound('defeat').play(); // Flash player red tween(playerCard, { tint: 0xff0000 }, { duration: 800, onFinish: function onFinish() { tween(playerCard, { tint: 0xffffff }, { duration: 800 }); } }); battleResultText.setText(resultText); finalizeBattle(); }); } else { // Tie resultText += 'It\'s a tie! No damage dealt.'; battleResultText.setText(resultText); finalizeBattle(); } function rollAttackCoins(coinCount, isPlayer, callback) { // Clear previous attack coins var attackCoinsContainer = new Container(); attackCoinsContainer.x = 0; attackCoinsContainer.y = isPlayer ? 150 : -150; coinFlipContainer.addChild(attackCoinsContainer); var successfulAttacks = 0; var coinsFlipped = 0; for (var i = 0; i < coinCount; i++) { var coin = new FlippingCoin(); coin.x = (i - (coinCount - 1) / 2) * 80; coin.y = 0; attackCoinsContainer.addChild(coin); // Set attack coin color based on player/enemy var coinGraphic = coin.getChildAt(0); coinGraphic.tint = isPlayer ? 0x2196F3 : 0xFF5722; // Blue for player attack, orange for enemy attack LK.setTimeout(function (coinRef) { return function () { coinRef.flip(function (result) { if (result === 'heads') { successfulAttacks++; } coinsFlipped++; if (coinsFlipped === coinCount) { callback(successfulAttacks); } }, isPlayer); }; }(coin), i * 400); } } function finalizeBattle() { // Update health displays playerCard.updateHealth(Math.max(0, playerHealth), playerMaxHealth); enemyCard.updateHealth(Math.max(0, enemyHealth), enemyMaxHealth); // Check for game over LK.setTimeout(function () { if (playerHealth <= 0) { LK.showGameOver(); } else if (enemyHealth <= 0) { LK.showYouWin(); } else { // Reset for next turn resetTurn(); } }, 4000); } } function resetTurn() { gameState = 'selectSkill'; selectedSkill = null; skill1Button.setSelected(false); skill2Button.setSelected(false); readyButton.alpha = 0.5; statusText.setText('Choose your skill'); enemySkillText.setText(''); // Clear coin flips LK.setTimeout(function () { coinFlipContainer.removeChildren(); }, 2000); } // Game update loop game.update = function () { // Update status text based on game state if (gameState === 'selectClass') { // Class selection phase - no status updates needed } else if (gameState === 'selectSkill') { if (statusText) statusText.setText('Choose your skill'); if (enemySkillText) enemySkillText.setText(''); } else if (gameState === 'ready') { if (statusText) statusText.setText('Ready to battle with ' + selectedSkill.skillName + ' (Power: ' + selectedSkill.minPower + '-' + selectedSkill.maxPower + ', ' + selectedSkill.coinCount + ' coins)!'); // Show enemy's planned skill when player is ready var enemySkillIndex = Math.floor(Math.random() * enemySkills.length); var enemySkill = enemySkills[enemySkillIndex]; var enemyMinPower = enemySkill.power; var enemyMaxPower = enemySkill.power + enemySkill.coins * 2; if (enemySkillText) enemySkillText.setText('Enemy plans: ' + enemySkill.name + ' (Power: ' + enemyMinPower + '-' + enemyMaxPower + ', ' + enemySkill.coins + ' coins)'); } };
===================================================================
--- original.js
+++ change.js
@@ -482,9 +482,9 @@
fill: '#000000'
});
battleResultText.anchor.set(0.5, 0.5);
battleResultText.x = 1024;
-battleResultText.y = 1600;
+battleResultText.y = 1450;
game.addChild(battleResultText);
// Coin flip display area
var coinFlipContainer = new Container();
coinFlipContainer.x = 1024;
@@ -574,9 +574,9 @@
fill: '#000000'
});
enemySkillText.anchor.set(0.5, 0.5);
enemySkillText.x = 1024;
- enemySkillText.y = 100;
+ enemySkillText.y = 150;
game.addChild(enemySkillText);
// Initialize health displays
playerCard.updateHealth(playerHealth, playerMaxHealth);
enemyCard.updateHealth(enemyHealth, enemyMaxHealth);
@@ -602,35 +602,19 @@
// Display enemy's planned skill
enemySkillText.setText('Enemy plans: ' + enemySkill.name + ' (Power: ' + enemyMinPower + '-' + enemyMaxPower + ', ' + enemyCoins + ' coins)');
// Clear previous coins
coinFlipContainer.removeChildren();
- // Add column headers
- var playerHeader = new Text2('PLAYER', {
- size: 40,
- fill: '#4CAF50'
- });
- playerHeader.anchor.set(0.5, 0.5);
- playerHeader.x = -300;
- playerHeader.y = -80;
- coinFlipContainer.addChild(playerHeader);
- var enemyHeader = new Text2('ENEMY', {
- size: 40,
- fill: '#F44336'
- });
- enemyHeader.anchor.set(0.5, 0.5);
- enemyHeader.x = 300;
- enemyHeader.y = -80;
- coinFlipContainer.addChild(enemyHeader);
// Flip player coins
var playerSuccessfulFlips = 0;
var playerCoinsFlipped = 0;
for (var i = 0; i < playerCoins; i++) {
var coin = new FlippingCoin();
- coin.x = -300 + (i - (playerCoins - 1) / 2) * 100; // Position player coins to the left
- coin.y = 0;
+ coin.x = (i - (playerCoins - 1) / 2) * 100;
+ coin.y = -50;
coinFlipContainer.addChild(coin);
// Set player coin color
- coin.getChildAt(0).tint = 0x4CAF50; // Green for player coins
+ var coinGraphic = coin.getChildAt(0);
+ coinGraphic.tint = 0x4CAF50; // Green for player coins
LK.setTimeout(function (coinRef) {
return function () {
coinRef.flip(function (result) {
if (result === 'heads') {
@@ -649,13 +633,14 @@
var enemySuccessfulFlips = 0;
var enemyCoinsFlipped = 0;
for (var i = 0; i < enemyCoins; i++) {
var coin = new FlippingCoin();
- coin.x = 300 + (i - (enemyCoins - 1) / 2) * 100; // Position enemy coins to the right
- coin.y = 0;
+ coin.x = (i - (enemyCoins - 1) / 2) * 100;
+ coin.y = 50;
coinFlipContainer.addChild(coin);
// Set enemy coin color
- coin.getChildAt(0).tint = 0xF44336; // Red for enemy coins
+ var coinGraphic = coin.getChildAt(0);
+ coinGraphic.tint = 0xF44336; // Red for enemy coins
LK.setTimeout(function (coinRef) {
return function () {
coinRef.flip(function (result) {
if (result === 'heads') {
@@ -748,10 +733,10 @@
}
function rollAttackCoins(coinCount, isPlayer, callback) {
// Clear previous attack coins
var attackCoinsContainer = new Container();
- attackCoinsContainer.x = isPlayer ? -300 : 300; // Separate columns for player and enemy
- attackCoinsContainer.y = 100;
+ attackCoinsContainer.x = 0;
+ attackCoinsContainer.y = isPlayer ? 150 : -150;
coinFlipContainer.addChild(attackCoinsContainer);
var successfulAttacks = 0;
var coinsFlipped = 0;
for (var i = 0; i < coinCount; i++) {
@@ -759,9 +744,10 @@
coin.x = (i - (coinCount - 1) / 2) * 80;
coin.y = 0;
attackCoinsContainer.addChild(coin);
// Set attack coin color based on player/enemy
- coin.getChildAt(0).tint = isPlayer ? 0x2196F3 : 0xFF5722; // Blue for player attack, orange for enemy attack
+ var coinGraphic = coin.getChildAt(0);
+ coinGraphic.tint = isPlayer ? 0x2196F3 : 0xFF5722; // Blue for player attack, orange for enemy attack
LK.setTimeout(function (coinRef) {
return function () {
coinRef.flip(function (result) {
if (result === 'heads') {