class Card { constructor(name) { this.name = name; } } class Bang extends Card {…
- User
class Card { constructor(name) { this.name = name; } }
class Bang extends Card { constructor() { super(“Bang”); }
isPlayable(target, player, playedCards) { const misseds = playedCards.filter(card => card.constructor === Missed); return target !== player && !target.hasMissed && misseds.length === 0; }
play(player, target) { target.health -= 1; target.hasMissed = false; } }
class Missed extends Card { constructor() { super(“Missed!”); }
isPlayable(target, player, playedCards) { return playedCards.filter(card => card.constructor === Missed).length === 0; }
play(player, target) { target.hasMissed = true; } }
class Beer extends Card { constructor() { super(“Beer”); }
isPlayable() { return true; }
play(player) { player.health += 1; } }
class Player { constructor(name, health, hand) { this.name = name; this.health = health; this.hand = hand; this._hasMissed = false; }
get hasMissed() { return this._hasMissed; }
hasCard(card) { return this.hand.includes(card); }
removeCard(card) { this.hand = this.hand.filter(c => c !== card); }
toString() { return {this.health}, Hand: ${this.hand.map(card => card.name)}); } }
class Game { constructor(players, deck) { if (players.length < 2) { throw new Error(“At least 2 players are required.”); } this.players = players; this.deck = deck; this._currentPlayerIndex = Math.floor(Math.random() * players.length); this.playedCards = []; }
get currentPlayerIndex() { return this._currentPlayerIndex; }
set currentPlayerIndex(value) { this._currentPlayerIndex = value % this.players.length; }
- Assistant
- User
refactor
- Assistant
- User
refactor more
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.