Skip to content

Commit fdb952b

Browse files
committed
Merge remote-tracking branch 'upstream/main'
2 parents e10747b + 9f9dc7c commit fdb952b

File tree

4 files changed

+75
-21
lines changed

4 files changed

+75
-21
lines changed

js/GameScene.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class GameScene extends Phaser.Scene {
5252
this.createEnvironment();
5353
this.createPlayerEntities();
5454
this.createUI();
55-
//this.setupInput();
5655

5756
this.selectionPointer = this.add.image(0, 0, 'UI_Pointer_white');
5857
this.selectionPointer.setOrigin(0.5, 1);
@@ -506,10 +505,7 @@ getClickedFloorIndex(y) {
506505
const top = fy - halfHeight;
507506
const bottom = fy + halfHeight;
508507

509-
//console.log(`Checking floor ${i}: y=${y}, top=${top}, bottom=${bottom}`);
510-
511508
if (y >= top && y <= bottom) {
512-
//console.log(`→ Clicked floor ${i}`);
513509
return i;
514510
}
515511
}

js/components/Sidebar.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,7 @@ class Sidebar {
8585
const controlsY = GameConfig.SIDEBAR_CONTROLS_Y + 25;
8686

8787
// Left click control
88-
this.leftClickIcon = this.scene.add.graphics();
89-
this.leftClickIcon.fillStyle(0x94a3b8, 1); // Light gray for mouse body
90-
this.leftClickIcon.fillRoundedRect(GameConfig.SIDEBAR_MARGIN, controlsY, 18, 20, 3);
91-
this.leftClickIcon.fillStyle(0x64b5f6, 1); // Accent blue for left button
92-
this.leftClickIcon.fillRect(GameConfig.SIDEBAR_MARGIN + 2, controlsY + 2, 7, 10);
93-
this.leftClickIcon.lineStyle(1, 0x2196f3, 1); // Blue border
94-
this.leftClickIcon.strokeRect(GameConfig.SIDEBAR_MARGIN + 2, controlsY + 2, 7, 10);
88+
this.leftClickIcon = this.createMouseButton(controlsY, true);
9589
this.elements.push(this.leftClickIcon);
9690

9791
this.leftClickText = this.scene.add.text(
@@ -104,13 +98,7 @@ class Sidebar {
10498

10599
// Right click control
106100
const rightClickY = controlsY + 30;
107-
this.rightClickIcon = this.scene.add.graphics();
108-
this.rightClickIcon.fillStyle(0x94a3b8, 1); // Light gray for mouse body
109-
this.rightClickIcon.fillRoundedRect(GameConfig.SIDEBAR_MARGIN, rightClickY, 18, 20, 3);
110-
this.rightClickIcon.fillStyle(0x64b5f6, 1); // Accent blue for right button
111-
this.rightClickIcon.fillRect(GameConfig.SIDEBAR_MARGIN + 9, rightClickY + 2, 7, 10);
112-
this.rightClickIcon.lineStyle(1, 0x2196f3, 1); // Blue border
113-
this.rightClickIcon.strokeRect(GameConfig.SIDEBAR_MARGIN + 9, rightClickY + 2, 7, 10);
101+
this.rightClickIcon = this.createMouseButton(rightClickY, false);
114102
this.elements.push(this.rightClickIcon);
115103

116104
this.rightClickText = this.scene.add.text(
@@ -122,7 +110,19 @@ class Sidebar {
122110
this.elements.push(this.rightClickText);
123111
}
124112

125-
113+
createMouseButton(yPosition, isLeftButton) {
114+
const mouseIcon = this.scene.add.graphics();
115+
mouseIcon.fillStyle(0x94a3b8, 1); // Light gray for mouse body
116+
mouseIcon.fillRoundedRect(GameConfig.SIDEBAR_MARGIN, yPosition, 18, 20, 3);
117+
mouseIcon.fillStyle(0x64b5f6, 1); // Accent blue for active button
118+
119+
const buttonX = isLeftButton ? GameConfig.SIDEBAR_MARGIN + 2 : GameConfig.SIDEBAR_MARGIN + 9;
120+
mouseIcon.fillRect(buttonX, yPosition + 2, 7, 10);
121+
mouseIcon.lineStyle(1, 0x2196f3, 1); // Blue border
122+
mouseIcon.strokeRect(buttonX, yPosition + 2, 7, 10);
123+
124+
return mouseIcon;
125+
}
126126

127127
updatePlayer(_player)
128128
{

js/managers/ElevatorManager.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ class ElevatorManager {
191191
if (Math.abs(dx) < 2) {
192192
player.x = targetX;
193193
player.vx = 0;
194-
//player.spriteRef.setVisible(false);
195194
player.spriteRef.setDepth(0); // Behind the elevator door
196195
player.inElevator = true;
197196
player.waitingForElevator = false;
@@ -223,7 +222,6 @@ class ElevatorManager {
223222
player.targetFloor = null;
224223
player.waitingForElevator = false;
225224
player.inElevator = false;
226-
//player.spriteRef.setVisible(true);
227225
player.spriteRef.setDepth(20); // Return to default front layer
228226
if (player.deferredTargetX !== undefined) {
229227
player.targetX = player.deferredTargetX;

todo.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# TODO: Code Refactoring Checklist
2+
3+
## Duplicate Code Refactoring
4+
5+
### High Priority
6+
- [ ] **Floor Y Position Calculations**
7+
- [ ] Create a centralized `PositionUtils` class for floor calculations
8+
- [ ] Refactor `GameScene.js:262-266` getFloorY()
9+
- [ ] Refactor `BuildingManager.js:38-44` calculateFloorPosition()
10+
- [ ] Update `DoorManager.js:7` floor position calculation
11+
- [ ] Update `ElevatorManager.js` lines 16, 46, 106, 286
12+
13+
### Medium Priority
14+
- [ ] **Idle State Reset Pattern**
15+
- [ ] Create `IdleStateManager` or helper method
16+
- [ ] Refactor 6 instances in GameScene.js (lines 337-340, 344-346, 428-431, 442-445, 450-452, 488-491)
17+
18+
- [ ] **Proximity/Distance Checks**
19+
- [ ] Create `ProximityUtils.isWithinDistance(obj1, obj2, threshold)`
20+
- [ ] Replace distance checks in:
21+
- [ ] `GameScene.js:297` (elevator proximity)
22+
- [ ] `Player.js:45` (movement threshold)
23+
- [ ] `DoorManager.js:41` (door proximity)
24+
25+
- [ ] **Sequential Processing Pattern**
26+
- [ ] Create base class or utility for sequential operations
27+
- [ ] Refactor `ElevatorManager.sequentialBoarding()`
28+
- [ ] Refactor `ElevatorManager.sequentialExiting()`
29+
30+
### Low Priority
31+
- [ ] **Animation Key Generation**
32+
- [ ] Create `AnimationUtils.getAnimationKey(action, spriteKey)`
33+
- [ ] Update `PlayerSprite.js:20-21`
34+
- [ ] Update `AnimationManager.js:7-8`
35+
36+
- [ ] **Sprite Loading Pattern**
37+
- [ ] Create sprite configuration array
38+
- [ ] Loop through configuration in `GameScene.preload()`
39+
- [ ] Remove repetitive sprite loading code
40+
41+
- [ ] **Door Creation Pattern**
42+
- [ ] Create door configuration array with positions
43+
- [ ] Loop through configuration in `GameScene.createEnvironment()`
44+
- [ ] Remove repetitive door.addDoor() calls
45+
46+
- [ ] **Rectangle Creation Pattern**
47+
- [ ] Create helper method in EnvironmentManager
48+
- [ ] Refactor createSky(), createGround(), createBackground()
49+
50+
## Additional Refactoring Tasks
51+
52+
### Code Style Standardization
53+
- [ ] Convert `DoorManager` from prototype to ES6 class
54+
- [ ] Extract magic numbers to `GameConfig.js`
55+
- [ ] Remove active console.log statements (lines 99, 517 in GameScene.js)
56+
57+
### Architecture Improvements
58+
- [ ] Split `GameScene.js` (521 lines) into smaller managers
59+
- [ ] Implement proper state management for Player
60+
- [ ] Create event system for loose coupling between components

0 commit comments

Comments
 (0)