Economy: free vs paid games + buy-coins page; friends remove confirmation

- Coins only matter for ranked: free games (vs computer / private friend rooms)
  cost nothing; random ranked requires an entry (stake), gated by balance →
  routes to buy-coins when short
- Buy Coins page (CoinPack/getCoinPacks/buyCoins; mock credits now, real
  Zarinpal/IDPay TODO); TopBar coins → buy; lobby create-room is Free
- Friends: removed instant red ✕ delete; UserMinus → inline confirm before remove

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
soroush.asadi
2026-06-04 16:28:59 +03:30
parent fe136f7ee4
commit cdb8d522dd
12 changed files with 257 additions and 38 deletions
+21
View File
@@ -21,6 +21,7 @@ import {
AppNotification,
AuthSession,
ChatMessage,
CoinPack,
Conversation,
DailyRewardState,
Friend,
@@ -772,6 +773,26 @@ export class MockOnlineService implements OnlineService {
/* --------------------- leaderboard / shop / daily ------------------ */
async getCoinPacks(): Promise<CoinPack[]> {
return [
{ id: "p1", coins: 1000, bonus: 0, priceToman: 19000 },
{ id: "p2", coins: 5000, bonus: 500, priceToman: 89000, tag: "popular" },
{ id: "p3", coins: 12000, bonus: 2000, priceToman: 179000, tag: "best" },
{ id: "p4", coins: 30000, bonus: 7000, priceToman: 399000 },
];
}
async buyCoins(packId: string) {
const p = await this.getProfile();
const pack = (await this.getCoinPacks()).find((x) => x.id === packId);
if (!pack) return { ok: false, coins: 0 };
// NOTE: real payment (Zarinpal/IDPay) goes here. For now we credit instantly.
const added = pack.coins + pack.bonus;
this.profile = { ...p, coins: p.coins + added };
this.saveProfile();
return { ok: true, profile: this.profile, coins: added };
}
private onlineCount = 600 + Math.floor(Math.random() * 900);
async getOnlineCount(): Promise<number> {
// gentle random walk so the badge feels alive