Skip to content

Commit 0ef1fd6

Browse files
committed
Rename methods, remove 1 unused method
1 parent e40fdb1 commit 0ef1fd6

File tree

1 file changed

+16
-25
lines changed

1 file changed

+16
-25
lines changed

playing-cards-2-planes/Table.js

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export class Table extends Container {
3737

3838
// Track which card is in each cell (null = empty)
3939
// Layout: [0: top, 1: second, 2: third, 3: bottom]
40-
this._quadrantCards = [null, null, null, null];
40+
this._cellCards = [null, null, null, null];
4141

4242
// Debug bounds outline (set alpha to 0 to hide)
4343
this._boundsGraphics = new Graphics();
@@ -84,7 +84,7 @@ export class Table extends Container {
8484
* @returns {object} Object with minX, maxX, minY, maxY for the cell
8585
* @private
8686
*/
87-
_getQuadrantBounds(index) {
87+
_getCellBounds(index) {
8888
const { minX, maxX, minY, maxY } = this._bounds;
8989
const height = maxY - minY;
9090
const quarterHeight = height / 4;
@@ -112,25 +112,16 @@ export class Table extends Container {
112112
* @returns {number[]} Array of free cell indices
113113
* @private
114114
*/
115-
_getFreeQuadrants() {
115+
_getFreeCells() {
116116
const free = [];
117-
for (let i = 0; i < this._quadrantCards.length; i++) {
118-
if (this._quadrantCards[i] === null) {
117+
for (let i = 0; i < this._cellCards.length; i++) {
118+
if (this._cellCards[i] === null) {
119119
free.push(i);
120120
}
121121
}
122122
return free;
123123
}
124124

125-
/**
126-
* Gets the number of cards currently on the table.
127-
* @returns {number} The card count
128-
* @private
129-
*/
130-
_getCardCount() {
131-
return this._quadrantCards.filter(c => c !== null).length;
132-
}
133-
134125
/**
135126
* Draws 4 cell rectangles for debugging purposes.
136127
* Shows the area where card centers can be placed.
@@ -139,8 +130,8 @@ export class Table extends Container {
139130
_drawBounds() {
140131
this._boundsGraphics.clear();
141132

142-
for (let i = 0; i < this._quadrantCards.length; i++) {
143-
const qb = this._getQuadrantBounds(i);
133+
for (let i = 0; i < this._cellCards.length; i++) {
134+
const qb = this._getCellBounds(i);
144135
this._boundsGraphics.rect(qb.minX, qb.minY, qb.maxX - qb.minX, qb.maxY - qb.minY);
145136
this._boundsGraphics.stroke({ width: 2, color: 0xff0000 });
146137
}
@@ -151,10 +142,10 @@ export class Table extends Container {
151142
* @private
152143
*/
153144
_repositionCards() {
154-
for (let i = 0; i < this._quadrantCards.length; i++) {
155-
const card = this._quadrantCards[i];
145+
for (let i = 0; i < this._cellCards.length; i++) {
146+
const card = this._cellCards[i];
156147
if (card) {
157-
const qb = this._getQuadrantBounds(i);
148+
const qb = this._getCellBounds(i);
158149
card.x = Math.min(Math.max(card.x, qb.minX), qb.maxX);
159150
card.y = Math.min(Math.max(card.y, qb.minY), qb.maxY);
160151
card.baseX = card.x;
@@ -174,15 +165,15 @@ export class Table extends Container {
174165
* @returns {boolean} True if card was added, false if all cells are full
175166
*/
176167
addCard(spriteSheet, textureKey, startPos, startAngle, startAlpha, clickHandler = null) {
177-
const freeCells = this._getFreeQuadrants();
168+
const freeCells = this._getFreeCells();
178169

179170
if (freeCells.length === 0) {
180171
return false;
181172
}
182173

183174
// Pick the first free cell (top to bottom order)
184175
const cellIndex = freeCells[0];
185-
const qb = this._getQuadrantBounds(cellIndex);
176+
const qb = this._getCellBounds(cellIndex);
186177

187178
// Random X within the cell, Y fixed at cell center
188179
const x = qb.minX + Math.random() * (qb.maxX - qb.minX);
@@ -197,7 +188,7 @@ export class Table extends Container {
197188
this.addChild(card);
198189

199190
// Mark cell as occupied
200-
this._quadrantCards[cellIndex] = card;
191+
this._cellCards[cellIndex] = card;
201192

202193
if (startPos) {
203194
// Animate card from startPos to target position
@@ -226,9 +217,9 @@ export class Table extends Container {
226217
*/
227218
removeCard(card) {
228219
// Find which cell the card was in and free it
229-
for (let i = 0; i < this._quadrantCards.length; i++) {
230-
if (this._quadrantCards[i] === card) {
231-
this._quadrantCards[i] = null;
220+
for (let i = 0; i < this._cellCards.length; i++) {
221+
if (this._cellCards[i] === card) {
222+
this._cellCards[i] = null;
232223
break;
233224
}
234225
}

0 commit comments

Comments
 (0)