This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
zeroRandom (OIManka) — 股票交易 × 扭蛋抽卡 × OJ 积分联动的 Web 小游戏。PHP + SQLite + 无框架。
URL (e.g. /market.php) → Standalone PHP file → loads bootstrap (config + core + session) → loads template
- 无路由 — 每个页面是独立
.php文件(不是通过 index.php 路由) - 模板 — PHP 文件直接包含
templates/layout/header.php和templates/layout/footer.php
$_SESSION['layer']—'default'或'kaleidoscope'is_kaleidoscope()— helpers.php 中的辅助函数- 天界模式:白主题、独立
kaleidoscope_balance、只显示 fake stocks(adapter_name='fake') - 检测入口:
helpers.php,init_check.php
| Class | Responsibility |
|---|---|
Database |
SQLite PDO singleton, migrations via CREATE TABLE IF NOT EXISTS + ALTER TABLE column migrations |
Session |
Session wrapper, flash messages, auth helpers |
TokenSystem |
Token balance: getBalance, add, spend, transfer + kaleidoscope variants |
StockEngine |
Stock queries, price history, market summary, rarity recalculation |
TradingEngine |
Buy/sell logic, portfolio, withdraw profits |
GachaEngine |
Gacha pulls, rarity weights, pity system, pool pulls |
PoolEngine |
Card pool CRUD, limited edition pools, split pools |
MarketEngine |
P2P card market listings, buy/cancel |
CheckinEngine |
Daily check-in logic |
QuestEngine |
Quest/achievement progress tracking |
AutoJob |
Periodic tasks: pool expiry, online tracking, auto price refresh, holdings limit |
AdapterInterface— contract for platform adaptersHustojAdapter— MySQL-based HustOJ connectionHydrojAdapter— HTTP API-based HydroOJ connection (currently removed)manager.php—AdapterManagerregistry/factory
- SQLite (
data/oimanka.db), WAL mode - Migrations in
Database::migrate()— creates tables + runsALTER TABLE ADD COLUMN setup.php— standalone migration tool with table/column structure detection
- Defined in
helpers.php, loaded viainit_check.php - Three modes:
wan(万/亿),4digit(1,2345),3digit(1,234) - Stored in
$_SESSION['number_style']
Session::flash('success', '消息内容');
// Displayed automatically in header.php- All templates in
templates/, layouts intemplates/layout/ - Template variables set in the entry PHP file, then
includethe template
bash deploy.sh # Uses sshpass, excludes config.php & data/# Browser: visit /setup.php, enter key from config.php
# CLI: php setup.php verifysetup, then refresh /setup.phpconfig.phpis excluded from deploy — new constants must also go inhelpers.php- SQLite doesn't support nested transactions — use direct SQL instead of
TokenSystem::add()/spend()within transactions - Stock queries auto-filter to
adapter_name='fake'when$_SESSION['layer'] === 'kaleidoscope'