implement Strike and Block card from Slay the Spire into Javascript classes
- User
implement Strike and Block card from Slay the Spire into Javascript classes
- Assistant
//Define a Card class class Card { constructor(name, cost) { this.name = name; this.cost = cost; }
//Define the effect of Strike card strike(target) { target.hitPoints -= 6; }
//Define the effect of Block card block(target) { target.blockPoints += 5; } }
//Initialize Strike and Block cards as instances of the Card class const strike = new Card("Strike", 1); const block = new Card("Block", 1);
//Define a Character class class Character { constructor(name, hitPoints, blockPoints) { this.name = name; this.hitPoints = hitPoints; this.blockPoints = blockPoints; }
//Define the attack method attack(target, card) { if (this.blockPoints > 0) { console.log(
${this.name} Blocked!); this.blockPoints -= 1; } else { card.strike(target); console.log(${this.name} did 6 damage to ${target.name}. ${target.name} has ${ target.hitPoints } hit points left.); } }//Define the defend method defend(card) { card.block(this); console.log(
${this.name} gained 5 block points.); } }//Create two instances of the Character class const player = new Character("Player", 50, 0); const enemy = new Character("Enemy", 30, 0);
//Simulate the game console.log(
${player.name}: ${player.hitPoints} hit points.); console.log(${enemy.name}: ${enemy.hitPoints} hit points.);player.attack(enemy, strike); enemy.defend(block); player.attack(enemy, strike); enemy.attack(player, strike); player.attack(enemy, strike);
console.log(
${player.name}: ${player.hitPoints} hit points.); console.log(${enemy.name}: ${enemy.hitPoints} hit points.);//OUTPUT: // Player: 50 hit points. // Enemy: 30 hit points. // Player did 6 damage to Enemy. Enemy has 24 hit points left. // Enemy gained 5 block points. // Player did 6 damage to Enemy. Enemy has 18 hit points left. // Enemy did 6 damage to Player. Player has 44 hit points left. // Player did 6 damage to Enemy. Enemy has 12 hit points left. // Player: 44 hit points. // Enemy: 12 hit points.
- User
implement Flex card from slay the spire
- Assistant
//Define a Card class class Card { constructor(name, cost) { this.name = name; this.cost = cost; }
- User
Flex gives 2 Strength (add additional damage to attack) until the end of turn
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.