How gyre-cyanyu/penghucalculator2 works
PenghuCalculator2 is a WeChat mini-program for managing Penghu scorekeeping rooms. Players create or join a room, take seats or spectate, record game actions, and see synchronized scores; settling a room archives its result for later history. The client pages invoke cloud functions and watch live room documents, while cloud functions operate on the rooms, histories, users, and notices collections. The main interaction paths are excerpted; several feature subsystems are represented from README and indexed filenames, so their internal call links are omitted where source evidence is unavailable.
Main entry points: cloudfunctions Room and notice queries · room.ts Live scoring · information.ts Room details · home.ts Home and joining
Components 27
Mini-program client
- Home and joining
miniprogram/pages/home/home.ts - Create room
miniprogram/pages/create/create.ts - Time formatting
miniprogram/utils/format.ts - Image cache
miniprogram/utils/storage.ts - App identity
miniprogram/app.ts
Room and scoring
- Live scoring
miniprogram/pages/room/room.ts - Room details
miniprogram/pages/information/information.ts
User and history
- Profile
miniprogram/pages/profile/profile.ts - History view
miniprogram/pages/history/history.ts - History list
miniprogram/pages/history/history.ts
Cloud operations
- Room creation
cloudfunctions/P2_createRoomData/index.js - Room membership
cloudfunctions/P2_updateMemberList/index.js - Seat selection
cloudfunctions/P2_updateNextPlayerTuple/index.js - Score actions
cloudfunctions/P2_takeOperation/index.js - Undo actions
cloudfunctions/P2_undoAction/index.js - Transfer scores
cloudfunctions/P2_transferScores/index.js - Room settlement
cloudfunctions/P2_settleRoom/index.js - Room state updates
cloudfunctions - Room and notice queries
cloudfunctions - User data operations
cloudfunctions - Room cleanup
cloudfunctions/P2_clearRoomData/index.js
Cloud data
- Rooms collection
- Histories collection
- Users collection
- Notices collection
- Cloud file storage
Other components
- Player
Connections 39
- Player → Home and joining: opens
- Player → Create room: creates
- Home and joining → Room membership: joins room
miniprogram/pages/home/home.ts - Create room → Room creation: creates room
- Live scoring → Seat selection: selects seat
miniprogram/pages/room/room.ts - Room details → Seat selection: selects seat
miniprogram/pages/information/information.ts - Live scoring → Rooms collection: watches updates
miniprogram/pages/room/room.ts - Room details → Rooms collection: watches updates
miniprogram/pages/information/information.ts - Live scoring → Score actions: records action
- Live scoring → Undo actions: requests undo
- Live scoring → Transfer scores: transfers scores
miniprogram/pages/room/room.ts - Room details → Room state updates: updates room state
miniprogram/pages/information/information.ts - Room details → Room settlement: settles room
miniprogram/pages/information/information.ts - Home and joining → Room and notice queries: loads notices
- Home and joining → Room and notice queries: loads joined rooms
- App identity → User data operations: loads current user
miniprogram/app.ts - Profile → User data operations: updates profile
miniprogram/pages/profile/profile.ts - Profile → Cloud file storage: uploads avatar
miniprogram/pages/profile/profile.ts - History view → History list: loads records
miniprogram/pages/history/history.ts - History list → Room and notice queries: fetches histories
miniprogram/pages/history/history.ts - History list → User data operations: fetches members
miniprogram/pages/history/history.ts - History view → Time formatting: formats dates
miniprogram/pages/history/history.ts - History view → Image cache: caches avatars
miniprogram/pages/history/history.ts - App identity → Image cache: caches avatar
miniprogram/app.ts - Room creation → Rooms collection: creates document
- Room membership → Rooms collection: updates members
- Seat selection → Rooms collection: updates seats
cloudfunctions/P2_updateNextPlayerTuple/index.js - Score actions → Rooms collection: updates scores
cloudfunctions/P2_takeOperation/index.js - Undo actions → Rooms collection: revises actions
cloudfunctions/P2_undoAction/index.js - Transfer scores → Rooms collection: updates scores
- Room settlement → Rooms collection: reads room
- Room settlement → Histories collection: archives result
- Room state updates → Rooms collection: updates state
- Room and notice queries → Rooms collection: queries rooms
- Room and notice queries → Histories collection: queries history
- Room and notice queries → Notices collection: queries notices
- User data operations → Users collection: reads and writes
- Room cleanup → Rooms collection: cleans stale rooms
- Image cache → Cloud file storage: downloads files
miniprogram/utils/storage.ts